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 ...
随机推荐
- ThinkPHP 汉字转成多种形式拼音
模型: <?php namespace Admin\Model; use Think\Model; /** * 汉字转拼音 * @author huangguojin */ class ZHMo ...
- 我们把Mybatis的功能架构分为三层:
我们把Mybatis的功能架构分为三层: (1)API接口层:提供给外部使用的接口API,开发人员通过这些本地API来操纵数据库.接口层一接收到调用请求就会调用数据处理层来完成具体的数据处理. (2) ...
- 具有全球唯一性,相对于internet,IP为逻辑地址
网络与分布式集群系统的区别:每个节点都是一台计算机,而不是各种计算机内部的功能设备. Ip:具有全球唯一性,相对于internet,IP为逻辑地址. 端口(port):一台PC中可以有65536个端口 ...
- 【BZOJ】1696: [Usaco2007 Feb]Building A New Barn新牛舍(贪心)
http://www.lydsy.com/JudgeOnline/problem.php?id=1696 原题要求min(sum{|x-xi|+|y-yi|}),且一定要看题:“没有两头牛的吃草位置是 ...
- Xcode升级后插件失败解决方法
大家都知道每次升级Xcode 然后插件都不能用了,最根本的原因是每一个插件都有个Info.plist文件,这个文件里有个key-DVTPlugInCompatibilityUUIDs记录了能够使用该插 ...
- 将数据写入TXT文件中,file_put_contents与fwrite
<?php header("content-type:text/html;charset=utf-8"); $file = './aa.txt'; ###判断是不是文件 if ...
- 【转】关于OnPaint的工作机制
转载出处:http://blog.csdn.net/foreverhuylee/article/details/21889025 用了两年的VC++,其实对OnPaint的工作原理一直都是一知半解.这 ...
- hdu 4708(暴力+找规律)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708 思路:由于N不大,并且我们可以发现通过旋转得到的4个对角线的点的位置关系,以及所要旋转的最小步数 ...
- 推荐一个 HTML5在线的流程图工具——ProcessOn
一直想找个简单好用的UML建模工具,无意在茫茫百度中看见了网友推荐的N多工具,从中找了一个叫 ProcessOn 的工具,可以说非常棒.如果我是WEB开发人员,我肯定去深入研究HTML5啦,太令人着迷 ...
- iOS开发之--获取验证码倒计时及闪烁问题解决方案
大家在做验证码的时候一般都会用到倒计时,基本上大家实现的方式都差不多,先贴出一些代码来.. -(void)startTime{ __block ; //倒计时时间 dispatch_queue_t q ...