Scikit-Learn Cheat Sheet
Scikit-Learn Cheat Sheet
Scikit-Learn Cheat Sheet
scaler = StandardScaler().fit(X_train)
standardized_X = scaler.transform(X_train)
Accuracy Score
>>> knn.score(X_test, y_test)
#Estimator score method
Confusion Matrix
>>> scaler = Normalizer().fit(X_train)
Scikit-learn >>>
>>>
normalized_X = scaler.transform(X_train)
normalized_X_test = scaler.transform(X_test)
>>> from sklearn.metrics import confusion_matrix
Scikit-learn is an open source Python library that
implements a range of Binarization Regression Metrics
machine learning,
preprocessing, cross-validation and visualization
X_test = scaler.transform(X_test)
Clustering Metrics
>>> knn.fit(X_train, y_train)
Homogeneity
>>> lr = LinearRegression(normalize=True)
>>> X_train, X_test, y_train, y_test = train_test_split(X,
y,
random_state=0)
Support Vector Machines (SVM)
>>> from sklearn.svm import SVC
Grid Search
> Model Fitting
Naive Bayes
>>> from sklearn.naive_bayes import GaussianNB
>>> print(grid.best_score_)
Unsupervised Learning
Unsupervised Learning Estimators >>> print(grid.best_estimator_.n_neighbors)
>>> k_means.fit(X_train) #Fit the model to the data
>>> print(rsearch.best_score_)
>>> y_pred = svc.predict(np.random.random((2,5)))
#Predict labels