Scikit-Learn


array or Pandas  Series



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

array
or Pandas 
Series
. Target array may 
have both the values, continuous numerical values and discrete values.
How target array differs from feature columns? 
We can distinguish both by one point that the target array is usually the quantity we want 
to predict from the data i.e. in statistical terms it is the dependent variable.
Example 
In the example below, from 
iris dataset
we predict the species of flower based on the other 
measurements. In this case, the 
Species 
column would be considered as the feature.
import seaborn as sns 
iris = sns.load_dataset('iris') 
%matplotlib inline 
import seaborn as sns; sns.set() 
sns.pairplot(iris, hue='species', height=3); 
 
Output 


Scikit-Learn
15 
X_iris = iris.drop('species', axis=1) 
X_iris.shape 
y_iris = iris['species'] 
y_iris.shape 
Output 
(150,4) 
(150,) 
 


Scikit-Learn
16 
In this chapter, we will learn about 
Estimator API
(application programming interface). 
Let us begin by understanding what is an Estimator API. 
What is Estimator API? 
It is one of the main APIs implemented by Scikit-learn. It provides a consistent interface 
for a wide range of ML applications that’s why all machine learning algorithms in Scikit-
Learn are implemented via Estimator API. The object that learns from the data (fitting the 
data) is an estimator. It can be used with any of the algorithms like classification
regression, clustering or even with a transformer, that extracts useful features from raw 
data. 
For fitting the data, all estimator objects expose a fit method that takes a dataset shown 
as follows: 
estimator.fit(data) 
Next, all the parameters of an estimator can be set, as follows, when it is instantiated by 
the corresponding attribute. 
estimator = Estimator (param1=1, param2=2) 
estimator.param1 
The output of the above would be 1. 
Once data is fitted with an estimator, parameters are estimated from the data at hand. 
Now, all the estimated parameters will be the attributes of the estimator object ending by 
an underscore as follows: 
estimator.estimated_param_ 

Yüklə 1,92 Mb.

Dostları ilə paylaş:
1   ...   15   16   17   18   19   20   21   22   ...   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ə