数据规范化(标准化)

在数据预处理时,这两个术语可以互换使用。(不考虑标准化在统计学中有特定的含义)。 
下面所有的规范化操作都是针对一个特征向量(dataFrame中的一个colum)来操作的。 
首先举一个例子:

//MaxAbsScaler例子(参考后面MaxAbsScaler部分)
//例子:对特征0,特征1,特征2,分别进行缩放,使得值为[-1,1]
//例如特征0,其特征向量为[1000,100,-10] absMax=1000,因此缩放为[1.0,0.1,-0.01]+-----+--------------------------------+----------------------------+
|label|features                        |maxAbsScalerFeatures        |
+-----+--------------------------------+----------------------------+
|1.0  |(3,[0,1,2],[1000.0,0.1,-25.0])  |(3,[0,1,2],[1.0,0.001,-1.0])|
|2.0  |(3,[0,1,2],[100.0,-100.0,-25.0])|(3,[0,1,2],[0.1,-1.0,-1.0]) |
|3.0  |(3,[0,1,2],[-10.0,35.0,12.5])   |(3,[0,1,2],[-0.01,0.35,0.5])|
+-----+--------------------------------+----------------------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

Normalizer 规范化

将某个特征向量(由所有样本某一个特征组成的向量)计算其p-范数,然后对该每个元素除以p-范数。将原始特征Normalizer以后可以使得机器学习算法有更好的表现。

单位P-范数定义如下: 

当p取1,2,∞的时候分别是以下几种最简单的情形: 
1-范数 (L1) : ║x║1=│x1│+│x2│+…+│xn│  
2-范数 (L1) : ║x║2=(│x1│2+│x2│2+…+│xn│2)1/2  
∞-范数 (L∞) : ║x║∞=max(│x1│,│x2│,…,│xn│)  
其中2-范数就是通常意义下的距离。

Normalizer is a Transformer which transforms a dataset of Vector rows, normalizing each Vector to have unit norm. It takes parameter p, which specifies the p-norm used for normalization. ( p=2  by default.) This normalization can help standardize your input data and improve the behavior of learning algorithms.

//完整Java版代码
package my.spark.ml.practice.classification;
import org.apache.spark.ml.feature.Normalizer;
import org.apache.spark.sql.Dataset;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SparkSession;
public class myNorm {public static void main(String[] args) {SparkSession spark=SparkSession.builder().appName("CoFilter").master("local[4]").config("spark.sql.warehouse.dir","file///:G:/Projects/Java/Spark/spark-warehouse" ).getOrCreate();         String path="/spark/data/mllib/sample_multiclass_classification_data.txt";          Dataset<Row> dataFrame =spark.read().format("libsvm").load(path);//对每一行(即一个样点不同特征组成的向量),使用p-范数进行正则化//1-范数进行正则化Normalizer normalizerL1=new Normalizer().setInputCol("features").setOutputCol("normfeaturesL1").setP(1.0);normalizerL1.transform(dataFrame).show(2,false);//2-范数进行正则化Normalizer normalizerL2=new Normalizer().setInputCol("features").setOutputCol("normfeaturesL1").setP(2);normalizerL2.transform(dataFrame).show(2,false);//∞-范数进行正则化Normalizer normalizerLinf=new Normalizer().setInputCol("features").setOutputCol("normfeaturesL1").setP(Double.POSITIVE_INFINITY);normalizerLinf.transform(dataFrame).show(2,false);  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

StandardScaler

z−score 规范化,又叫零均值规范化 
将某个特征向量(由所有样本某一个特征组成的向量)进行标准化,使数据均值为0,方差为1。Spark中可以选择是带或者不带均值和方差。

new−feature(i)k=feature(i)k−featurek¯¯¯¯¯¯¯¯¯¯¯¯¯σfeaturekfeaturek是由所有样本点k特征组成向量,feature(i)k是i样本点k特征的值

注意: 尤其是离群点左右了MinMaxScaler规范化,需要使用StandardScaler。  

Spark中有两个参数可以选择: 
1、withStd=true,将方差缩放到1, 
2、withMean-将均值移到0,注意对于稀疏输入矩阵不可以用。默认为false。

StandardScaler transforms a dataset of Vector rows, normalizing each feature to have unit standard deviation and/or zero mean. It takes parameters:

