缩放不失价值重要性的Python Sklearn

问题描述 投票:1回答:1

该CSV的样品是:

0.03528821669081923,0.4209514856338501
0.4755249949860231,0.4248427748680115
0.09710556840327728,0.4209169149398804
0.07149631133318766,0.4201127290725708
-0.2400341908399068,0.417565792798996
-0.17768551828033466,0.4184338748455048
-0.30025757809215714,0.416279673576355
-0.09094791496191304,0.41964152455329895
0.07154744586719554,0.4196658134460449
0.2381333126503035,0.42377570271492
0.2593105332145284,0.4222800433635712
-0.6691065606953182,0.4089060425758362
-0.6456401882265393,0.4092327654361725
-0.2320063391631248,0.4154394268989563
0.03676064944004283,0.4164957106113434
-0.049027521405378964,0.4175394177436829
-0.5611679536206179,0.4090659916400909
-1.151078217514793,0.3977192640304565
-1.1251183926252533,0.3976330757141113
-1.3598634565590335,0.3943647146224976
-1.452113101667516,0.3926326930522919
-1.724856436518542,0.3888352811336517
-1.3449567318568625,0.3950198888778687
-0.9327234868901516,0.39986416697502136
-0.8698905846258818,0.40163424611091614
-1.0829297248122909,0.4009062349796295
-0.7123502605778409,0.406065821647644
-0.7078240398708294,0.4043383300304413
-1.0054995188827682,0.4010890424251557
-0.40067943737923295,0.41085284948349
-0.3684788480142471,0.4130916893482208
-0.31293912846313354,0.4178936183452606

我曾在大熊猫装好了,并试图与sklearn.preprocessing.scale()规模,但它不仅会在指定的列缩放。

df['col1'] = sklearn.preprocessing.scale(df['col1'].values)
df['col2'] = sklearn.preprocessing.scale(df['col2'].values)

我想相对于其他规模上栏,这样我就可以在同一个图绘制即可。如果值是一些如何在相同的范围,不松有重要价值,才可能如此。 请建议我我能做些什么。

python python-3.x pandas scikit-learn
1个回答
1
投票

有一两件事你可以做的是改用sklearn.preprocessing.StandardScaler,可以配合使用数组,然后变换使用计算meanstd其他阵列。所以,你可以做如下:

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()

重塑从数据框列numpy的数组:

col1 = x['col1'].values.reshape(-1,1)
col2 = x['col2'].values.reshape(-1,1)

使用qazxsw POI适合实例化对象:

col1

使用标准化从fitted = scaler.fit(col1) meanstd所有功能:

col1
© www.soinside.com 2019 - 2024. All rights reserved.