A Beginners Guide to Scikit-Learn
Estimators

The Scitkit-learn library provides a very large variety of pre-built algorithms to perform both supervised and unsupervised machine learning. They are generally referred to as estimators.

The estimator you choose for your project will depend on the data set you have and the problem that you are trying to solve. The Scikit-learn documentation helpfully provides this diagram, shown below, to help you to determine which algorithm is right for your task.

What makes Scikit-learn so straight forward to use is that regardless of the model or algorithm you are using, the code structure for model training and prediction is the same.

To illustrate this let’s run through an example.

Let’s say you are working on a regression problem and want to train a linear regression algorithm and use the resulting model to make predictions. The first step, with Scikit-learn, is to call the logistic regression estimator and save it as an object. The example below calls the algorithm and saves it as an object called lr.

The next step is to fit the model to some training data. This is performed using the fit() method. We call lr.fit() on the features and target data and save the resulting model as an object called model. In the example below I am also using the train_test_split() method to split the dataset into test and train data.

Next, we use the model and the predict() method to predict on previously unseen data.

If we were to now use Scitkit-learn to perform a different task, say for example, we wanted to train a random forest classifier. The code would look very similar and have the same number of steps.

This consistent code structure makes developing machine learning models extremely straight forward and also produces code that is highly readable and reproducible.
['Rebecca Vickery']
['Machine Learning', 'Data Science', 'Technology', 'Education', 'Getting Started']