-
-
Save BinarySpoon/08844d292344a78e7cdb75c2ab7c88da 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
# The four step process | |
#1 import the model you wanna use --> | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.svm import SVC | |
from sklearn.ensemble import RandomForestClassifier | |
from sklearn.neighbors import KNeighborsClassifier | |
#2 Make an instance of the model --> | |
lgr = make_pipeline(StandardScaler(), LogisticRegression(random_state=0)) | |
svc = make_pipeline(StandardScaler(), SVC(random_state=0,gamma='auto')) | |
rf = make_pipeline(StandardScaler(), RandomForestClassifier(max_depth=2,random_state=0)) | |
knn = make_pipeline(StandardScaler(), KNeighborsClassifier(n_neighbors=5)) | |
#3 Training the model on the data (fitting) --> | |
lgr.fit(x_train, y_train) | |
svc.fit(x_train,y_train) | |
rf.fit(x_train,y_train) | |
knn.fit(x_train,y_train) | |
#4 Predict for new data (test) --> | |
lr_predict = lgr.predict(x_test) | |
svc_predict = svc.predict(x_test) | |
rf_predict = rf.predict(x_test) | |
knn_predict = knn.predict(x_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment