From 327962b0dae88a7a185b114f506b640945a688f4 Mon Sep 17 00:00:00 2001 From: eugene Date: Tue, 6 Jun 2023 19:52:20 +0200 Subject: [PATCH] archive the model --- script5_2.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/script5_2.py b/script5_2.py index 96f340f..0942189 100644 --- a/script5_2.py +++ b/script5_2.py @@ -3,6 +3,7 @@ from sklearn.model_selection import train_test_split from sklearn.preprocessing import LabelEncoder from keras.models import Sequential from keras.layers import Dense +import pickle # Load the dataset df = pd.read_csv('data.csv') @@ -33,6 +34,13 @@ model.compile(loss='mean_squared_error', optimizer='adam') # Train the model model.fit(X_train, y_train, batch_size=64, epochs=10, validation_data=(X_test, y_test)) +# Save the model to a file +model.save('model.h5') + +# Save the encoder to a file +with open('encoder.pkl', 'wb') as f: + pickle.dump(encoder, f) + # Make predictions on new data new_writer = 'Jim Cash' new_writer_encoded = encoder.transform([new_writer])