Welcome to the Simplilearn Community

Want to join the rest of our members? Sign up right away!

Sign Up

Machine Learning( Nov 23rd - Dec 11th,2020)| Abhishek

Adwait Karkare

Customer
Customer
Unable to register for live classes before Mid-January. It is showing that are full. Yesterday there was a class option Nov21-Jan09 which was full but it is now the option is replaced by Dec14-Jan15 which is also full.
 

bhavana_16

Well-Known Member
Staff member
Unable to register for live classes before Mid-January. It is showing that are full. Yesterday there was a class option Nov21-Jan09 which was full but it is now the option is replaced by Dec14-Jan15 which is also full.
Hi Learner,

Thank you for reaching out to us

I would request you to raise a ticket for the same so that we can assist you accordingly
 
Hi All, Below is the Code I used to generate the regression task from last week and attacehd is the resulted Excel sheet:


import pandas as pd
import numpy as np

from math import sqrt
import itertools

import statsmodels.api as sm
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, r2_score

wine = pd.read_csv('wine.csv')

wine.head()

wine.columns

wine.corr()

y=wine[['Price']]
XHeader= ['WinterRain', 'AGST', 'HarvestRain','Age', 'FrancePop']

lmAnalysis = pd.DataFrame(columns=['Variable Names', 'R^2', 'R^2 Adjusted', 'Train RMSE', 'Test RMSE'])
lmAnalysis

XHeaderSubSetes = []
for i in range(0, len(XHeader)+1):
for x in itertools.combinations(XHeader, i):
XHeaderSubSetes.append(list(x))

XHeaderSubSetes.remove([])
XHeaderSubSetes

for i in range(len(XHeaderSubSetes)):
X=wine[XHeaderSubSetes]
XTrain, XTest, yTrain, yTest = train_test_split(X,y,train_size=0.8,random_state=100)
xTrain = sm.add_constant(XTrain)
xTest = sm.add_constant(XTest)
lm = sm.OLS(yTrain, xTrain).fit()
lmAnalysis = lmAnalysis.append(pd.Series([
",".join(([str(element) for element in X.columns.to_list()])),
lm.rsquared,
lm.rsquared_adj,
sqrt(mean_squared_error(yTrain,lm.predict(xTrain))),
sqrt(mean_squared_error(yTest,lm.predict(xTest)))],
index=lmAnalysis.columns)
,ignore_index=True)

lmAnalysis.head()

lmAnalysis.to_excel('wine lm possibilities analysis.xlsx')
 

Attachments

  • wine lm possibilities analysis.zip
    8.7 KB · Views: 2
Hi All, Below is the Code I used to generate the regression task from today and attacehd is the resulted Excel sheet:

import pandas as pd
import numpy as np

from math import sqrt
import itertools

import matplotlib.pyplot as plt
%matplotlib inline

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix,accuracy_score,classification_report

df = pd.read_csv('kyphosis.csv')

df.head()

df.columns

y=df[['Kyphosis']]
XHeader= ['Age', 'Number', 'Start']

logRegAnalysis = pd.DataFrame(columns=['Parameter/ Variable', 'Precision', 'Train - Recall','Train - F1 Score','Train - Accuracy','Test - Precision','Test - Recall','Test - F1 Score','Test - Accuracy'])
logRegAnalysis

XHeaderSubSetes = []
for i in range(0, len(XHeader)+1):
for x in itertools.combinations(XHeader, i):
XHeaderSubSetes.append(list(x))

XHeaderSubSetes.remove([])
XHeaderSubSetes

for i in range(len(XHeaderSubSetes)):
X=df[XHeaderSubSetes]
XTrain, XTest, yTrain, yTest = train_test_split(X,y,train_size=0.7,random_state=110)
LogReg = LogisticRegression()
LogReg.fit(XTrain, yTrain)
yPred = LogReg.predict(XTest)
clfRep = classification_report(yTest,yPred,output_dict=True)
yPredTrain = LogReg.predict(XTrain)
clfRepTrain = classification_report(yTrain,yPredTrain,output_dict=True)
logRegAnalysis = logRegAnalysis.append(pd.Series([
",".join(([str(element) for element in X.columns.to_list()])),
clfRep['present']['precision'],
clfRep['present']['recall'],
clfRep['present']['f1-score'],
accuracy_score(yTest,yPred),
clfRepTrain['present']['precision'],
clfRepTrain['present']['recall'],
clfRepTrain['present']['f1-score'],
accuracy_score(yTrain,yPredTrain)],
index=logRegAnalysis.columns)
,ignore_index=True)

logRegAnalysis

logRegAnalysis.to_excel('logReg possibilities analysis Teatcher.xlsx')
 

Attachments

  • logReg possibilities analysis Teatcher values.zip
    5.3 KB · Views: 3
Top