Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The fully prepared training and testing data is reloaded below and assigned to the following variables: X_train_final X_test_final y_train_final y_test_final For the last question, you

The fully prepared training and testing data is reloaded below and assigned to the following variables:

  • X_train_final
  • X_test_final
  • y_train_final
  • y_test_final

For the last question, you will HELP WITH another OLS model using 1 Principal Component.

  • Instantiate an instance of PCA with the following configuration and assign topca_one:

PCA(n_components=1, random_state=24)

  • Usingpca_one, fit and transformX_train_finaland assign the output toX_train_pca.
  • Usingpca_one, transformX_test_finaland assign output toX_test_pca(Be careful not to refit on testing data!)
  • HELP WITH anOLSregression model using statsmodels:
  • Prepend a column of ones toX_train_pcaandX_test_pcafor the intercept term (statsmodels.api.add_constant(df))
  • Fit an OLS model usingX_train_pcaandy_train_final. Assign the model topca_model
  • Usingpca_model, create predictions forX_test_pcaand assign topca_test_preds

In[]:

X_train_final = read_training_data(final=True) y_train_final = read_y_train(final=True) X_test_final = read_testing_data(final=True) y_test_final = read_y_test(final=True) 

In[]:

### GRADED import statsmodels.api as sm ### YOUR SOLUTION HERE pca_one = None X_train_pca = None X_test_pca = None pca_model = None pca_preds = None 

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

Students also viewed these Programming questions

Question

=+ b. If the bank eliminates excess reserves by making new loans,

Answered: 1 week ago