-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now the main function is very clear and runs everything
Showing
12 changed files
with
71 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import os | ||
import pickle | ||
from yaml_tools import read_yaml_from_file | ||
from config.ml_models import classifiers | ||
from find_filename import find_dataset_filename | ||
from find_filename import find_hyperparams_filename | ||
from find_filename import find_model_filename | ||
|
||
|
||
def train_model(ml_model, method): | ||
train_data_file = os.path.join(os.path.dirname(__file__), | ||
'datasets', 'train', | ||
f'{method}_train_dataset.txt') | ||
hyperparams_file = os.path.join(os.path.dirname(__file__), | ||
'config', 'hyperparams', | ||
f'{method}_{ml_model}') | ||
with open(train_data_file, 'rb') as f: | ||
method_x_train, method_y_train = pickle.load(f) | ||
hyperparams = read_yaml_from_file(hyperparams_file) | ||
current_classifier = classifiers[ml_model] | ||
clf = current_classifier(**hyperparams) | ||
clf.fit(method_x_train, method_y_train) | ||
|
||
|
||
# print(train_model(ml_models[1], dataset_types[0])) | ||
train_data_filename = find_dataset_filename('train', method=method) | ||
hyperparams_file = find_hyperparams_filename(method, ml_model) | ||
with open(train_data_filename, 'rb') as train_data_file: | ||
x_train, y_train = pickle.load(train_data_file) | ||
hyperparams = read_yaml_from_file(hyperparams_file) | ||
current_classifier = classifiers[ml_model] | ||
clf = current_classifier(**hyperparams) | ||
clf.fit(x_train, y_train) | ||
trained_model_filename = find_model_filename(method, ml_model) | ||
with open(trained_model_filename, 'wb') as trained_model_file: | ||
pickle.dump(clf, trained_model_file) |