Question: Dataframe/Python URL=https://bit.ly/2WKPUXI *You may need to use encoding='latin1' as additional parameter for read_csv() Q1: Convert all columns that store categorical values to numerical values. Hint,

Dataframe/Python URL="https://bit.ly/2WKPUXI"

*You may need to use encoding='latin1' as additional parameter for read_csv()

Q1: Convert all columns that store categorical values to numerical values. Hint, store the unique values of a particular column in a list and replace the unique value with its index. Store your results in a new dataframe called DF2.

Q2:

  • Define a new dataframe called DF3 that has a copy of DF2. Convert ordinal values to numarical values.
  • Define a new dataframe called DF4 that has a copy of DF2. Drop the columns that store ordinal values.
  • Define a new dataframe called DF5 that has a copy of df. Drop all columns that contain non-numeric values.
  • How many columns in df , DF2, DF3, DF4, and DF5?

Q3: 1- Split DF3 into 70% training and 30% testing data.

2- Split DF4 into 70% training and 30% testing data.

3- Split DF5 into 70% training and 30% testing data.

############# Write your code here ##############

############ DO not modify this part #############

######### Read, understand, and run it ###########

from sklearn.linear_model import LinearRegression

from sklearn.metrics import mean_absolute_error

model = LinearRegression()

model.fit(X_train, y_train)

predict = model.predict(X_test)

r_sq = model.score(X_test, y_test)

print('coefficient of determination:', r_sq)

print("errors in predictions: ", mean_absolute_error(y_test, predict))

print("coefficient: ", model.coef_)

##################################################

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!