Linear Regression in ML and AI with Examples and Project
Introduction to linear Regression Code python:- Import numpy as np Import pandas as pd Import matplotlib.pyplot as plt Import seaborn as sns Df = pd.read_csv(‘USA_Housing.csv’) Df.head() Df.info()-- total information of dataset Df.describe()-calculated estimation Df.columns-names of columns Sns.pairplot(df) Sns.distplot(df[‘Price’]) Sns.heatmap(df.corr(),annot=True)shows correlation Training a data using Linear regression First of all designing the features We need all the columns name Df.columns Select the names of the columns leaving price and address X = df[[names of columns]] y= df[‘Price’] the labels From sklearn.cross_validation import train_test_split X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.4,random_state=101) Test_size is that amount of total data you want to allocate for testset 40% given here Random_state is a number given to randomly split the data Creating and training the model From sklearn.linear_model import LinearRegression Initi...
Comments
Post a Comment