Created
June 6, 2017 10:59
-
-
Save jay-trivedi/f2f32d4d0338d4d160f864b991dd84f2 to your computer and use it in GitHub Desktop.
This file contains 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
acc_vs_seed_result = {"seed": [],\ | |
"train_acc": [], | |
"valid_acc": [], | |
"top_feature": [], | |
"second_feature": [], | |
"third_feature": []} | |
depth = 10 | |
seed_range = range(0, 3000,288) | |
for seed in seed_range: | |
model = H2ORandomForestEstimator(model_id="model", \ | |
sample_rate=0.7, \ | |
ntrees=1, \ | |
max_depth=depth, \ | |
seed=seed) | |
model.train(x=x, y=y, training_frame=train, validation_frame=valid) | |
predict_valid = model.predict(valid[x]) | |
predict_train = model.predict(train[x]) | |
t = predict_train["predict"].cbind(train["SalePrice"]).as_data_frame() | |
v = predict_valid["predict"].cbind(valid["SalePrice"]).as_data_frame() | |
acc_vs_seed_result["seed"].append(seed) | |
acc_vs_seed_result["valid_acc"].append(mean_squared_error(y_true = v.SalePrice, y_pred = v.predict)) | |
acc_vs_seed_result["train_acc"].append(mean_squared_error(y_true = t.SalePrice, y_pred = t.predict)) | |
acc_vs_seed_result["top_feature"].append(model.varimp()[0][0]) | |
acc_vs_seed_result["second_feature"].append(model.varimp()[1][0]) | |
acc_vs_seed_result["third_feature"].append(model.varimp()[2][0]) | |
acc_vs_seed_result_df = pd.DataFrame(acc_vs_seed_result) | |
cols = ["seed", "train_acc", "valid_acc", "top_feature", "second_feature", "third_feature"] | |
acc_vs_seed_result_df = acc_vs_seed_result_df[cols] | |
acc_vs_seed_result_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment