Step 1: Installing libraries
*pip install numpy
*pip install pandas
*pip install sklearn
Step 2: Importing the libraries
import pandas as pd
import numpy as np
from sklearn import linear_model
Step 3: Reading the CSV
df=pd.read_csv('car_data.csv')
df
Step 4: Preprocessing 1:
inputs=df.drop(['Car_Name','Owner','Seller_Type'],axis='columns')
target=df.Selling_Price
inputs
Step 5: Preprocessing 2
from sklearn.preprocessing import LabelEncoder
Numerics=LabelEncoder()
inputs['Fuel_Type_n']=Numerics.fit_transform(inputs['Fuel_Type'])
inputs['Transmission_n']=Numerics.fit_transform(inputs['Transmission'])
inputs
Step 6: Dropping the string columns
inputs_n=inputs.drop(['Fuel_Type','Transmission','Selling_Price'],axis='columns')
inputs_n
Step 7: Implemention of Linear regression & Prediction
model=linear_model.LinearRegression()
model.fit(inputs_n,target)
pred=model.predict([[2013,9.54,430000,1,1]])
Fullcode: Github
Thanks for Sharing the Python Courses Training for Freshers and Experience Candidates
ReplyDeletePython course in Bangalore
Python Training in Bangalore
Best Python Training Institutes in Bangalore
python training institute in Bangalore
Machine Learning Course in Noida
ReplyDeleteMachine Learning Training in Noida