How to store scaling parameters for later use
2017-05-27 11:41
316 查看
you can use
注意: 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
But data_scaled only contains zeros. What am i doing wrong?
回答:
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
preprocessingfrom
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?
回答:
2down vote | 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 likedata = [[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. |
相关文章推荐
- Safe to store list::iterator for later use?
- 如何在QT for S60 中使用pthread库(Carbide.c++) (How to use pthread in QT4.6 for S60)
- How to use your Selenium Tests for automated JavaScript/AJAX Performance Analysis
- How to Use RSA Key for SSH Authentication
- how to cross-language store & access small file use redis,here is soluation
- How to save data in ASCII format in ADS for use in MATLAB
- How to use Wise SetupCapture in the Wise Packager for Deployment Server to create an MSI
- How to use a Ramdisk for Linux
- How to create fully custom Role, User, Event, Resource classes for use with the Security and Scheduler modules
- How to use the HTML source for debugging issues
- ★ Learn how you can use Adobe Creative Suite to create skins for Flex and AIR applications.
- How to use http-proxy for svn
- Item 36: Understand How to Use PLINQ for I/O Bound Operations(Effective C#)
- How to use your Selenium Tests for automated JavaScript/AJAX Performance Analysis
- How to configure OpenFiler v2.3 iSCSI Storage for use with VMware ESX.
- How To Use Box2D For Just Collision Detection with Cocos2D iPhone
- How to create and use SDCard image for Android emulator
- How To Use JavaSoft References For Caching @ JDJ
- How To Use WordBasic Functions in an MFC Automation Client for Word 97, Word 2000, Word 2002, or Word 2003
- How to use iPhone with File I/O Functions: A Tutorial for Software Developers