Wednesday, January 20, 2021

Machine learning

 

Machine learning (ML) is a type of artificial intelligence (AI) that allows software applications to become more accurate at predicting outcomes without being explicitly programmed to do so. 

 

Machine learning algorithms use historical data as input to predict new output values.

 




Applications of Machine Learning:

Dynamic Pricing
Product recommendations
Traffic prediction
Self-driving cars
Email Spam and Malware Filtering

 

 

 

Regression models

What is regression??

Regression can be said to be a technique to find out the best relationship between the input variables known as predictors and the output variable also known as response/target variable.

Best relationship is signified by minimal difference between the predicted and the actual values.

Regression analysis is an important tool for modelling and analyzing data. Here, we fit a curve / line to the data points, in such a manner that the differences between the distances of data points from the curve or line is minimized.

It indicates the strength of impact of multiple independent variables on a dependent variable.
 
 

Linear regression


It is a supervised learning algorithm mostly used in predictive analysis which typically means trying to fit the best straight line between the input and output variables in order to model our data.

this best fitting straight line is also known as regression line that minimizes the sum of the squared errors of prediction.

Characteristic of linear regression is the output variable should be continuous.

Linear Regression establishes a relationship between dependent variable (Y) and one or more independent variables (X) using a best fit straight line (also known as regression line).
 

 

 

 

 

 

Best fit - line or curve:

1. The maximum number of points covered.

2. Minimize the distance between other points (error -SSE)

 

 

 

 

 

 

 

The below-given equation is used to denote the linear regression model:

y=mx+c+e

where m is the slope of the line, c is an intercept, and e represents the error in the model

Linear regression where Y is the output variable and X is the input variable/variables.

 

 


 Find Slope & Intercept:

 

 

 

 Linear Regression Python code:



#Importing Needed packages

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from sklearn import linear_model

 

 

#Reading the data in

path='C:/TrainingDocs/MachineLearningwithPython/homeprices1.csv'

df = pd.read_csv(path)

df

 

# summarize the data

df.describe()

 

#plot graph for datapoints

%matplotlib inline

plt.xlabel('area(sqr ft)')

plt.ylabel('price(US$)')

plt.scatter(df.Area,df.Price,color='red',marker='+')

 

 

#Using sklearn package to model data

#fitting training data and then generating predictions on test data

reg=linear_model.LinearRegression()

reg.fit(df[['Area']],df.Price)

 

 

#Predict price for area (3300 sq feet)

reg.predict([[3300]])

 

#Plot graph for prediction

#Draw the line on the scatter plot

%matplotlib inline

plt.xlabel('Area',fontsize=20)

plt.ylabel('Price',fontsize=20)

plt.scatter(df.Area,df.Price,color='red',marker='+')

plt.plot(df.Area,reg.predict(df[['Area']]),color='blue')

 

 

print ('Coefficients: ', reg.coef_)

print ('Intercept: ',reg.intercept_)

 

#Check Value of Coefficients

reg.coef_

 

#Check Value of intercept

reg.intercept_

 

#Validate linear equation

#y=mx+b

#134.07534247*3300+176232.87671232875

134.07534247*3300+176232.87671232875

 

#Predict price based on given area

path1='C:/TrainingDocs/MachineLearningwithPython/areas.csv'

d= pd.read_csv(path1)

d.head(3)

 

p=reg.predict(d)

d['prices'] = p

path2='C:/TrainingDocs/MachineLearningwithPython/prediction.csv'

d.to_csv(path2,index=False)

 

 


Multiple linear regression:

 

Predict for 3000 sq ft, 3 bedrooms, 40-year-old

 

 Multiple linear regression Python Code:



#Importing Needed packages

import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

from sklearn import linear_model

 

 

 

#Reading the data in

path='C:/TrainingDocs/MachineLearningwithPython/homeprices1.csv'

df = pd.read_csv(path)

df

 

#Cleaning of data

import math

median_bedrooms=math.floor(df.Bedrooms.median())

median_bedrooms

 

#Assign some value to NaN

 

df.Bedrooms=df.Bedrooms.fillna(median_bedrooms)

df

 

 

#To Train model

reg=linear_model.LinearRegression()

reg.fit(df[['Area','Bedrooms','Age']],df.Price)

 

 

 

print ('Coefficients: ', reg.coef_)

print ('Intercept: ',reg.intercept_)

 

 

 

#Predict for 3000 sq ft, 3 bedrooms, 40 yeal old

