Popular posts from this blog
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...
Logistic Regression in ML and AI with Examples and Projects
Logistic Regression in ML and AI with Examples and Projects The Complete Code import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns from sklearn.model_selection import train_test_split train = pd.read_csv("titanic_train.csv") def impute_age(cols): Age = cols[0] Pclass = cols[1] if pd.isnull(Age): if Pclass == 1: return 37 elif Pclass == 2: return 29 else: return 24 else: return Age train['Age'] = train[['Age','Pclass']].apply(impute_age,axis=1) train.drop('Cabin',axis=1,inplace=True) train.dropna(inplace=True) Sex = pd.get_dummies(train['Sex'],drop_first=True) Embark = pd.get_dummies(train['Embarked'],drop_first=True) train = pd.concat([train,Sex,Em...
Comments
Post a Comment