Commit 769e96af authored by Guillaume HEUSCH's avatar Guillaume HEUSCH

added data normalization to prevent libSVM sparse format to crash

parent 172d46e0
Pipeline #24451 passed with stage
in 10 minutes and 31 seconds
......@@ -277,6 +277,13 @@ class SVM(Algorithm):
machine = trainer.train(data) # train the machine
# TODO: find a proper way to handle this - Guillaume HEUSCH, 08-08-2018
if machine.shape[0] != data[0].shape[1]:
data[0] += 1
data[1] += 1
machine = trainer.train(data) # train the machine
precision_cv = self.comp_prediction_precision(
machine, np.copy(real_cv), np.copy(attack_cv))
......@@ -370,6 +377,12 @@ class SVM(Algorithm):
machine = trainer.train(data) # train the machine
# TODO: find a proper way to handle this - Guillaume HEUSCH, 08-08-2018
if machine.shape[0] != data[0].shape[1]:
data[0] += 1
data[1] += 1
machine = trainer.train(data) # train the machine
if mean_std_norm_flag:
machine.input_subtract = features_mean # subtract the mean of train data
machine.input_divide = features_std # divide by std of train data
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment