Scikit-learn or sklearn is a machine learning library for the Python programming language. This library provides various classes and functions for classification, regression, and clustering algorithms. The sklearn library is mostly written in Python and it is built on NumPy, SciPy and Matplotlib Python library.
The sklearn library has three main types of objects. They are estimators, transformers, and predictors. In this article, we will discuss what estimators, transformrs, and predictors are in the sklearn Python library.
What are estimators in sklearn?
Estimators are the type of objects that learn from the input data. For example, in a linear regression problem, an estimator can learn from the input data and calculate or estimate the parameters for the linear regression problem.
Estimators implement a method called fit(). The learning from input data happens within this fit method. Let’s look at the example below:
import seaborn from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression df = seaborn.load_dataset("tips") X_train, X_test, y_train, y_test = train_test_split(df[["total_bill"]], df["tip"], train_size=0.8, shuffle=True, random_state=1) linear_regressor = LinearRegression() linear_regressor.fit(X_train, y_train) print(linear_regressor.coef_) print(linear_regressor.intercept_)
Here, we are reading the tips dataset using the seaborn library. The tips dataset contains various information, such as total …






0 Comments