  1. withStd: True by default. Scales the data to unit standard 
    deviation.
  2. withMean: False by default. Centers the data with mean before 
    scaling. It will build a dense output, so this does not work on 
    sparse input and will raise an exception.
//关键代码,其余代码参考本文“Normalizer规范化”那个例子
StandardScaler scaler=new StandardScaler().setInputCol("features").setOutputCol("scFeatures").setWithMean(false)//数据为稀疏矩阵,必须设置为false.setWithStd(true);
StandardScalerModel model=scaler.fit(dataFrame);
model.transform(dataFrame).show(10,false);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

MinMaxScaler

最大-最小规范化: 
将所有特征向量线性变换到用户指定最大-最小值之间。但注意在计算时还是一个一个特征向量分开计算的(见下面公式)通常将最大,最小值设置为1和0,这样就归一化到[0,1]。Spark中可以对min和max进行设置,默认就是[0,1]。

注意:(1)最大最小值可能受到离群值的左右。(2)零值可能会转换成一个非零值,因此稀疏矩阵将变成一个稠密矩阵。 
MinMaxScaler transforms a dataset of Vector rows, rescaling each feature to a specific range (often [0, 1]). It takes parameters:

参数1:min: 0.0 by default. Lower bound after transformation, shared by all features. 
参数2:max: 1.0 by default. Upper bound after transformation, shared by all features.

Note that since zero values will probably be transformed to non-zero values, output of the transformer will be DenseVector even for sparse input.

Rescaled(ei)=ei−EminEmax−Emin∗(max−min)+minEmin,Emax是某个特征向量所有元素的最大最小值,max,min是用户可以重新自定义的范围,默认为[0,1],由所有特征共享(所有特征向量都是相同的设置)
MinMaxScaler minMaxScaler=new MinMaxScaler()
                          .setInputCol("features")
                          .setOutputCol("minmaxFeatures")
                          .setMax(100.0)//将数据线性变换到[-100,100]
                          .setMin(-100.0);
MinMaxScalerModel minMaxScalerModel=minMaxScaler.fit(dataFrame);
minMaxScalerModel.transform(dataFrame).show(3,false);
//输出举例
/*
+-----+--------------------------------+----------------------------------+
|label|features                        |minmaxFeatures                    |
+-----+--------------------------------+----------------------------------+
|1.0  |(3,[0,1,2],[1000.0,0.1,-25.0])  |[100.0,48.296296296296276,-100.0] |
|2.0  |(3,[0,1,2],[100.0,-100.0,-25.0])|[-78.21782178217822,-100.0,-100.0]|
|3.0  |(3,[0,1,2],[-10.0,35.0,12.5])   |[-100.0,100.0,100.0]              |
+-----+--------------------------------+----------------------------------+
*/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

MaxAbsScaler

同样是对某一个特征操作,各特征值除以最大绝对值,因此缩放到[-1,1]之间。且不移动中心点。不会将稀疏矩阵变得稠密。例如一个叫长度的特征,有三个样本有此特征,特征向量为[-1000,100,10],最大绝对值为1000,因此转换为[-1000/1000,100/100,10/1000]=[-1,0.1,0.01]。 
       因此如果最大绝对值是一个离群点,显然这种处理方式是很不合理的。

MaxAbsScaler transforms a dataset of Vector rows, rescaling each feature to range [-1, 1] by dividing through the maximum absolute value in each feature. It does not shift/center the data, and thus does not destroy any sparsity.

MaxAbsScaler computes summary statistics on a data set and produces a MaxAbsScalerModel. The model can then transform each feature individually to range [-1, 1].

//关键代码,无需参数设置MaxAbsScalerModel maxAbsScalerModel=new MaxAbsScaler().setInputCol("features").setOutputCol("maxAbsScalerFeatures").fit(dataFrame);
maxAbsScalerModel.transform(dataFrame).show(10,false);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

String<->Index 相互转换

VectorIndexer

主要作用:提高决策树或随机森林等ML方法的分类效果。 
VectorIndexer是对数据集特征向量中的类别(离散值)特征(index categorical features categorical features )进行编号。 
它能够自动判断那些特征是离散值型的特征,并对他们进行编号,具体做法是通过设置一个maxCategories,特征向量中某一个特征不重复取值个数小于maxCategories,则被重新编号为0~K(K<=maxCategories-1)。某一个特征不重复取值个数大于maxCategories,则该特征视为连续值,不会重新编号(不会发生任何改变)。结合例子看吧,实在太绕了。

