본문 바로가기
둘/[ Machine Learning ]

Scaler & Model 저장 및 불러오기

by Kieran_Han 2024. 12. 18.

Scaler File 저장, 내보내기

sc_X = StandardScaler()

normed_train_data = sc_X.fit_transform(train_data)
normed_train_data = pd.DataFrame(normed_train_data, dtype = float)

normed_test_data = sc_X.transform(test_data)

# Save Scaler
joblib.dump(sc_X, os.getcwd() + "\\Model_Scalar.pkl")

 

Model File 저장, 내보내기

save_model(best_model, "Prediction_Model.h5")

 

Model File 불러오기

model = load_model(os.getcwd() + "\\Trained_Model\\Prediction_Model.h5")
model

 

Scaler File 불러오기

sc_X = pd.read_pickle(os.getcwd() + "\\Model_Scalar.pkl")
sc_X

 

Scaler File 활성화

sc_X = StandardScaler()
sc_X.fit(test_data)

normed_X_train = sc_X.fit_transform(test_data)
normed_X_train = pd.DataFrame(normed_X_train, dtype = float)
normed_X_test = sc_X.transform(test_data)