Created
June 6, 2017 10:58
-
-
Save jay-trivedi/fb412e99df75366f1f631e1b0964bbc2 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
depth = 10 | |
seed_range = range(0, 3000,288) | |
acc_vs_seed_result = {"seed": [],\ | |
"train_acc": [], | |
"valid_acc": [], | |
"top_feature": [], | |
"second_feature": [], | |
"third_feature": []} | |
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) | |
predict_valid = model.predict(valid[x]) | |
predict_train = model.predict(train[x]) | |
acc_vs_seed_result["seed"].append(seed) | |
acc_vs_seed_result["valid_acc"].append((predict_valid["predict"] == valid["Survived"]).mean()[0]) | |
acc_vs_seed_result["train_acc"].append((predict_train["predict"] == train["Survived"]).mean()[0]) | |
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