From 18def2004c25d2514b276245571fb223cbc2c5e0 Mon Sep 17 00:00:00 2001 From: Jakhes <dean.schmitz@schmitzbauer.de> Date: Fri, 21 Oct 2022 16:30:38 +0200 Subject: [PATCH] Updating some of the tests files --- src/helper_files/helper.pl | 7 ++++++- src/methods/adaboost/adaboost_test.pl | 21 +++++++------------ src/methods/linear_SVM/linear_SVM_test.pl | 2 +- src/methods/lmnn/lmnn_test.pl | 2 +- .../local_coordinate_coding_test.pl | 2 +- .../logistic_regression_test.pl | 2 +- src/methods/lsh/lsh_test.pl | 2 +- src/methods/mean_shift/mean_shift_test.pl | 2 +- .../naive_bayes_classifier_test.pl | 2 +- src/methods/nca/nca_test.pl | 2 +- src/methods/nmf/nmf_test.pl | 2 +- src/methods/pca/pca_test.pl | 2 +- src/methods/perceptron/perceptron_test.pl | 2 +- src/methods/radical/radical_test.pl | 2 +- .../random_forest/random_forest_test.pl | 2 +- 15 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/helper_files/helper.pl b/src/helper_files/helper.pl index 85a9f77..e872821 100644 --- a/src/helper_files/helper.pl +++ b/src/helper_files/helper.pl @@ -5,7 +5,8 @@ convert_record_to_arr/2, take_csv_row/3, take_csv_row/4, - convert_float_array_to_2d_list/4]). + convert_float_array_to_2d_list/4, + take_rows_from_iris_CSV/2]). :- use_module(library(structs)). :- use_module(library(csv)). @@ -90,3 +91,7 @@ take_csv_row(File, Count, H) :- append(Out, Rest, H), take_csv_row(File, NewCount, Rest), !. + +take_rows_from_iris_CSV(RowAmount, RowList) :- + open('src/data_csv/iris2.csv', read, File), + take_csv_row(File, skipFirstRow,RowAmount, RowList). diff --git a/src/methods/adaboost/adaboost_test.pl b/src/methods/adaboost/adaboost_test.pl index f65ba55..a2665f7 100644 --- a/src/methods/adaboost/adaboost_test.pl +++ b/src/methods/adaboost/adaboost_test.pl @@ -105,8 +105,7 @@ test(classify_with_bad_data_input_decision_stump) :- %% Successful Tests test(classify_perceptron) :- reset_Model_No_Train(perceptron), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, _), classify([3, 2, 0, 5, 1, 4, 0, 0, 4, 3, 3, 5, 0, 5, 5, 2, 5, 5, 0, 2], 4, [1.0,1.0,1.0,1.0,0.0], @@ -114,8 +113,7 @@ test(classify_perceptron) :- test(classify_decision_stump) :- reset_Model_No_Train(decision_stump), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, decision_stump, 50, 0.0001, _), classify([3, 2, 0, 5, 1, 4, 0, 0, 4, 3, 3, 5, 0, 5, 5, 2, 5, 5, 0, 2], 4, [1.0,1.0,1.0,1.0,1.0], @@ -152,8 +150,7 @@ test(numClasses_Custom_NumClasses, [true(Amount =:= 3)]) :- test(numClasses_afterTrain_Perceptron, [true(Amount =:= 2)]) :- reset_Model_No_Train(perceptron), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, _), numClasses(Amount). @@ -187,8 +184,7 @@ test(getTolerance_Custom_Tolerance, [true(Amount =:= 0.0009)]) :- test(getTolerance_afterTrain, [true(Amount =:= 0.0005)]) :- reset_Model_No_Train(perceptron), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0005, _), getTolerance(Amount). @@ -234,8 +230,7 @@ test(modifyTolerance_Custom_Tolerance, [true(Amount =:= 0.02)]) :- test(modifyTolerance_afterTrain, [true(Amount =:= 0.02)]) :- reset_Model_No_Train(perceptron), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, _), modifyTolerance(0.02), getTolerance(Amount). @@ -300,8 +295,7 @@ test(train_With_Direct_Input_Perceptron, [true(Error =:= 1)]) :- test(train_With_Data_From_CSV_Perceptron, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). test(train_With_Direct_Input_Decision_Stump, [true(Error =:= 1)]) :- @@ -310,8 +304,7 @@ test(train_With_Direct_Input_Decision_Stump, [true(Error =:= 1)]) :- test(train_With_Data_From_CSV_Decision_Stump, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(decision_stump), - open('src/data_csv/iris2.csv', read, File), - take_csv_row(File, skipFirstRow,10, Records), + take_rows_from_iris_CSV(10, Records), train(Records, 4, [0,1,0,1,1,0,1,1,1,0], 2, decision_stump, 50, 0.0001, Error). test(train_After_InitTrain_Perceptron, [true(Error =:= 1)]) :- diff --git a/src/methods/linear_SVM/linear_SVM_test.pl b/src/methods/linear_SVM/linear_SVM_test.pl index 055cfd4..2535dc8 100644 --- a/src/methods/linear_SVM/linear_SVM_test.pl +++ b/src/methods/linear_SVM/linear_SVM_test.pl @@ -45,7 +45,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/lmnn/lmnn_test.pl b/src/methods/lmnn/lmnn_test.pl index 23c98ee..cfa4b4c 100644 --- a/src/methods/lmnn/lmnn_test.pl +++ b/src/methods/lmnn/lmnn_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/local_coordinate_coding/local_coordinate_coding_test.pl b/src/methods/local_coordinate_coding/local_coordinate_coding_test.pl index d62d2a6..5fe6b23 100644 --- a/src/methods/local_coordinate_coding/local_coordinate_coding_test.pl +++ b/src/methods/local_coordinate_coding/local_coordinate_coding_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/logistic_regression/logistic_regression_test.pl b/src/methods/logistic_regression/logistic_regression_test.pl index 41cb4f1..da8651e 100644 --- a/src/methods/logistic_regression/logistic_regression_test.pl +++ b/src/methods/logistic_regression/logistic_regression_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/lsh/lsh_test.pl b/src/methods/lsh/lsh_test.pl index 8461a26..e6eb341 100644 --- a/src/methods/lsh/lsh_test.pl +++ b/src/methods/lsh/lsh_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/mean_shift/mean_shift_test.pl b/src/methods/mean_shift/mean_shift_test.pl index 6914576..43d02d1 100644 --- a/src/methods/mean_shift/mean_shift_test.pl +++ b/src/methods/mean_shift/mean_shift_test.pl @@ -44,7 +44,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/naive_bayes_classifier/naive_bayes_classifier_test.pl b/src/methods/naive_bayes_classifier/naive_bayes_classifier_test.pl index 5ddcc33..351e70f 100644 --- a/src/methods/naive_bayes_classifier/naive_bayes_classifier_test.pl +++ b/src/methods/naive_bayes_classifier/naive_bayes_classifier_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/nca/nca_test.pl b/src/methods/nca/nca_test.pl index 60e83f7..33e4e0b 100644 --- a/src/methods/nca/nca_test.pl +++ b/src/methods/nca/nca_test.pl @@ -34,7 +34,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/nmf/nmf_test.pl b/src/methods/nmf/nmf_test.pl index 04f2c7d..4b132f7 100644 --- a/src/methods/nmf/nmf_test.pl +++ b/src/methods/nmf/nmf_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/pca/pca_test.pl b/src/methods/pca/pca_test.pl index 98b0315..c9ec81f 100644 --- a/src/methods/pca/pca_test.pl +++ b/src/methods/pca/pca_test.pl @@ -45,7 +45,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/perceptron/perceptron_test.pl b/src/methods/perceptron/perceptron_test.pl index e6fb253..e151fa1 100644 --- a/src/methods/perceptron/perceptron_test.pl +++ b/src/methods/perceptron/perceptron_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/radical/radical_test.pl b/src/methods/radical/radical_test.pl index 54e9328..995725b 100644 --- a/src/methods/radical/radical_test.pl +++ b/src/methods/radical/radical_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). diff --git a/src/methods/random_forest/random_forest_test.pl b/src/methods/random_forest/random_forest_test.pl index 908724a..6aa9376 100644 --- a/src/methods/random_forest/random_forest_test.pl +++ b/src/methods/random_forest/random_forest_test.pl @@ -33,7 +33,7 @@ test(testDescription3, [true(Error =:= 1)]) :- test(testDescription4, [true(Error =:= 0.9797958971132711)]) :- reset_Model_No_Train(perceptron), - open('/home/afkjakhes/eclipse-workspace/prolog-mlpack-libary/src/data_csv/iris2.csv', read, File), + open('src/data_csv/iris2.csv', read, File), take_csv_row(File, skipFirstRow,10, Data), train(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, perceptron, 50, 0.0001, Error). -- GitLab