Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil, Elizabeth O'Neil

2nd Edition

1558605800, 978-1558605800

More Books

Students also viewed these Databases questions