fit_transform和inverse_transform在两个不同的脚本上
如何fit_transform
& inverse_transform
在单独的脚本中?
我首先在脚本中标准化数值目标(整数)。
然后,我使用其他脚本实时预测这些数值目标(回归)。
fit_transform
& inverse_transform
函数def在第三个脚本中。
scaler = MinMaxScaler(copy=True, feature_range=(0.,1.))
def normalize(array):
array = scaler.fit_transform(array).flatten()
return array
def inverse_norm(array):
array = scaler.inverse_transform(array).flatten()
return array
天真,我只是“ inverse_transform”我的实时脚本中的预测值。
但是预测的值不在原始数值目标中:这些是浮点数很小的。
感谢您的帮助。
How to fit_transform
& inverse_transform
in separate scripts?
I first normalize numerical targets (integers) in a script.
Then, I use an other script to predict in real-time these numerical targets (regression).
fit_transform
& inverse_transform
functions def are in a third script.
scaler = MinMaxScaler(copy=True, feature_range=(0.,1.))
def normalize(array):
array = scaler.fit_transform(array).flatten()
return array
def inverse_norm(array):
array = scaler.inverse_transform(array).flatten()
return array
Naively, I just "inverse_transformed" the predicted values within my real-time script.
But predicted values were not in the range as the original numerical targets: these are little float numbers.
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
总的来说,我认为您不想将目标变量归一化,但是如果您想这样做,则可以使用标签编码器而不是Minmax Scaleer,该标签量表可用于正常化功能
In general I think you don't want to normalize you target variable but if you want to do so you can use a label encoder instead of a minmax scaler which is rather use to normalize features
由于Mattornothing,我解决了自己的问题。
只需写下答案即可。
第一个脚本:
第二个脚本:
其中
myArray
&myPredicedArray
是numpy数组。I fixed myself the problem thanks to mattOrNothing.
Just write down the answer.
First script:
Second script:
Where
myArray
&myPredicedArray
are numpy arrays.