博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
How to store scaling parameters for later use
阅读量:6194 次
发布时间:2019-06-21

本文共 1312 字,大约阅读时间需要 4 分钟。

you can use sklearn's built-in tool:

from sklearn.externals import joblibscaler_filename = "scaler.save"joblib.dump(scaler, scaler_filename) # And now to load...scaler = joblib.load(scaler_filename)

 

注意: from sklearn.preprocessing import MinMaxScaler 中的 MinMaxScaler 只接受shape为 [n, 1] 的数据的缩放, [1, n]的shape的数据是不能缩放的(缩放所得数据会出错):

https://stackoverflow.com/questions/25886116/sklearns-minmaxscaler-only-returns-zeros

问题:

I am trying to scale a some number to a range of 0 - 1 using preprocessing from sklearn. Thats what i did:

data = [44.645, 44.055, 44.54, 44.04, 43.975, 43.49, 42.04, 42.6, 42.46, 41.405] min_max_scaler = preprocessing.MinMaxScaler(feature_range=(0, 1)) data_scaled = min_max_scaler.fit_transform([data]) print data_scaled

But data_scaled only contains zeros. What am i doing wrong?

回答:


2

I had the same problem when I tried scaling with MinMaxScaler from sklearn.preprocessing. Scaler returned me zeros when I used a shape a numpy array as list, i.e. [1, n]. Input array would looked in your case like

data = [[44.645, 44.055, 44.54, 44.04, 43.975, 43.49, 42.04, 42.6, 42.46, 41.405]]

I changed the shape of array to [n, 1]. I your case it would be

data = [[44.645], [44.055], [44.540], [44.040], [43.975], [43.490], [42.040], [42.600], [42.460], [41.405]]

Then MinMaxScaler worked in proper way.

 

转载地址:http://hluca.baihongyu.com/

你可能感兴趣的文章
Kubernetes 集群使用 Jenkins 持续发布
查看>>
vCenter——邮件接收告警日志
查看>>
我的友情链接
查看>>
BGP 路由反射器
查看>>
linux并发连接数查看
查看>>
快捷创建H-v虚拟机
查看>>
InnoDB memcached插件的前提条件
查看>>
数状数组的学习总结
查看>>
python版春节倒计时实时显示
查看>>
基于MapReduce的ItemBase推荐算法的共现矩阵实现(一)
查看>>
使用MPLS桥接互联-----Frame Relay-to-vlan
查看>>
Using KVM Configure Openfiler 2.99 Active/Passive Cluster
查看>>
[简明python教程]学习笔记之总结篇
查看>>
我的大一总结
查看>>
希捷硬盘维修工具 v5.10.6 绿色免费版
查看>>
监控软件cacti添加主机
查看>>
浅谈千万级PV/IP规模高性能高并发网站架构
查看>>
Ansible模块知多少
查看>>
生成唯一标识的元素
查看>>
Skype for Business Server 2015-11-Web Application Proxy-部署
查看>>