    VectorIndexer helps index categorical features in datasets of Vectors. It can both automatically decide which features are categorical and convert original values to category indices. Specifically, it does the following:Take an input column of type Vector and a parameter maxCategories. Decide which features should be categorical based on the number of distinct values, where features with at most maxCategories are declared categorical.
Compute 0-based category indices for each categorical feature.
Index categorical features and transform original feature values to indices.Indexing categorical features allows algorithms such as Decision Trees and Tree Ensembles to treat categorical features appropriately, improving performance.This transformed data could then be passed to algorithms such as DecisionTreeRegressor that handle categorical features.

用一个简单的数据集举例如下:

//定义输入输出列和最大类别数为5,某一个特征
//(即某一列)中多于5个取值视为连续值
VectorIndexerModel featureIndexerModel=new VectorIndexer().setInputCol("features").setMaxCategories(5).setOutputCol("indexedFeatures").fit(rawData);
//加入到Pipeline
Pipeline pipeline=new Pipeline().setStages(new PipelineStage[]{labelIndexerModel,featureIndexerModel,dtClassifier,converter});
pipeline.fit(rawData).transform(rawData).select("features","indexedFeatures").show(20,false);
//显示如下的结果:
+-------------------------+-------------------------+
|features                 |indexedFeatures          |
+-------------------------+-------------------------+
|(3,[0,1,2],[2.0,5.0,7.0])|(3,[0,1,2],[2.0,1.0,1.0])|
|(3,[0,1,2],[3.0,5.0,9.0])|(3,[0,1,2],[3.0,1.0,2.0])|
|(3,[0,1,2],[4.0,7.0,9.0])|(3,[0,1,2],[4.0,3.0,2.0])|
|(3,[0,1,2],[2.0,4.0,9.0])|(3,[0,1,2],[2.0,0.0,2.0])|
|(3,[0,1,2],[9.0,5.0,7.0])|(3,[0,1,2],[9.0,1.0,1.0])|
|(3,[0,1,2],[2.0,5.0,9.0])|(3,[0,1,2],[2.0,1.0,2.0])|
|(3,[0,1,2],[3.0,4.0,9.0])|(3,[0,1,2],[3.0,0.0,2.0])|
|(3,[0,1,2],[8.0,4.0,9.0])|(3,[0,1,2],[8.0,0.0,2.0])|
|(3,[0,1,2],[3.0,6.0,2.0])|(3,[0,1,2],[3.0,2.0,0.0])|
|(3,[0,1,2],[5.0,9.0,2.0])|(3,[0,1,2],[5.0,4.0,0.0])|
+-------------------------+-------------------------+
结果分析:特征向量包含3个特征,即特征0,特征1,特征2。如Row=1,对应的特征分别是2.0,5.0,7.0.被转换为2.0,1.0,1.0。
我们发现只有特征1,特征2被转换了,特征0没有被转换。这是因为特征0有6中取值(2,3,4,5,8,9),多于前面的设置setMaxCategories(5)
,因此被视为连续值了,不会被转换。
特征1中,(4,5,6,7,9)-->(0,1,2,3,4,5)
特征2中,  (2,7,9)-->(0,1,2)输出DataFrame格式说明(Row=1):
3个特征 特征0,1,2      转换前的值
|(3,    [0,1,2],      [2.0,5.0,7.0])
3个特征 特征1,1,2       转换后的值
|(3,    [0,1,2],      [2.0,1.0,1.0])|
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

StringIndexer

理解了前面的VectorIndexer之后,StringIndexer对数据集的label进行重新编号就很容易理解了,都是采用类似的转换思路,看下面的例子就可以了。

//定义一个StringIndexerModel,将label转换成indexedlabel
StringIndexerModel labelIndexerModel=new StringIndexer().
                setInputCol("label")
                .setOutputCol("indexedLabel")
                .fit(rawData);
//加labelIndexerModel加入到Pipeline中
Pipeline pipeline=new Pipeline()
                 .setStages(new PipelineStage[]
                         {labelIndexerModel,
                         featureIndexerModel,
                         dtClassifier,
                         converter});
//查看结果
pipeline.fit(rawData).transform(rawData).select("label","indexedLabel").show(20,false);按label出现的频次,转换成0~num numOfLabels-1(分类个数),频次最高的转换为0,以此类推:
label=3,出现次数最多,出现了4次,转换(编号)为0
其次是label=2,出现了3次,编号为1,以此类推
+-----+------------+
|label|indexedLabel|
+-----+------------+
|3.0  |0.0         |
|4.0  |3.0         |
|1.0  |2.0         |
|3.0  |0.0         |
|2.0  |1.0         |
|3.0  |0.0         |
|2.0  |1.0         |
|3.0  |0.0         |
|2.0  |1.0         |
|1.0  |2.0         |
+-----+------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

在其它地方应用StringIndexer时还需要注意两个问题: 
(1)StringIndexer本质上是对String类型–>index( number);如果是:数值(numeric)–>index(number),实际上是对把数值先进行了类型转换( cast numeric to string and then index the string values.),也就是说无论是String,还是数值,都可以重新编号(Index); 
(2)利用获得的模型转化新数据集时,可能遇到异常情况,见下面例子。

StringIndexer对String按频次进行编号id | category | categoryIndex
----|----------|---------------0  | a        | 0.01  | b        | 2.02  | c        | 1.03  | a        | 0.04  | a        | 0.05  | c        | 1.0如果转换模型(关系)是基于上面数据得到的 (a,b,c)->(0.0,2.0,1.0),如果用此模型转换category多于(a,b,c)的数据,比如多了d,e,就会遇到麻烦:id | category | categoryIndex
----|----------|---------------0  | a        | 0.01  | b        | 2.02  | d        | ?3  | e        | ?4  | a        | 0.05  | c        | 1.0Spark提供了两种处理方式:StringIndexerModel labelIndexerModel=new StringIndexer().setInputCol("label").setOutputCol("indexedLabel")//.setHandleInvalid("error").setHandleInvalid("skip").fit(rawData);(1)默认设置,也就是.setHandleInvalid("error"):会抛出异常org.apache.spark.SparkException: Unseen label: d,e(2).setHandleInvalid("skip") 忽略这些label所在行的数据,正常运行,将输出如下结果:id | category | categoryIndex
----|----------|---------------0  | a        | 0.01  | b        | 2.04  | a        | 0.05  | c        | 1.0
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

IndexToString

相应的,有StringIndexer,就应该有IndexToString。在应用StringIndexer对labels进行重新编号后,带着这些编号后的label对数据进行了训练,并接着对其他数据进行了预测,得到预测结果,预测结果的label也是重新编号过的,因此需要转换回来。见下面例子,转换回来的convetedPrediction才和原始的label对应。