reg.predict([[3000,3,40]])

 

 

#Validate multiple equation

#y=m1x1+m2x2+m3x3+y

#3000*137.25+3*-26025+40*-6825+383724.9999999998

3000*137.25+3*-26025+40*-6825+383724.9999999998

 

 

Monday, June 8, 2020

How to optimize Your Google My Business Listing


How to Completely Optimize Your Google My Business Listing



Google My Business (GMB) – the free tool from Google that helps business owners manage their online presence across the search engine and its growing portfolio of utilities – offers the greatest impact for brands seeking local exposure.

Google My Business complements your existing website by giving your business a public identity and presence with a listing on Google, the most popular search engine in the world.

The information you provide about your business can appear in Google Search, Google Maps, and on Google+.

1. Provide Complete Data for Your Listing :

Local search results favor the most relevant results for searches, and business offering the most detailed and accurate information will be easier to serve in search.
Don’t leave anything to be guessed or assumed; make sure your listing communicates with potential customers what your business does, where it is, and how they can acquire the good and/or services your business is offering.

2. Power of including Keywords :

You need to add relevant keyword in the business description.Also,You can do rearch of comtitores keywords using below link:

www.semrush.com
www.spyfu.com


3. Customer Reviews:

You need to request your customer to share feedback of your service by providing reviews.
Positive reviews are going to have a positive effect on potential customers when researching your business, but they also increase your business’s visibility in search results.


4. Local Citations:

You need to register your business in local business directories (Name,Address,Phone Nuumber ) Examples : Yellowpages,Yelp,Foursquare )


Have a Great Day!

Wednesday, May 27, 2020

Redmi Earbuds S : Powerful wireless earbuds that everybody can afford now



Redmi Earbuds S @ Rs 1,799


Redmi Earbuds S

  • 🎧🎧 【Google Voice Assistant】: double-click on any of the headset multi function keys to activate the voice assistant, you can navigate the route. You can concentrate on driving and the route has already been planned for you. Make a meal with friends, you can arrive at your destination in advance through a voice assistant

  • 🎧🎧 【Latest Bluetooth 5. 0 Technology and Stereo Calls】 Wireless headphones are equipped with Bluetooth 5. 0 chips, which offer high-quality stereo sound, loud bass and maintain low latency when playing or making videos. The built-in microphone and noise cancellation design, both the left and right earphones support answering and hanging calls, giving you a pleasant calling experience.

  • 🎧🎧 【One-Step Connection】 When you remove the wireless headset from the charging bag, the wireless headset will automatically turn on and connect to the phone. However, when you connect for the first time, you must manually select from the phone's Bluetooth list. When you reinsert the case, turn it off and load it automatically. You do not even need the skills to use earplugs.

  • 🎧🎧 【Charge wherever you want】 Bluetooth wireless headsets are equipped with a charging box, which allows you to charge them at any time or any place. It also has a small size, ensuring that it is easy and convenient to carry in your pocket. With only 1 hour of charge in the box, they can be used for about 4 hours, It can be extended to 12 hours with the cargo box.

  • 🎧🎧 【Control & Easy Use】 Thanks to the advanced technology of Touch Control, with just a touch on the wireless bluetooth headset you can play, pause, change the music, adjust the volume, take, reject the call, etc. And they automatically connect to your device after the first use, which simplifies your life as much as possible.


        Buy : https://store.mi.com/in/item/3202100010



Wednesday, May 20, 2020

AWS Machine Learning Scholarship Program

AWS Machine Learning Scholarship Program

Image result for udacity image


AWS and Udacity are collaborating to educate developers of all skill levels on Machine Learning concepts.

The foundations course is intended to help developers of all skill levels get started with machine learning. When you successfully complete the course, you’ll be awarded with a certificate of completion.

At the end of the AWS Machine Learning Foundations Course, learners will take an assessment from which top students will be selected for one of 325 follow-up scholarships to one of Udacity’s most popular Nanodegree programs: AWS Machine Learning Engineer.

Enrollment Opens : Tuesday, May 19                                  
Enrollment Closes: Wednesday, July 31, 11:59 PM PST

Registration Link:


Tuesday, June 25, 2019

SQL Queries for Interview

SQL Queries for Interview

Q1 SQL select total and split into success and failed

Table 1                Table 2                   
|leadid|Location|      |leadid|leadstatus|       
|---------------|      |-----------------|
|1     |Japan   |      |1     | Hired    |
|2     |China   |      |2     | Failed   |
|3     |Korea   |      |3     | Hired    |
|4     |Japan   |      |4     | Hired    |
|5     |Japan   |      |5     | Hired    |
 
