Linear Regression Big Mart Sales Example Code has a issue?

Reference link -

Data pre-processing steps for regression model

imputing missing values

train[‘Item_Visibility’] = train[‘Item_Visibility’].replace(0,np.mean(train[‘Item_Visibility’]))
train[‘Outlet_Establishment_Year’] = 2013 - train[‘Outlet_Establishment_Year’]

creating dummy variables to convert categorical into numeric values

mylist = list(train1.select_dtypes(include=[‘object’]).columns)
dummies = pd.get_dummies(train[mylist], prefix= mylist)
train.drop(mylist, axis=1, inplace = True)
X = pd.concat([train,dummies], axis =1 )

In the line : mylist = list(train1.select_dtypes(include=[‘object’]).columns)
Variable train1 is not defined, need help to understand if it is same as train variable or no

I don’t have access to course but maybe you should simply use train instead of train1. Maybe it is only typo.

I would simply try with train and see if it gives expected results.

© Copyright 2013-2019 Analytics Vidhya