Understanding Estimators
So, what exactly is an estimator anyway? The concept of estimators lies at the heart of scikit-learn. Estimators are objects (in the Python Object-Oriented Programming (OOP) sense) that implement algorithms for learning from data and are consistent across the entire library. Every estimator in scikit-learn, whether a model or a transformer, follows a simple and intuitive interface. The two most essential methods of any estimator are fit()
and predict()
previously mentioned. The fit()
method trains the model by learning from data, while predict()
is used to make predictions on new data based on the trained model. This is the raison d’etre of ML.
For example, in one of the simplest ML models (yet still often powerful), LinearRegression()
, calling fit()
with training data allows the model to learn the optimal coefficients for predicting outcomes. Afterward, predict()
can be used on new data to generate predictions.
from sklearn.linear_model import LinearRegression...