- Hands-On Neural Networks
- Leonardo De Marchi Laura Mitchell
- 261字
- 2021-06-24 14:00:11
Feature scaling
A very important engineering technique that is necessary to perform even with neural networks is feature scaling. It's necessary to scale the numerical input to have all the features on the same scale; otherwise, the network will give more importance to features with larger numerical values.
A very simple transformation is re-scaling the input between 0 and 1, also known as MinMax scaling. Other common operations are standardization and zero-mean translation, which makes sure the standard deviation of the input is 1 and the mean is 0, which in the scikit-learn library are implemented in the scale method:
from sklearn import preprocessing
import numpy as np
X_train = np.array([[ -3., 1., 2.],
[ 2., 0., 0.],
[ 1., 2., 3.]])
X_scaled = preprocessing.scale(X_train)
The preceding command generates the following result:
Out[2]:
array([[-1.38873015, 0. , 0.26726124],
[ 0.9258201 , -1.22474487, -1.33630621],
[ 0.46291005, 1.22474487, 1.06904497]])
You can find many other numerical transformations already available in scikit-learn. Some other important transformations from its documentation are as follows:
- PowerTransformer: This transformation applies a power transformation to each feature in order to transform the data to follow a Gaussian-like distribution. It will find the optimal scaling factor to stabilize the variance and at the same time minimize skewness. The PowerTransformer transformation of scikit-learn will force the mean to be zero and force the variance to 1.
- QuantileTransformer: This transformation has an additional output_distribution parameter that allows us to force a Gaussian distribution to the features instead of a uniform distribution. It will introduce saturation for our inputs' extreme values.
- Dreamweaver CS3 Ajax網(wǎng)頁設(shè)計(jì)入門與實(shí)例詳解
- Design for the Future
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)·基礎(chǔ)模塊
- Windows XP中文版應(yīng)用基礎(chǔ)
- 控制系統(tǒng)計(jì)算機(jī)仿真
- PostgreSQL 10 Administration Cookbook
- 單片機(jī)C語言應(yīng)用100例
- 深度學(xué)習(xí)與目標(biāo)檢測
- 嵌入式操作系統(tǒng)原理及應(yīng)用
- 零起點(diǎn)學(xué)西門子S7-200 PLC
- Learning ServiceNow
- Natural Language Processing and Computational Linguistics
- 工業(yè)機(jī)器人操作
- Mastering Windows Group Policy
- 人工智能基礎(chǔ)教程:Python篇(青少版)