Skip to content

Commit

Permalink
Merge pull request #12 from dmonllao/MDL-58992_master
Browse files Browse the repository at this point in the history
MDL-58992 analytics: extend Classifier for  multiclassification
  • Loading branch information
David Monllaó authored Sep 11, 2019
2 parents c81e533 + e245d07 commit 7924426
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 176 deletions.
2 changes: 1 addition & 1 deletion moodlemlbackend/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0
2.1.0
5 changes: 3 additions & 2 deletions moodlemlbackend/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ def evaluation():

modelid = sys.argv[1]
directory = sys.argv[2]
dataset = sys.argv[3]

binary_classifier = estimator.Binary(modelid, directory)
classifier = estimator.Classifier(modelid, directory, dataset)

if len(sys.argv) > 7:
trained_model_dir = sys.argv[7]
else:
trained_model_dir = False

result = binary_classifier.evaluate_dataset(sys.argv[3],
result = classifier.evaluate_dataset(dataset,
float(sys.argv[4]),
float(sys.argv[5]),
int(sys.argv[6]),
Expand Down
4 changes: 2 additions & 2 deletions moodlemlbackend/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def export_classifier():
modelid = sys.argv[1]
directory = sys.argv[2]

binary_classifier = estimator.Binary(modelid, directory)
exportdir = binary_classifier.export_classifier(sys.argv[3])
classifier = estimator.Classifier(modelid, directory)
exportdir = classifier.export_classifier(sys.argv[3])
if exportdir:
print(exportdir)
sys.exit(0)
Expand Down
5 changes: 3 additions & 2 deletions moodlemlbackend/import.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ def import_classifier():
modelid = sys.argv[1]
directory = sys.argv[2]

binary_classifier = estimator.Binary(modelid, directory)
binary_classifier.import_classifier(sys.argv[3])
classifier = estimator.Classifier(modelid, directory)
classifier.import_classifier(sys.argv[3])

print('Ok')
# An exception will be thrown before if it can be imported.
sys.exit(0)

Expand Down
5 changes: 4 additions & 1 deletion moodlemlbackend/model/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ def set_tensor_logdir(self, tensor_logdir):

def build_graph(self, initial_weights=False):
"""Builds the computational graph without feeding any data in"""
print(type(initial_weights))
# Placeholders for input values.
with tf.name_scope('inputs'):
self.x = tf.placeholder(
Expand Down Expand Up @@ -181,6 +180,10 @@ def get_n_features(self):
"""Return the number of features"""
return self.n_features

def get_n_classes(self):
"""Return the number of features"""
return self.n_classes

def fit(self, X, y):
"""Fits provided data into the session"""

Expand Down
5 changes: 3 additions & 2 deletions moodlemlbackend/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ def prediction():

modelid = sys.argv[1]
directory = sys.argv[2]
dataset = sys.argv[3]

# TensorFlow binary classifier - NN.
binary_classifier = estimator.Binary(modelid, directory)
classifier = estimator.Classifier(modelid, directory, dataset)

result = binary_classifier.predict_dataset(sys.argv[3])
result = classifier.predict_dataset(dataset)

print(json.dumps(result))
sys.exit(result['status'])
Expand Down
Loading

0 comments on commit 7924426

Please sign in to comment.