         Symmetrically to StringIndexer, IndexToString maps a column of label indices back to a column containing the original labels as strings. A common use case is to produce indices from labels with StringIndexer, train a model with those indices and retrieve the original labels from the column of predicted indices with IndexToString.
IndexToString converter=new IndexToString()
                .setInputCol("prediction")//Spark默认预测label行
                .setOutputCol("convetedPrediction")//转换回来的预测label
                .setLabels(labelIndexerModel.labels());//需要指定前面建好相互相互模型
Pipeline pipeline=new Pipeline()
                 .setStages(new PipelineStage[]
                         {labelIndexerModel,
                         featureIndexerModel,
                         dtClassifier,
                         converter});
pipeline.fit(rawData).transform(rawData)
        .select("label","prediction","convetedPrediction").show(20,false);
|label|prediction|convetedPrediction|
+-----+----------+------------------+
|3.0  |0.0       |3.0               |
|4.0  |1.0       |2.0               |
|1.0  |2.0       |1.0               |
|3.0  |0.0       |3.0               |
|2.0  |1.0       |2.0               |
|3.0  |0.0       |3.0               |
|2.0  |1.0       |2.0               |
|3.0  |0.0       |3.0               |
|2.0  |1.0       |2.0               |
|1.0  |2.0       |1.0               |
+-----+----------+------------------+
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25

离散<->连续特征或Label相互转换

oneHotEncoder

独热编码将类别特征(离散的,已经转换为数字编号形式),映射成独热编码。这样在诸如Logistic回归这样需要连续数值值作为特征输入的分类器中也可以使用类别(离散)特征。

独热编码即 One-Hot 编码,又称一位有效编码,其方法是使用N位 状态寄存 
器来对N个状态进行编码,每个状态都由他独立的寄存器 位,并且在任意 
时候,其 中只有一位有效。 
例如: 自然状态码为:000,001,010,011,100,101 
独热编码为:000001,000010,000100,001000,010000,100000 
可以这样理解,对于每一个特征,如果它有m个可能值,那么经过独 热编码 
后,就变成了m个二元特征。并且,这些特征互斥,每次只有 一个激活。因 
此,数据会变成稀疏的。 
这样做的好处主要有: 
解决了分类器不好处理属性数据的问题 
在一定程度上也起到了扩充特征的作用

One-hot encoding maps a column of label indices to a column of binary vectors, with at most a single one-value. This encoding allows algorithms which expect continuous features, such as Logistic Regression, to use categorical features.

//onehotencoder前需要转换为string->numericalDataset<Row> indexedDf=new StringIndexer().setInputCol("category").setOutputCol("indexCategory").fit(df).transform(df);//对随机分布的类别进行OneHotEncoder,转换后可以当成连续数值输入Dataset<Row> coderDf=new OneHotEncoder().setInputCol("indexCategory").setOutputCol("ontHotCategory")//不需要fit                     .transform(indexedDf);
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

Bucketizer

分箱(分段处理):将连续数值转换为离散类别 
        比如特征是年龄,是一个连续数值,需要将其转换为离散类别(未成年人、青年人、中年人、老年人),就要用到Bucketizer了。 
        分类的标准是自己定义的,在Spark中为split参数,定义如下: 
        double[] splits = {0, 18, 35,50, Double.PositiveInfinity} 
        将数值年龄分为四类0-18,18-35,35-50,55+四个段。 
     如果左右边界拿不准,就设置为,Double.NegativeInfinity, Double.PositiveInfinity,不会有错的。

Bucketizer transforms a column of continuous features to a column of 
feature buckets, where the buckets are specified by users.

//
double[] splits={0,18,35,55,Double.POSITIVE_INFINITY};Dataset<Row> bucketDf=new Bucketizer().setInputCol("ages").setOutputCol("bucketCategory").setSplits(splits)//设置分段标准.transform(df);
//输出
/*
+---+----+--------------+
|id |ages|bucketCategory|
+---+----+--------------+
|0.0|2.0 |0.0           |
|1.0|67.0|3.0           |
|2.0|36.0|2.0           |
|3.0|14.0|0.0           |
|4.0|5.0 |0.0           |
|5.0|98.0|3.0           |
|6.0|65.0|3.0           |
|7.0|23.0|1.0           |
|8.0|37.0|2.0           |
|9.0|76.0|3.0           |
+---+----+--------------+*/
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

QuantileDiscretizer

分位树为数离散化,和Bucketizer(分箱处理)一样也是:将连续数值特征转换为离散类别特征。实际上Class QuantileDiscretizer extends (继承自) Class(Bucketizer)。

