Created
May 26, 2022 02:18
-
-
Save esenthil2018/b18be9c447178ace32247080460a7844 to your computer and use it in GitHub Desktop.
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
| #RandomeForestClassifer | |
| from sklearn.ensemble import RandomForestClassifier | |
| model = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1) | |
| model.fit(X, y) | |
| predictions = model.predict(X_test) | |
| model.score(X, y) | |
| acc_random_forest = round(model.score(X, y) * 100, 2) | |
| acc_random_forest | |
| # Gaussian Naive Bayes | |
| from sklearn.naive_bayes import GaussianNB | |
| gaussian = GaussianNB() | |
| gaussian.fit(X, y) | |
| Y_pred = gaussian.predict(X_test) | |
| acc_gaussian = round(gaussian.score(X, y) * 100, 2) | |
| acc_gaussian | |
| # Support Vector Machines | |
| from sklearn.svm import SVC, LinearSVC | |
| svc = SVC() | |
| svc.fit(X, y) | |
| Y_pred = svc.predict(X_test) | |
| acc_svc = round(svc.score(X, y) * 100, 2) | |
| acc_svc | |
| # Decision Tree | |
| from sklearn.tree import DecisionTreeClassifier | |
| decision_tree = DecisionTreeClassifier() | |
| decision_tree.fit(X, y) | |
| Y_pred = decision_tree.predict(X_test) | |
| acc_decision_tree = round(decision_tree.score(X, y) * 100, 2) | |
| acc_decision_tree | |
| # Stochastic Gradient Descent | |
| from sklearn.linear_model import SGDClassifier | |
| sgd = SGDClassifier() | |
| sgd.fit(X, y) | |
| Y_pred = sgd.predict(X_test) | |
| acc_sgd = round(sgd.score(X, y) * 100, 2) | |
| acc_sgd | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment