Skip to content
Snippets Groups Projects
Commit 4919b94e authored by a.croix's avatar a.croix
Browse files

Fix error in prepareFolds method

parent fa2543ec
No related branches found
No related tags found
1 merge request!3K fold
Pipeline #1757 passed
......@@ -63,10 +63,10 @@ public final class Example {
Trainer trainer = new Trainer(parameters, new SolutionDistance(5));
long start_time = System.currentTimeMillis();
AbstractSolution solution = trainer.run(
"./ressources/webshell_data.json",
"./ressources/webshell_expected.json");
System.out.println(solution);
//AbstractSolution solution = trainer.run(
// "./ressources/webshell_data.json",
// "./ressources/webshell_expected.json");
//System.out.println(solution);
long end_time = System.currentTimeMillis();
logger.log(Level.INFO, "Execution time : "
+ (end_time - start_time) / 1000 + " seconds");
......
......@@ -188,8 +188,9 @@ public class Trainer {
TrainingDataset tmp = new TrainingDataset();
int alert_counter = 0;
int no_alert_counter = 0;
while (tmp.getLength() < (alert_counter + no_alert_counter)) {
int index = Utils.randomInteger(0, dataset.getLength());
System.out.println("Fold " + i);
while (tmp.getLength() < (alert_number + no_alert_number)) {
int index = Utils.randomInteger(0, dataset.getLength() - 1);
if (dataset.getExpected().get(index) == 1
&& alert_counter < alert_number) {
tmp.addElementInDataset(dataset, index);
......
......@@ -108,11 +108,12 @@ class TrainingDataset {
* @param data_to_add
* @param index
*/
void addFoldInDataset(
TrainingDataset addFoldInDataset(
final List<TrainingDataset> data_to_add,
final int index) {
this.data.addAll(data_to_add.get(index).data);
this.expected.addAll(data_to_add.get(index).expected);
this.length++;
return this;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment