Зміст курсу
ML Introduction with scikit-learn
ML Introduction with scikit-learn
Models
You already know the basics of preprocessing your data and how to build pipelines. Now we can move to the fun part, modeling!
Let's recap what a model is. In Scikit-learn, it is an estimator that has both .predict()
and .score()
methods (and since it is an estimator, the .fit()
method is also present).
.fit()
Once the data is preprocessed and ready to go to the model, the first step of building a model is training a model. This is done using the .fit(X, y)
.
During training, a model learns everything it needs to make predictions. What the model learns and the duration of training depend on the chosen algorithm. For each task, numerous models are available, based on different algorithms. Some train slower, while others train faster.
However, training is generally the most time-consuming aspect of machine learning. If the training set is large, a model could take minutes, hours, or even days to train.
.predict()
Once the model is trained using the .fit()
method, it can perform predictions. Predicting is as easy as calling the .predict()
method:
Usually, you want to predict a target for new instances, X_new
.
.score()
The .score()
method is used to measure a trained model's performance. Usually, it is calculated on the test set (the following chapters will explain what it is). Here is the syntax:
The .score()
method requires actual target values (y_test
in the example). It calculates the prediction for X_test
instances and compares this prediction with the true target (y_test
) using some metric. By default, this metric is accuracy for classification.
Дякуємо за ваш відгук!