steps in building a machine learning model code example

Example: how to create your own machine learning model

from sklearn.model_selection import GridSearchCVn_estimators = [100, 300, 500, 800, 1200]max_depth = [5, 8, 15, 25, 30]min_samples_split = [2, 5, 10, 15, 100]min_samples_leaf = [1, 2, 5, 10]param_grid = dict(n_estimators = n_estimators, max_depth = max_depth,                min_samples_split = min_samples_split,              min_samples_leaf = min_samples_leaf)rf = RandomForestClassifier()grid_search = GridSearchCV(estimator=rf, param_grid=param_grid)best_model = grid_search.fit(X_train, y_train)print(round(best_model.score(X_test, y_test),2))print(best_model.best_params_)

Tags:

Misc Example