  • 参数1:不同的是这里不再自己定义splits(分类标准),而是定义分几箱(段)就可以了。QuantileDiscretizer自己调用函数计算分位数,并完成离散化。 
    -参数2: 另外一个参数是精度,如果设置为0,则计算最精确的分位数,这是一个高时间代价的操作。
  • 另外上下边界将设置为正负无穷,覆盖所有实数范围。

QuantileDiscretizer takes a column with continuous features and outputs a column with binned categorical features. The number of bins is set by the numBuckets parameter. The bin ranges are chosen using an approximate algorithm (see the documentation for approxQuantile for a detailed description). The precision of the approximation can be controlled with the relativeError parameter. When set to zero, exact quantiles are calculated (Note: Computing exact quantiles is an expensive operation). The lower and upper bin bounds will be -Infinity and +Infinity covering all real values.

new QuantileDiscretizer()
             .setInputCol("ages")
             .setOutputCol("qdCategory")
             .setNumBuckets(4)//设置分箱数
             .setRelativeError(0.1)//设置precision-控制相对误差
             .fit(df)
             .transform(df)
             .show(10,false);
//例子:
+---+----+----------+
|id |ages|qdCategory|
+---+----+----------+
|0.0|2.0 |0.0       |
|1.0|67.0|3.0       |
|2.0|36.0|2.0       |
|3.0|14.0|1.0       |
|4.0|5.0 |0.0       |
|5.0|98.0|3.0       |
|6.0|65.0|2.0       |
|7.0|23.0|1.0       |
|8.0|37.0|2.0       |
|9.0|76.0|3.0       |
+---+----+----------+

数据规范化(标准化)相关推荐

  1. tensorflow keras numpy 数据 规范化、标准化、归一化

    numpy 数据 规范化.归一化 import numpy as np import tensorflow as tf 标准化 mean = np.mean(train_data, axis=0) # ...

