Scikit-learn(Sklearn) in Python
Scikit-learn(Sklearn) in Python
Scikit-learn is probably the most useful library for machine learning in Python.
The sklearn library contains a lot of efficient tools for machine learning and
dimensionality reduction.
Please note that sklearn is used to build machine learning models. It should not
be used for reading the data, manipulating and summarizing it. There are better
Components of scikit-learn:
Scikit-learn comes loaded with a lot of features. Here are a few of them to help
algorithm you might have heard about and there is a very high chance that it is
methods – all of them are part of scikit-learn toolbox. The spread of machine
learning algorithms is one of the big reasons for the high usage of scikit -learn. I
started using scikit to solve supervised learning problems and would recommend
Various toy datasets: This came in handy while learning scikit-learn. I had
learned SAS using various academic datasets (e.g. IRIS dataset, Boston House
prices dataset). Having them handy while learning a new library helped a lot.
Feature extraction: Scikit-learn for extracting features from images and text
One of the main reasons behind using open source tools is the huge community
it has. Same is true for sklearn as well. There are about 35 contributors to scikit -
learn till date, the most notable being Andreas Mueller (P.S. Andy’s machine
There are various Organizations of the likes of Evernote, Inria and AWeber which
are being displayed on scikit learn home page as users. But I truly believe that
There was also a Kaggle knowledge contest, which finished recently but might
still be one of the best places to start playing around with the library.
Machine Learning cheat sheet – see Original image for better resolution
Quick Example:
Now that you understand the ecosystem at a high level, let me illustrate the use
of sklearn with an example. The idea is to just illustrate the simplicity of usage of
sklearn. We will have a look at various algorithms and best ways to use them in
[stextbox id = “grey”]
import numpy as np
import matplotlib as plt
[/stextbox]
[stextbox id = “grey”]
dataset = datasets.load_iris()
[/stextbox]
I am skipping these steps for now. You can read this article, if you want to learn
exploratory analysis.
predictions
[stextbox id = “grey”]
model.fit(dataset.data, dataset.target)
expected = dataset.target
predicted = model.predict(dataset.data)
[/stextbox]
Step 4: Print confusion matrix
[stextbox id = “grey”]
print(metrics.classification_report(expected, predicted))
print(metrics.confusion_matrix(expected, predicted))