Machine Learning Project : model 1 - Bytecode.technilesh.com Python
we are going to build an model for Machine learning and if want Video explanination
check this link : CODEWITHNILESH :https://www.youtube.com/channel/UCJHkjFmCK_9jvbkxTerKKTA
- We are importing all libraries which are require that numpy , pandas , matlibplot & sklearn .
- initially we take the data preprocessing and i already provide the overview and idea for data preprocessing .after that we create linear regression using the sklearn liberaries class Linear Regression . using object ' Regressor ' we call the class .after that we call the method of Linear Regressor class Fit Method which fit the train dataset of X ,Y to model .using Linear Regression we train the Model and now we have to provide test Data set to get prediction ,so again we used Predicts method of Linear Regression class and pass X_test data set and we get the Y_Prediction.
# template is heavnly need and also feature scaling is not need for mant time but if required we used
import numpy as np
import matplotlib.pyplot as plot
import pandas as pd
#import the data sets
dataset = pd.read_csv('data.csv')
X = dataset.iloc[: , :-1].values
Y = dataset.iloc[: ,:1].values
#split the set to traning and test sets
from sklearn.model_selection import train_test_split
X_train,X_test,Y_train,Y_test = train_test_split(X,Y,test_size=0.2) # test size should be displayed
print(Y_test)
#model trainng so we used the class of sklearn i.e. Linear Regression
from sklearn.linear_model import LinearRegression
regressor = LinearRegression() # we call the class using the object regressor
regressor.fit(X_train,Y_train)
# we used fit method to fit the data in theregressor i.e linear regression
# finally we train model and made an model now pass the test data to find prediction
Y_Pred = regressor.predict(X_test) # we used predict method which take parameter of test class and using linear regresson find the resiu
print(Y_Pred)
https://youtu.be/fqVHp6jrsJc
Wow
ReplyDelete