Professional Documents
Culture Documents
Machine Learning Algorithm With Python Implementation
Machine Learning Algorithm With Python Implementation
Machine Learning Algorithm With Python Implementation
Implementation
Faculty Name: Mrs. Reshma Gulwani
Assistant Professor
Department of Information Technology
DY Patil Deemed to be University
Ramrao Adik Institute Of Techchnology
Contents
Regression
Types of Regression
2
Regression
Helps seller
To predict the sale of products in the future based on past
buying behavior.
Helps organizations
To figure out how much they would pay to a new joinee based
on the years of experience.
y = ax + b
y is response variable
x is predictor variable
Power of both the variables is 1.
a and b are constants which are called the coefficients.
Mathematically a linear relationship represents a straight line
when plotted as a graph
Machine Learning algorithm with
6
python implementation
What is linear
It’s easy to predict (or calculate) the Price based on Value and
vice versa using the equation.
y=2+1.5x
Problem Statement:
How to pick the best number for him? It’s time to use
Machine Learning to predict the best salary for our
candidate.
Machine Learning algorithm with
14
python implementation
Step 1: Import Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
dataset = pd.read_csv("Salary_Data.csv")
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, -1].values
Training dataset for training the model and then check the
performance of the model on the test dataset.
Use the train_test_split method from library model_selection
y_pred = regressor.predict(X_test)
plt.xlabel('Years of Experience')
plt.ylabel('Salary')
plt.show()
Machine Learning algorithm with
22
python implementation
Output
Make new predictions for data points that do not exist in the
dataset.
Like for a person with 12 years experience.
new_salary_pred = regressor.predict([[12]])
Easier to implement.
y = a + b1x1+b2x2+…bnxn
y is the response variable.
a, b1, b2...bn are the coefficients.
x1, x2, ...xn are the predictor variables.
• Website link:
www.ncbi.nlm.nih.gov/pmc/articles/PMC7128942/