Created
February 27, 2019 17:50
-
-
Save ravishchawla/d71b1955ffeac76a1dafb721d9a3390e to your computer and use it in GitHub Desktop.
AirBnB post: PCA results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pca = PCA(n_components=400, random_state=1024); | |
| pca.fit(l_X) | |
| listings_pca = pca.transform(l_X); | |
| l_X_p_train, l_X_p_test, l_y_p_train, l_y_p_test = train_test_split(listings_pca, l_y, test_size=0.33, random_state=1024) | |
| rf_classifier_2 = RandomForestRegressor(n_estimators=100, criterion='mse', random_state=1024); | |
| rf_classifier_2.fit(l_X_p_train, l_y_p_train) | |
| l_y_p_pred = rf_classifier_2.predict(l_X_p_test); | |
| l_y_p_pred_tr = rf_classifier_2.predict(l_X_p_train); | |
| print(math.sqrt(mean_squared_error(l_y_p_test, l_y_p_pred))) | |
| print(math.sqrt(mean_squared_error(l_y_p_train, l_y_p_pred_tr))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment