-
-
Save amankharwal/ec897f1811700a4bf7fb37d4494bb080 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
dt_clf = DecisionTreeClassifier() # Create Decision Tree classifer object | |
dt_clf = dt_clf.fit(X_train,y_train) # Fit/Train Decision Tree Classifer on training set | |
# Save model to file in the current working directory so that it can be imported and used. | |
# I use the pickle library to save the parameters of the trained model | |
pkl_file = "decision_tree_model.pkl" | |
with open(pkl_file, 'wb') as file: | |
pickle.dump(dt_clf, file) | |
# Load previously trained model from pickle file | |
with open(pkl_file, 'rb') as file: | |
dt_clf = pickle.load(file) | |
dt_clf # parameters of the Decision Tree model are shown below and can be further optimized to improve model performance | |
y_pred = dt_clf.predict(X_test) #Predict the response for test dataset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment