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 ...
随机推荐
- 004杰信-关于formSubmit('factorycreate.action','_self')路径的疑惑
本文材料来源于传智播客,在此说明. 整个项目结构:
- SSH三大框架的知识题
Struts 谈谈你对Struts的理解. 答: 1.struts是一个按MVC模式设计的Web层框架,其实它就是一个大大的servlet,这个Servlet名为ActionServlet,或是Act ...
- VS2005环境下采用makefile编译、使用libjpeg.lib函数库
1.从www.ijg.org下载源码,解压后得到文件夹jpeg-8d 2.在文件夹里新建jconfig.h文件,将jconfig.vc里的内容拷到jconfig.h中 3.编译. Run->CM ...
- 【vijos】1164 曹冲养猪(中国剩余定理)
https://vijos.org/p/1164 好赞orz. 对于求一组线性同余方程 x=a[i](mod m[i]) 这里任意两个m[i]和m[j]都互质 那么可以用中国剩余定理来做. 对中国剩余 ...
- QWidget切换
QWidget切换,参考类:QstackedLayout,QStackedWidget,QTabWidget 一.Tab出现的位置 tabWidget.setTabPosition(QTabWidge ...
- SQL的学习
1. 判断表达式的值是否为空在表达式后面接 IS NULL 或 IS NOT NULL 可以判断表达式是否为空或不为空 2. 把数据库中的数据导出成可执行的SQL语句对数据库点击右键一次选择 任务-- ...
- 【H.264/AVC视频编解码技术具体解释】十三、熵编码算法(4):H.264使用CAVLC解析宏块的残差数据
<H.264/AVC视频编解码技术具体解释>视频教程已经在"CSDN学院"上线,视频中详述了H.264的背景.标准协议和实现,并通过一个实战project的形式对H.2 ...
- 有Thread1、Thread2、Thread3、Thread4四条线程分别统计C、D、E、F四个盘的大小,所有线程都统计完毕交给Thread5线程去做汇总,应当如何实现?
利用java.util.concurrent包下的CountDownLatch(减数器)或CyclicBarrier(循环栅栏) 转自:http://www.cnblogs.com/westward/ ...
- css做鼠标指向图片图片放大但边框不放大
这是一个圆形边框做的效果 HTML <div class="circle-wrapper"> <img src="" > </di ...
- SSH电力项目九--运行监控首页显示
需求:在首页显示出设备运行情况,并去掉<br>换行符,每隔十分钟刷新一次页面. ElecMenuAction.java 首先注入运行监控service public class ElecM ...