How to store scaling parameters for later use
you can use sklearn's built-in tool:
from sklearn.externals import joblib
scaler_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?
回答:
|
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
I changed the shape of array to [n, 1]. I your case it would be
Then MinMaxScaler worked in proper way. |
How to store scaling parameters for later use的更多相关文章
- 断句:Store all parameters but the first passed to this function as an array
// Store all parameters but the first passed to this function as an array //除了第一个参数,把调用publish函数时的所有 ...
- PHP7函数大全(4553个函数)
转载来自: http://www.infocool.net/kb/PHP/201607/168683.html a 函数 说明 abs 绝对值 acos 反余弦 acosh 反双曲余弦 addcsla ...
- windows下使用libsvm3.2
一.官方介绍 libsvm主页:https://www.csie.ntu.edu.tw/~cjlin/libsvm/index.html libsvm介绍文档:http://www.csie.ntu. ...
- libsvm下的windows版本中的工具的使用
下载的libsvm包里面已经为我们编译好了(windows).进入libsvm\windows,可以看到这几个exe文件: a.svm-toy.exe:图形界面,可以自己画点,产生数据等. b.svm ...
- 微软版的SqlHelper.cs类
一,微软SQLHelper.cs类 中文版: using System; using System.Data; using System.Xml; using System.Data.SqlClien ...
- OracleHelper类
using System; using System.Collections; using System.Collections.Generic; using System.Data; using S ...
- SqlHelper类
using System; using System.Collections; using System.Collections.Generic; using System.Data; using S ...
- 【2016-11-2】【坚持学习】【Day17】【微软 推出的SQLHelper】
从网络上找到 微软原版本的SQLHelper,很多行代码.认真看了,学习了. 代码: using System; using System.Data; using System.Xml; usin ...
- SqlHelper c#
using System; using System.Data; using System.Xml; using System.Data.SqlClient; using System.Collect ...
随机推荐
- 判断gridView是否有数据
我这里的gridView是采用空模板数据来显示的 当gridView的数据源为空的时候它们就会显示标题 有数据的显示它们就会显示下面的这种 你仔细观察会发现,当有数据的时候空标题的table没有了,解 ...
- JavaScript实现网页安全登录(转)
现在很多商业网站的用户登录都是明码传输的,而一般用户又习惯于所有帐号使用相同的密码来保存,甚至很多人使用的密码和自己的银行帐号都一样哦!所 以嘛还是有一定的安全隐患的,YAHOO的免费邮箱登录使用了M ...
- SpringCloud架构设计
最近一直在针对SpringCloud框架做项目,从中踩了不少的坑,也渐渐梳理出了一些内容,由于SpringCloud作为一个全家桶,其中东西太多,所以这时候就要有所取舍,这里就想把自己比较常用组件及架 ...
- 【BZOJ】1500: [NOI2005]维修数列(splay+变态题)
http://www.lydsy.com/JudgeOnline/problem.php?id=1500 模板不打熟你确定考场上调试得出来? 首先有非常多的坑点...我遇到的第一个就是,如何pushu ...
- LoadRunner压力测试心得总结
一.虚拟用户迭代一次的时间对整个压力场景的影响. 1.虚拟用户迭代一次的时间大于等于压力场景的上行周期. 此种情况,在压力场景的上行周期中,所有虚拟用户根据压力场景设置的策略全部依次运行.压力场景的上 ...
- EF简单查询
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- LA3485 Bridge[(辛普森自适应)微积分]
做此题完全是为了练积分. [普通求导版] Select Code #include<cstdio> #include<cmath> using namespace std; t ...
- ios 如何改变UISegmentedControl文本的字体大小?
UIFont *Boldfont = [UIFont boldSystemFontOfSize:16.0f]; NSDictionary *attributes = [NSDictionary dic ...
- 记录初次使用tesseract的过程
目录 简介 安装tesseract 安装成功 python应用识别图片 简介 这个谷歌的识别项目早就听说了,使用之后发现,真的很厉害.写下初次简单使用的过程吧. 安装tesseract 谷歌的开源识别 ...
- 记一个在docker中运行多线程event_loop.run_forever()的bug
问题简介 我写爬虫,用到了asyncio相关的事件循环,新建了一个线程去run_forever(),在docker中运行.后来程序有异常,主线程挂了,但是竟然不报错.查了很久,才找出来. 如果你新建一 ...