Created
March 15, 2021 09:51
-
-
Save PranjalDureja0002/321126c1b9a872d0ebd4f419e7724f3e to your computer and use it in GitHub Desktop.
model
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
parameters = {'max_depth':[1, 5, 10, 20, 50], | |
'min_samples_split':[5, 10, 100, 500]} | |
dt = DecisionTreeClassifier() | |
dt_grid = GridSearchCV(dt, param_grid=parameters, n_jobs=-1, verbose=1,scoring='f1_macro',cv=3,return_train_score=True) | |
dt_grid.fit(X_train,y_train) | |
best_depth=dt_grid.best_params_['max_depth'] | |
best_samples=dt_grid.best_params_['min_samples_split'] | |
dt_1 = DecisionTreeClassifier(max_depth=best_depth,min_samples_split=best_samples) | |
dt_1.fit(X_train, y_train) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment