Scikit-Learn



Yüklə 1,92 Mb.
Pdf görüntüsü
səhifə21/124
tarix23.02.2023
ölçüsü1,92 Mb.
#101394
1   ...   17   18   19   20   21   22   23   24   ...   124
sklearn

Sensible defaults 
According to this principle,
 
the Scikit-learn library defines an appropriate default value 
whenever ML models require user-specified parameters.
 
Inspection 


Scikit-Learn
18 
As per this guiding principle, every specified parameter value is exposed as pubic 
attributes.
Steps in using Estimator API 
Followings are the steps in using the Scikit-Learn estimator API: 
Step 1: Choose a class of model 
In this first step, we need to choose a class of model. It can be done by importing the 
appropriate Estimator class from Scikit-learn. 
Step 2: Choose model hyperparameters 
In this step, we need to choose class model hyperparameters. It can be done by 
instantiating the class with desired values. 
Step 3: Arranging the data 
Next

we need to arrange the data into features matrix (X) and target vector(y). 
Step 4: Model Fitting 
Now,
 
we need to fit the model to your data. It can be done by calling 
fit()
method of the 
model instance. 
Step 5: Applying the model 
After fitting the model, we can apply it to new data.
 
For supervised learning, use 
predict()
method to predict the labels for unknown data. While for unsupervised learning, use 
predict() 
or
 
transform()
 
to infer properties of the data. 
Supervised Learning Example 
Here, as an example of this process we are taking common case of fitting a line to (x,y) 
data i.e. 
simple linear regression
.
First, we need to load the dataset, we are using iris dataset: 
import seaborn as sns 
iris = sns.load_dataset('iris') 
X_iris = iris.drop('species', axis = 1) 
X_iris.shape 
Output 


Scikit-Learn
19 
(150, 4) 
y_iris = iris['species'] 
y_iris.shape 

Yüklə 1,92 Mb.

Dostları ilə paylaş:
1   ...   17   18   19   20   21   22   23   24   ...   124




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə