python - Scikit-learn: Predicting new raw and unscaled instance using models trained with scaled data -
i new scikit-learn library of python. of now, have produced different classifier models using library , has been smooth-sailing. due differences of units in data (i got data different sensors labeled corresponding categories), opted scale features using standardscale module.
resulting accuracy scores of different machine learning classifiers fine. however, when try use model predict raw instance (meaning unscaled) of sensor values, models output wrong classification.
should case because of scaling done training data? if so, there easy way scale raw values too? use model persistence using joblib , appreciated if there way make modular possible. meaning say, not record mean , standard variation each feature every time training data changes.
thank much!
should case because of scaling done training data?
yes, expected behavior. trained model on scaled data, work scaled data.
if so, there easy way scale raw values too?
yes, save scaler.
# training scaler = standardscaler() x_train = scaler.fit_transform(x_train) ... # training, save classifier, , save scaler too! then
# testing # load scaler scaled_instances = scaler.transform(raw_instances) meaning say, not record mean , standard variation each feature every time training data changes
this have to do, although not hand (as scaler computes), essentialy "under hood" happens - have store means/stds each feature.
Comments
Post a Comment