diff --git a/src/helper_files/helper.pl b/src/helper_files/helper.pl index 85a9f7736731d715ba87879840c3f836062c3335..e8728213b420ab995a74429a095b9a8e1b51d231 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 f65ba55c0e7f31c1a9839b84337f60d7b9648079..a2665f773bd702704ecdf5639429254726851d16 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 055cfd4375c7182d6d1bdef8ace9179c3e106a88..2535dc83ec63581d605f973f2132df5e0464f205 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 23c98eec019d70b5de5196a1042c6e5f575f0297..cfa4b4c100e5d27e87fccffd086ff38d659ebeb8 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 d62d2a66eac8db4f5114fbf4ede2df1897093f4c..5fe6b237aed5dd8d06ff3ad85db406abf8a99f84 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 41cb4f1b0bb3cc865c68174658fdc0d6a69df55d..da8651e190a62ec57928d02c557e53dc7ad83518 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 8461a26108ed4ae923925d917bacda406b6ff173..e6eb3417293ad10abcde0f2c29e4980597d48ddd 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 691457642df47e4349de8a3142d6d14ce69b66f2..43d02d1830d6fe5eef037c9d929743a01446c892 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 5ddcc3353a6558155cd2f497a90093559917b41d..351e70fd02fbc08ce40d6b68a98651cfdc955152 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 60e83f78a05c2beb1e69f1447dccddac48d795b8..33e4e0bb567d23d2898e5fb6113a03a1a69d6513 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 04f2c7d6c1e367d4d80115d8bdf0b5481355d8e4..4b132f776c6f97d6c6e260bb4cc8b279adf18bb8 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 98b031573734717ca4f4cbd3d537e3f61928d386..c9ec81f80f63c065f08e3099950964c54e3bff52 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 e6fb253377fab011160714a9bd860c420ac03f78..e151fa1c2a221522beed62316e28beafb4aa6693 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 54e9328b56c6f35aa411a0dec9d0dcd8e41a5a21..995725b2c9ee9af1444f364b2c1d75be4183fdee 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 908724a554e9f7aa845d36bd13d7a995651b4adb..6aa93769fe818e89668a29eebfc5b4e4e11dcddd 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).