Scikit and Matplotlib

Scikit-Learn is a basic standard to work with machine learning in python. It provides a python libraries for solid implementation of machine-learning algorithms. Scikit-learn provides a wide selection of supervised and unsupervised learning algorithms. Best of all, it’s by far the easiest and cleanest ML library.

Scikit Learn is built on top of several common data and math Python libraries. Such a design makes it super easy to integrate between them all. You can pass numpy arrays and pandas data frames directly to the ML algoirthms of Scikit! It uses the following libraries:

  • NumPy: For any work with matrices, especially math operations
  • SciPy: Scientific and technical computing
  • Matplotlib: Data visualisation
  • IPython: Interactive console for Python
  • Sympy: Symbolic mathematics
  • Pandas: Data handling, manipulation, and analysis

Scikit’s robust set of algorithm offerings includes:

  • Regression: Fitting linear and non-linear models
  • Clustering: Unsupervised classification
  • Decision Trees: Tree induction and pruning for both classification and regression tasks
  • Neural Networks: End-to-end training for both classification and regression. Layers can be easily defined in a tuple
  • SVMs: for learning decision boundaries
  • Naive Bayes: Direct probabilistic modelling

Even beyond that, it has some very convenient and advanced functions not commonly offered by other libraries:

  • Ensemble Methods: Boosting, Bagging, Random Forest, Model voting and averaging
  • Feature Manipulation: Dimensionality reduction, feature selection, feature analysis
  • Outlier Detection: For detecting outliers and rejecting noise
  • Model selection and validation: Cross-validation, Hyperparamter tuning, and metrics

Documentation

I recommend starting out with the quick-start tutorial and flicking through the user guide and example gallery for algorithms that interest you.

Ultimately, scikit-learn is a library and the API reference will be the best documentation for getting things done.

Papers

If you interested in more information about how the project started and it’s vision, there are some papers you may want to check-out.

Books

If you are looking for a good book, I recommend “Building Machine Learning Systems with Python”. It’s well written and the examples are interesting.

There is an old sayings, “One picture can tell thousand words“. Its true in case of matplotlib library in python. This python library can visualize our work in 2-dimensional spaces.

Matplotlib is a plotting library for the Python programming language and its numerical mathematics extension NumPy. One of the greatest benefits of visualization is that it allows us visual access to huge amounts of data in easily digestible visuals. Matplotlib consists of several plots like line, bar, scatter, histogram etc.

Importing matplotlib :

from matplotlib import pyplot as plt
or
import matplotlib.pyplot as plt 

Basic plots in Matplotlib :

Matplotlib comes with a wide variety of plots. Plots helps to understand trends, patterns, and to make correlations. They’re typically instruments for reasoning about quantitative information. Some of the sample plots are covered here.

#importing matplotlib module
from matplotlib import pyplot as plt  

#x-axis values
x=[5,3,7,2,1]

#y-axis values
y=[10,5,2,9,2]

plt.plot(x,y)

#Function to show the plot
plt.show()

For Bar plots, we can use plt.bar(x,y)

For Histogram, we can use plt.hist(x,y)

For scatter plots, we can use plt.scatter(x,y)

Do try the above codes and have fun 🙂

Hope you enjoyed my blog. Bye and Take care:)

2 thoughts on “Scikit and Matplotlib”

Leave a comment