add MLProject, update Dockerfile, dllib-sacred.py
This commit is contained in:
parent
6cda242a4c
commit
452e1bedb5
@ -2,6 +2,7 @@ import numpy as np
|
||||
import sys
|
||||
import os
|
||||
import torch
|
||||
import mlflow
|
||||
import pandas as pd
|
||||
from torch import nn
|
||||
from torch.autograd import Variable
|
||||
@ -16,13 +17,15 @@ from sacred.observers import MongoObserver
|
||||
|
||||
# EPOCHS = int(sys.argv[1])
|
||||
|
||||
ex = Experiment()
|
||||
ex.observers.append(FileStorageObserver('my_res'))
|
||||
ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
#ex = Experiment()
|
||||
#ex.observers.append(FileStorageObserver('my_res'))
|
||||
#ex.observers.append(MongoObserver(url='mongodb://admin:IUM_2021@172.17.0.1:27017', db_name='sacred'))
|
||||
|
||||
@ex.config
|
||||
def my_config():
|
||||
epochs = 100
|
||||
mlflow.set_experiment("s444356")
|
||||
|
||||
#@ex.config
|
||||
#def my_config():
|
||||
# epochs = 100
|
||||
|
||||
class Model(nn.Module):
|
||||
def __init__(self, input_dim):
|
||||
@ -242,8 +245,11 @@ def remove_list(games):
|
||||
# features_g = pd.DataFrame(features_g, dtype=np.float64)
|
||||
# features_g = features_g.to_numpy()
|
||||
|
||||
@ex.automain
|
||||
def my_main(epochs, _run):
|
||||
epochs = int(sys.argv[1]) if len(sys.argv) > 20 else 20
|
||||
|
||||
#@ex.automain
|
||||
#def my_main(epochs, _run):
|
||||
def my_main(epochs)
|
||||
platform = pd.read_csv('all_games.train.csv', sep=',', usecols=[1], header=None).values.tolist()
|
||||
release_date = pd.read_csv('all_games.train.csv', sep=',', usecols=[2], header=None).values.tolist()
|
||||
meta_score = pd.read_csv('all_games.train.csv', sep=',', usecols=[4], header=None).values.tolist()
|
||||
@ -295,7 +301,8 @@ def my_main(epochs, _run):
|
||||
loss_fn = nn.CrossEntropyLoss()
|
||||
# epochs = 1000
|
||||
# epochs = epochs
|
||||
_run.info['epochs'] = epochs
|
||||
#_run.info['epochs'] = epochs
|
||||
mlflow.log_param("epochs", epochs)
|
||||
|
||||
def print_(loss):
|
||||
print ("The loss calculated: ", loss)
|
||||
@ -322,14 +329,15 @@ def my_main(epochs, _run):
|
||||
pred = pred.detach().numpy()
|
||||
|
||||
print("The accuracy is", accuracy_score(labels_test_g, np.argmax(pred, axis=1)))
|
||||
_run.info['accuracy'] = accuracy_score(labels_test_g, np.argmax(pred, axis=1))
|
||||
#_run.info['accuracy'] = accuracy_score(labels_test_g, np.argmax(pred, axis=1))
|
||||
_run.log_scalar("measure.accuracy", accuracy_score(labels_test_g, np.argmax(pred, axis=1)))
|
||||
mlflow.log_metric("measure.accuracy", accuracy_score(labels_test_g, np.argmax(pred, axis=1)))
|
||||
pred = pd.DataFrame(pred)
|
||||
|
||||
pred.to_csv('result.csv')
|
||||
|
||||
# save model
|
||||
torch.save(model, "games_model.pkl")
|
||||
ex.add_artifact("games_model.pkl")
|
||||
#ex.add_artifact("games_model.pkl")
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@ RUN pip3 install torch
|
||||
RUN pip3 install sacred
|
||||
RUN pip3 install GitPython
|
||||
RUN pip3 install pymongo
|
||||
RUN pip3 install mlflow
|
||||
#RUN pip3 install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/#tensorflow-0.12.0-py3-none-any.whl
|
||||
#RUN pip3 install keras
|
||||
RUN apt-get install unzip
|
||||
|
Loading…
Reference in New Issue
Block a user