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.
Dostları ilə paylaş: