This document describes how to create an Ordinary Least Squares regression model using statsmodels: prepend a column of ones to the training and test data for the intercept term, fit an OLS model on the training data and targets, and make predictions on the test data using the fitted OLS model.
10 Points Create an Ordinary Least Squares regression model using sta.pdf
1. 10 Points Create an Ordinary Least Squares regression model using statsmodels: - Prepend a
column of ones to xtrain_final and X_test_final for the intercept term
(statsmodels.api.add_constant(df)). Assign output to X _train_ols and x test_ols, respectively. -
Fit an OLS model using X_train_ols and y_train_final. Assign the model object to ols_model. -
Using ols_model, create predictions for X_test_ols and assign to ols_test_preds ## GRADED
import statsmodels.api as sm ### YOUR SOLUTION HERE X_train_ols = None X _test_ols
= None ols_model = None ols_test_preds = None ### YOUR CODE HERE ###### ###
AUTOGRADER TEST - DO NOT REMOVE ###