|Location|Interview|Hired|Failed|
|-------------------------------|
|Japan   | 3       |3    |0     |
|Korea   | 1       |1    |0     |
|China   | 1       |0    |1     |
 
SELECT Location, COUNT(*) as Interview,
SUM(CASE WHEN leadstatus = 'Hired' THEN 1 ELSE 0 END) as Hired,
SUM(CASE WHEN leadstatus = 'Failed' THEN 1 ELSE 0 END) as Failed
FROM table1 
LEFT JOIN table2 ON table1.leadid = table2.leadid
            GROUP BY Location 
            ORDER BY Interview DESC
 
Select location,count(*) as Interview,
SUM(CASE WHEN (status='Hired')Then 1 Else 0 END) as Hired,
SUM(CASE WHEN(status='Failed') Then 1 Else 0 END) as Failed 
from loc inner join status on loc.leadid= status.leadid 
group by location;
 
Q 2 Second maximum salary 
 
Second maximum salary using sub query and IN clause 

mysql> SELECT max(salary) FROM Employee WHERE salary NOT IN 
(SELECT max(salary) FROM Employee);


mysql> SELECT max(salary) FROM Employee WHERE salary < 
(SELECT max(salary) FROM Employee);


Second highest salary using TOP keyword of Sybase or SQL Server database


SELECT TOP 1 salary FROM ( SELECT TOP 2 salary FROM employees ORDER BY salary DESC)
 AS emp ORDER BY salary ASC

Second maximum salary using LIMIT keyword of MYSQL database

SELECT salary  FROM (SELECT salary FROM Employee ORDER BY salary DESC LIMIT 2)
AS emp ORDER BY salary LIMIT 1;



 Q 3 Write an SQL query to clone a new table from another table.
 
 SELECT * INTO WorkerClone FROM Worker; (With data )
 SELECT * INTO WorkerClone FROM Worker WHERE 1 = 0; (Without data )
 CREATE TABLE WorkerClone LIKE Worker; (Without data )
 
 
 
 
 
    

Thursday, May 2, 2019

Hadoop HDFS Commands

Hadoop HDFS Commands

ls
Returns all the available files and subdirectories present under the root directory.
hadoop fs –ls /

cd  C:\hadoop-2.8.0\data\namenode
hadoop fs -mkdir  test1
hadoop fs -ls \
hadoop fs -mkdir -p /test1/Hadoop
hadoop fs -mkdir  /test1/Hadoop/tweeter_data

copyFromLocal
Copy a file from local filesytem to HDFS location.
hadoop fs –copyFromLocal Sample1.txt /test1/Hadoop/tweeter_data

put –
This hadoop command uploads a single file or multiple source files from local file system to hadoop distributed file system (HDFS).
hadoop fs –put Sample2.txt /test1/Hadoop/tweeter_data

moveFromLocal
This hadoop command functions similar to the put command but the source file will be deleted after copying.
hadoop fs –put Sample3.txt /test1/Hadoop/tweeter_data

du
Displays the disk usage for all the files available under a given directory.
hadoop fs –du /test1/Hadoop/

df
 Displas disk usage of current hadoop distributed file system.
hadoop fs –df

Expunge
This HDFS command empties the trash by deleting all the files and directories.
hadoop fs –expunge

Cat
This is similar to the cat command in Unix and displays the contents of a file.
hadoop fs –cat /test1/Hadoop/tweeter_data/Sample3.txt

cp
Copy files from one HDFS location to another HDFS location.
hadoop fs –cp /test1/Hadoop/tweeter_data/  /test2/

mv
Move files from one HDFS location to another HDFS location.
hadoop fs –mv /test2/  /test12/

rm
Removes the file or directory from the mentioned HDFS location.
hadoop fs –rm -r /test12/

tail
This hadoop command will show the last kilobyte of the file to stdout.
hadoop fs -tail /test1/Hadoop/tweeter_data/Sample3.txt

touchz
This command can be used to create a file of zero bytes size in HDFS filesystem.
hadoop fs -touchz /test1/URI.txt

tail
This command is used to show the last 1KB of the file.
hadoop fs -tail /test1/Hadoop/tweeter_data/Sample3.txt

count
This command is used to count the number of directories, files and bytes
hadoop fs -count /test1/Hadoop/