  2. 数据变换,数据规范化的方法之归一化(Min-max规范化)、标准化(Z-score规范化)、小数定标规范化

    这篇总结了哪些东西: 1. 数据变换 2. 数据规范化方法 归一化(Min-max规范化) 标准化(Z-score标准化) 小数定标规范化 4. 规范化的作用 3. 数据挖掘算法中是否都需要进行规范化 ...

  3. 数据规范化(归一化)、及Z-score标准化

    数据规范化 数据规范化(归一化)处理是数据挖掘的一项基础工作.不同评价指标往往具有不同的量纲,数值见的差别可能很大,不进行处理可能会影响到数据分析的结果.为了消除指标之间的量纲和取值范围差异的影响,需 ...

  4. Python数据挖掘:数据转换-数据规范化

    来源:天善智能韦玮老师课堂笔记 作者:Dust ---------- 数据转换: 简单变换 1.数据变换的目的是降数据转化为更方便分析的数据. 2.简单变换通常使用函数变换的方式进行,常见的函数变换包 ...

  5. 数据库数据规范化看不懂_数据库管理系统中的规范化

    数据库数据规范化看不懂 DBMS中的规范化 (Normalization in DBMS) Every table must have a single idea. The method by whi ...

  6. python 归一化_数据的标准化和归一化

    数据的标准化 归一化 归一化的目标 归一化的好处 归一化的方法 无量纲表达式 为什么要对数据进行归一化处理 常见的数据归一化方法 Python归一化处理方法 数据的标准化 数据的标准化(normali ...

  7. Python数据分析学习笔记:使用SciKit-Learn进行数据规范化

    Python数据分析学习笔记:使用SciKit-Learn进行数据规范化 数据规范化是数据挖掘的一项基础工作.不同评价指标往往具有不同的量纲,数值见的差别可能很大,不进行处理可能会影响到数据分析的结果 ...

  8. 数据规范化处理方法-Min-max 规范化和 Z-Score 规范化

    数据规范化处理 在拿到数据进行建模之前,我们需要将数据进行初步处理,例如通过据平滑.数据聚集.数据概化和规范化等方式将数据转换成适用于数据挖掘的形式.本文只介绍min-max标准化.Z-score标准 ...

  9. 数据规范化与数据离散化

    文章目录 一.数据规范化 1.小数定标规范化 2.最小-最大规范化 3.零-均值规范化(z-score规范化) 二.数据离散化 一.数据规范化 数据规范化(归一化)处理是数据挖掘的一项基础工作.不同评 ...

最新文章

  1. 超详讲解图像拼接/全景图原理和应用 | 附源码
  2. 【刷算法】判断链表是否有环以及返回入环节点
  3. micropython比c_选择C/C++还是选择MicroPython来开发?(第0章-第三节)
  4. python编码规范手册-python 编码规范整理
  5. ArcGIS Server for Silverlight 之集群(Simple Clusterer)
  6. OpenCV使用霍夫变换进行寻线的实例(附完整代码)
  7. MAC chrome浏览器 adobe flash player不是最新版本提示 的解决方案
  8. 测试智慧城市项目API接口
  9. 编程语言(1)--Go 语言环境安装
  10. Linux下实现一个网卡绑定多个IP地址
  11. 使用Css隐藏超出容器宽度的文字,溢出部分用“...”表示
  12. 关于iOS7之后状态栏修改总结
  13. 计算机云文档,计算机的云计算论文.doc
  14. MongoDB聚合—计数count
  15. Python3 configparser值为多行时配置文件书写格式
  16. tornado异步请求的理解
  17. bootcamp opencore_黑苹果(Hackintosh)BootCamp 使用教程
  18. 基于直流电机调速平台的PID参数整定心得
  19. kms激活win10
  20. linux系统添加host,Linux:在系统上设置hostid?

热门文章

  1. VS F12键失效怎么办?
  2. css判断iPhone样式
  3. 准独角兽已出现,火爆的隐私计算赛道谁是头部玩家?
  4. 几种常用的mosfet驱动电路
  5. 最新版Jenkins 2.249.3的安装
  6. 归并排序(JAVA版)
  7. 进程间通信的方式(附代码分析)
  8. c语言中的用户标识符是什么,C语言中用户标识符是什么?
  9. Typora收费了,再找找免费的Markdown编辑器吗?
  10. NDN Link :利用区块链技术代替TCP/IP 通信模式