数据规范化——sklearn.preprocessing

sklearn实现---归类为5大类

  • sklearn.preprocessing.scale()(最常用,易受异常值影响)
  • sklearn.preprocessing.StandardScaler()
  • sklearn.preprocessing.minmax_scale()(一般缩放到[0,1]之间,若新数据集最大最小值范围有变,需重新minmax_scale)
  • sklearn.preprocessing.MinMaxScaler()
  • sklearn.preprocessing.maxabs_scale()(为稀疏数据而生)
  • sklearn.preprocessing.MaxAbsScaler()
  • sklearn.preprocessing.robust_scale()(为异常值而生)
  • sklearn.preprocessing.RobustScaler()
  • sklearn.preprocessing.normalize()(文本分类or聚类时常用,默认对样本正则化,上述4种默认对列,即特征来规范化)
  • sklearn.preprocessing.preprocessing.Normalizer()

借用iris数据集

import pandas as pd
import numpy as np
from sklearn import datasets
iris  = datasets.load_iris()
x, y = iris.data, iris.tar

你可能感兴趣的:(人工智能,python,数据结构与算法)