Scikit-Learn Cheat Sheet - Python Machine Learning (Article) - DataCamp
Scikit-Learn Cheat Sheet - Python Machine Learning (Article) - DataCamp
Of cial Blog
PYTHON +1
Most of you who are learning data science with Python will have
definitely heard already about scikit-learn , the open source Python
library that implements a wide variety of machine learning,
preprocessing, cross-validation and visualization algorithms with the
help of a unified interface.
If you're still quite new to the field, you should be aware that machine
learning, and thus also this Python library, belong to the must-knows for
every aspiring data scientist.
That's why DataCamp has created a scikit-learn cheat sheet for those of
you who have already started learning about the Python package, but
that still want a handy reference sheet. Or, if you still have no idea about
how scikit-learn works, this machine learning cheat sheet might come
in handy to get a quick first idea of the basics that you need to know to
get started.
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 1/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
Either way, we're sure that you're going to find it useful when you're
tackling machine learning problems!
This scikit-learn cheat sheet will introduce you to the basic steps that
you need to go through to implement machine learning algorithms
successfully: you'll see how to load in your data, how to preprocess it,
how to create your own model to which you can fit your data and predict
target labels, how to validate your model and how to tune it further to
improve its performance.
In short, this cheat sheet will kickstart your data science projects: with
the help of code examples, you'll have created, validated and tuned your
machine learning models in no time.
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 2/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
A Basic Example
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 3/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
>>> y = np.array(['M','M','F','F','M','F','M','M','F','F','F'])
>>> X[X < 0.7] = 0
Standardization
Normalization
Binarization
Linear Regression
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 5/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
Naive Bayes
KNN
K Means
Model Fitting
Supervised learning
>>> lr.fit(X, y)
>>> knn.fit(X_train, y_train)
>>> svc.fit(X_train, y_train)
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 6/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
Unsupervised Learning
>>> k_means.fit(X_train)
>>> pca_model = pca.fit_transform(X_train)
Prediction
Supervised Estimators
Unsupervised Estimators
Accuracy Score
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 7/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
Classification Report
Confusion Matrix
Regression Metrics
R2 Score
Clustering Metrics
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 8/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
Homogeneity
V-measure
Cross-Validation
Grid Search
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 9/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
>>> print(grid.best_score_)
>>> print(grid.best_estimator_.n_neighbors)
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 10/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
>>> print(rsearch.best_score_)
Going Further
PS. Don't miss our Bokeh cheat sheet, the Pandas cheat sheet or
the Python cheat sheet for data science.
Subscribe to RSS
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 11/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 12/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 13/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 14/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 15/16
14/11/2017 Scikit-Learn Cheat Sheet: Python Machine Learning (article) - DataCamp
https://www.datacamp.com/community/blog/scikit-learn-cheat-sheet#gs.fZ2A1Jk 16/16