一、原理介绍
通常情况下,在建模之前,都需要对数据进行标准化处理,以消除量纲的影响。如果对未标准化的数据直接进行建模,可能会导致模型对数值大的变量学习过多,而对数值小的变量训练不够充分,往往模型效果会不好。常用的数据标准化方法有最大最小归一化、均值方差标准化、小数定标法、定量特征二值化等。
最大最小归一化,顾名思义,就是利用数据列中的最大值和最小值进行标准化处理,标准化后的数值处于[0,1]之间,计算方式为数据与该列的最小值作差,再除以极差。
具体公式为:x ′ = x − m i n m a x − m i n x'=\frac{x-min}{max-min}x ′=m a x −m i n x −m i n
公式中,x'表示单个数据的取值,min是数据所在列的最小值,max是数据所在列的最大值。
最大和最小规格化很容易受到极值的影响。当一列数据出现极值时,可以考虑根据实际业务场景提前剔除极值或异常值,或者对标准化数据进行对数等变换,使变换后的数据接近正态分布。
[En]
Maximum and minimum normalization is easily affected by extreme values. When there are extreme values in a column of data, it can be considered to eliminate extreme values or outliers in advance according to the actual business scenario, or transform the standardized data, such as logarithm, to make the transformed data close to normal distribution.
二、代码实现
from sklearn.preprocessing import StandardScaler
import warnings
warnings.filterwarnings("ignore")
from pyforest import *
import pandas as pd
import numpy as np
data=pd.read_csv("F:/data/data.csv",encoding='gbk')
data.head()
(1)资产负债率(2)剔除预收款项后的资产负债率(3)长期资本负债率(4)长期资产适合率(5)权益乘数00.6557990.6067080.6138650.4949600.79197110.7520610.7054980.8416391.0000000.93299020.9573910.9415430.0000000.4934650.98863030.8070460.7807090.9846960.5306370.95808640.8052350.7960710.8614800.5412990.957462
from sklearn.preprocessing import MinMaxScaler
Standard_data=MinMaxScaler().fit_transform(data)
Standard_data
array([[0.65608912, 0.60990114, 0.61386483, 0.49495976, 0.79739631],
[0.75239351, 0.70921165, 0.84163884, 1. , 0.93938095],
[0.95781436, 0.9464991 , 0. , 0.49346475, 0.99540256],
...,
[0.73319974, 0.65164941, 0.51791243, 0.50922178, 0.92607276],
[0.66202637, 0.56413243, 0.75722411, 0.49343682, 0.81677841],
[0.88919966, 0.85747254, 0. , 0.49297322, 0.98517934]])
Standard_data = pd.DataFrame(Standard_data)
Standard_data.to_csv("F:/data/Standard_data.csv",index=False)
Original: https://blog.csdn.net/weixin_45481473/article/details/113797850
Author: data learning
Title: 数据标准化之最大最小归一化(原理+Pyhon代码)

用 kaldi 和 CVTE开源模型 实现语音识别

源码解析–hugegraph基于raft实现分布式一致性

基于stm32的智能家居语音控制系统

ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION

VGG16模型进行十种花卉分类与识别(pycharm+python3.6解释器)

深度学习、Linux基础、语音技术等电子书籍分享,仅供学习

实战:QT车牌识别系统综合设计

VScode 安装PHPdebug新版Xdebug3.0

Ubuntu系统iptables安全防护整改计划

tensorflow学习3 — 建立网络详解

tar解压包的时候出现错误 gzip: stdin: not in gzip format

python中join()用法

PCL只获取点云中一个点的法向量之computePointNormal

python如何安装keras和tensorflow
