archive the model
This commit is contained in:
parent
eadd1af64c
commit
327962b0da
@ -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])
|
||||
|
Loading…
Reference in New Issue
Block a user