Scikit-Learn



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

 
L1 Normalisation 
It is also called Least Absolute Deviations. It modifies the value in such a manner that the 
sum of the absolute values remains always up to 1 in each row. Following example shows 
the implementation of L1 normalisation on input data.
 
Example 
import numpy as np 
from sklearn import preprocessing
Input_data = np.array([2.1, -1.9, 5.5], 
[-1.5, 2.4, 3.5], 
[0.5, -7.9, 5.6], 
[5.9, 2.3, -5.8]]) 
data_normalized_l1 = preprocessing.normalize(input_data, norm='l1') 
print("\nL1 normalized data:\n", data_normalized_l1) 
Output 
L1 normalized data: 
[[ 0.22105263 -0.2 0.57894737] 
[-0.2027027 0.32432432 0.47297297] 
[ 0.03571429 -0.56428571 0.4 ] 
[ 0.42142857 0.16428571 -0.41428571]] 


Scikit-Learn
12 
L2 Normalisation 
Also called Least Squares. It modifies the value in such a manner that the sum of the 
squares remains always up to 1 in each row. Following example shows the implementation 
of L2 normalisation on input data.
 
Example 
import numpy as np 
from sklearn import preprocessing
Input_data = np.array([2.1, -1.9, 5.5], 
[-1.5, 2.4, 3.5], 
[0.5, -7.9, 5.6], 
[5.9, 2.3, -5.8]]) 
data_normalized_l2 = preprocessing.normalize(input_data, norm='l2') 
print("\nL1 normalized data:\n", data_normalized_l2) 
Output 
L2 normalized data: 
[[ 0.33946114 -0.30713151 0.88906489] 
[-0.33325106 0.53320169 0.7775858 ] 
[ 0.05156558 -0.81473612 0.57753446] 
[ 0.68706914 0.26784051 -0.6754239 ]] 


Scikit-Learn
13 
As we know that machine learning is about to create model from data. For this purpose, 
computer must understand the data first. Next, we are going to discuss various ways to 
represent the data in order to be understood by computer: 
Data as table 
The best way to represent data in Scikit-learn is in the form of tables. A table represents 
a 2-D grid of data where rows represent the individual elements of the dataset and the 
columns represents the quantities related to those individual elements.

Yüklə 1,92 Mb.

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