Skip to content

Instantly share code, notes, and snippets.

@ravishchawla
Created February 27, 2019 17:43
Show Gist options
  • Save ravishchawla/62852ee66d97ca1a65797b1cc65aa2eb to your computer and use it in GitHub Desktop.
Save ravishchawla/62852ee66d97ca1a65797b1cc65aa2eb to your computer and use it in GitHub Desktop.
AirBnB post: Train test split
l_X, l_y = listings_cleaned.drop('price', axis=1), listings_cleaned['price'];
l_X_train, l_X_test, l_y_train, l_y_test = train_test_split(l_X, l_y, test_size=0.33, random_state=1024);
rf_classifier = RandomForestRegressor(n_estimators=400, criterion='mse', random_state=1024);
rf_classifier.fit(l_X_train, l_y_train)
l_y_pred = rf_classifier.predict(l_X_test);
l_y_pred_tr = rf_classifier.predict(l_X_train);
print(math.sqrt(mean_squared_error(l_y_test, l_y_pred)))
print(math.sqrt(mean_squared_error(l_y_test, l_y_pred)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment