s
This commit is contained in:
parent
8f458fd54a
commit
134226fa79
28
train.py
28
train.py
@ -1,13 +1,13 @@
|
|||||||
from sacred import Experiment
|
from sacred import Experiment
|
||||||
from sacred.observers import MongoObserver, FileStorageObserver
|
from sacred.observers import MongoObserver, FileStorageObserver
|
||||||
|
|
||||||
ex = Experiment('s487187-training')
|
# ex = Experiment('s487187-training')
|
||||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
# ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||||
ex.observers.append(FileStorageObserver('results'))
|
# ex.observers.append(FileStorageObserver('results'))
|
||||||
ex.use_git = False
|
# ex.use_git = False
|
||||||
|
|
||||||
@ex.config
|
# @ex.config
|
||||||
def my_config():
|
# def my_config():
|
||||||
data_file = 'data.csv'
|
data_file = 'data.csv'
|
||||||
model_file = 'model.h5'
|
model_file = 'model.h5'
|
||||||
epochs = 10
|
epochs = 10
|
||||||
@ -15,8 +15,8 @@ def my_config():
|
|||||||
test_size = 0.2
|
test_size = 0.2
|
||||||
random_state = 42
|
random_state = 42
|
||||||
|
|
||||||
@ex.capture
|
# @ex.capture
|
||||||
def train_model(data_file, model_file, epochs, batch_size, test_size, random_state):
|
# def train_model(data_file, model_file, epochs, batch_size, test_size, random_state):
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from sklearn.model_selection import train_test_split
|
from sklearn.model_selection import train_test_split
|
||||||
from sklearn.preprocessing import MinMaxScaler
|
from sklearn.preprocessing import MinMaxScaler
|
||||||
@ -60,10 +60,10 @@ def train_model(data_file, model_file, epochs, batch_size, test_size, random_sta
|
|||||||
|
|
||||||
model.save(model_file)
|
model.save(model_file)
|
||||||
|
|
||||||
return accuracy
|
# return accuracy
|
||||||
|
|
||||||
@ex.main
|
# @ex.main
|
||||||
def run_experiment():
|
# def run_experiment():
|
||||||
accuracy = train_model()
|
# accuracy = train_model()
|
||||||
ex.log_scalar('accuracy', accuracy)
|
# ex.log_scalar('accuracy', accuracy)
|
||||||
ex.add_artifact('model.h5')
|
# ex.add_artifact('model.h5')
|
||||||
|
Loading…
Reference in New Issue
Block a user