简体   繁体   English

带有导出的Keras模型的StandardScaler

[英]StandardScaler with exported Keras model

I just exported my keras model because I want to use it for my web application. 我刚刚导出了我的keras模型,因为我想将其用于我的Web应用程序。 For classification I'm using features from single audio files. 为了进行分类,我使用了单个音频文件中的功能。 The problem ist that with each prediction I only have one row, what makes the output of the StandardScaler 0. Is there any way to export the sklearn objekt that I can re use it in my webapp instead of using all the data from when I trained the model? 问题在于,对于每个预测,我只有一行,这使StandardScaler的输出为0。有什么方法可以导出sklearn对象,我可以在我的web应用程序中重新使用它,而不是使用我训练时得到的所有数据该模型?

Best regards 最好的祝福

I haven't used the webapp before, but I can save the trained scaler with joblib and then load it in the future. 我以前没有使用过webapp,但是我可以将受过训练的缩放器与joblib一起保存,然后在将来加载。

from sklearn.preprocessing import StandardScaler
import joblib
from sklearn.datasets import load_breast_cancer

data = load_breast_cancer()

data = data.data

scaler = StandardScaler()

scaler = scaler.fit(data)

data_t = scaler.transform(data)
#saves the trained scaler
joblib.dump(scaler,r"scaler")

#Loads for transforming the new  data
scaler_2 = joblib.load(r"scaler")


data_t_2 = scaler.transform(data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM