Skip to content
Snippets Groups Projects
Commit bb4a353e authored by Jakhes's avatar Jakhes
Browse files

Finishing random_forest tests

parent c22cffb8
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,12 @@ void initModelWithTrainNoWeights(float *dataMatArr, SP_integer dataMatSize, SP_i
{
// convert the Prolog array to arma::mat
mat data = convertArrayToMat(dataMatArr, dataMatSize, dataMatRowNum);
// check if labels fit the data
if (data.n_cols != labelsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of labels!");
return;
}
// convert the Prolog array to arma::rowvec
Row< size_t > labelsVector = convertArrayToVec(labelsArr, labelsArrSize);
......@@ -57,6 +62,11 @@ void initModelWithTrainNoWeights(float *dataMatArr, SP_integer dataMatSize, SP_i
{
randomForest = RandomForest(data, labelsVector, numClasses, numTrees, minimumLeafSize, minimumGainSplit, maximumDepth);
}
catch(const std::out_of_range& e)
{
raisePrologSystemExeption("The given Labels dont fit the format [0,Numclasses-1]!");
return;
}
catch(const std::exception& e)
{
raisePrologSystemExeption(e.what());
......@@ -86,6 +96,18 @@ void initModelWithTrainWithWeights(float *dataMatArr, SP_integer dataMatSize, SP
{
// convert the Prolog array to arma::mat
mat data = convertArrayToMat(dataMatArr, dataMatSize, dataMatRowNum);
// check if labels and weights fit the data
if (data.n_cols != labelsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of labels!");
return;
}
if (data.n_cols != weightsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of weights!");
return;
}
// convert the Prolog array to arma::Row< size_t >
Row< size_t > labelsVector = convertArrayToVec(labelsArr, labelsArrSize);
// convert the Prolog array to arma::rowvec
......@@ -96,6 +118,11 @@ void initModelWithTrainWithWeights(float *dataMatArr, SP_integer dataMatSize, SP
{
randomForest = RandomForest(data, labelsVector, numClasses, weightsVector, numTrees, minimumLeafSize, minimumGainSplit, maximumDepth);
}
catch(const std::out_of_range& e)
{
raisePrologSystemExeption("The given Labels dont fit the format [0,Numclasses-1]!");
return;
}
catch(const std::exception& e)
{
raisePrologSystemExeption(e.what());
......@@ -214,6 +241,12 @@ double trainNoWeights(float *dataMatArr, SP_integer dataMatSize, SP_integer data
{
// convert the Prolog array to arma::mat
mat data = convertArrayToMat(dataMatArr, dataMatSize, dataMatRowNum);
// check if labels fit the data
if (data.n_cols != labelsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of labels!");
return 0.0;
}
// convert the Prolog array to arma::rowvec
Row< size_t > labelsVector = convertArrayToVec(labelsArr, labelsArrSize);
......@@ -222,6 +255,11 @@ double trainNoWeights(float *dataMatArr, SP_integer dataMatSize, SP_integer data
{
return randomForest.Train(data, labelsVector, numClasses, numTrees, minimumLeafSize, minimumGainSplit, maximumDepth);
}
catch(const std::out_of_range& e)
{
raisePrologSystemExeption("The given Labels dont fit the format [0,Numclasses-1]!");
return 0.0;
}
catch(const std::exception& e)
{
raisePrologSystemExeption(e.what());
......@@ -252,6 +290,17 @@ double trainWithWeights(float *dataMatArr, SP_integer dataMatSize, SP_integer da
{
// convert the Prolog arrays to arma::mat
mat data = convertArrayToMat(dataMatArr, dataMatSize, dataMatRowNum);
// check if labels and weights fit the data
if (data.n_cols != labelsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of labels!");
return 0.0;
}
if (data.n_cols != weightsArrSize)
{
raisePrologSystemExeption("The number of data points does not match the number of weights!");
return 0.0;
}
// convert the Prolog arrays to arma::rowvec
Row< size_t > labelsVector = convertArrayToVec(labelsArr, labelsArrSize);
// convert the Prolog arrays to arma::rowvec
......@@ -262,6 +311,11 @@ double trainWithWeights(float *dataMatArr, SP_integer dataMatSize, SP_integer da
{
return randomForest.Train(data, labelsVector, numClasses, weightsVector, numTrees, minimumLeafSize, minimumGainSplit, maximumDepth);
}
catch(const std::out_of_range& e)
{
raisePrologSystemExeption("The given Labels dont fit the format [0,Numclasses-1]!");
return 0.0;
}
catch(const std::exception& e)
{
raisePrologSystemExeption(e.what());
......
......@@ -38,8 +38,6 @@ test(random_forest_InitModelNoTrain) :-
test(random_forest_InitModelWithTrainNoWeights_Negative_NumClasses, fail) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], -2, 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainNoWeights_Too_Many_NumClasses, fail) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 15, 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainNoWeights_Negative_NumTrees, fail) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, -20, 1, 0.0000001, 0).
......@@ -54,13 +52,13 @@ test(random_forest_InitModelWithTrainNoWeights_Negative_MaxDepth, fail) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, 20, 1, 0.0000001, -1).
test(random_forest_InitModelWithTrainNoWeights_Too_Short_Label, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainNoWeights_Too_Short_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1], 2, 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainNoWeights_Too_Long_Label, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainNoWeights_Too_Long_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1,0,1], 2, 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainNoWeights_Too_Many_Label_Classes, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainNoWeights_Too_Many_Label_Classes, [error(_,system_error('The given Labels dont fit the format [0,Numclasses-1]!'))]) :-
initModelWithTrainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,2,3], 2, 20, 1, 0.0000001, 0).
......@@ -88,9 +86,6 @@ test(random_forest_InitModelWithTrainNoWeights_CSV_Input) :-
test(random_forest_InitModelWithTrainWithWeights_Negative_NumClasses, fail) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], -2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Many_NumClasses, fail) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 15, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Negative_NumTrees, fail) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2], -20, 1, 0.0000001, 0).
......@@ -104,25 +99,22 @@ test(random_forest_InitModelWithTrainWithWeights_Negative_MaxDepth, fail) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, -1).
test(random_forest_InitModelWithTrainWithWeights_Too_Short_Label, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainWithWeights_Too_Short_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Long_Label, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainWithWeights_Too_Long_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1,0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Many_Label_Classes, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainWithWeights_Too_Many_Label_Classes, [error(_,system_error('The given Labels dont fit the format [0,Numclasses-1]!'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,2,3], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Short_Weights, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainWithWeights_Too_Short_Weights, [error(_,system_error('The number of data points does not match the number of weights!'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Long_Weights, [error(_,system_error('Error'))]) :-
test(random_forest_InitModelWithTrainWithWeights_Too_Long_Weights, [error(_,system_error('The number of data points does not match the number of weights!'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2,0.43,2.0], 20, 1, 0.0000001, 0).
test(random_forest_InitModelWithTrainWithWeights_Too_Many_Weights_Classes, [error(_,system_error('Error'))]) :-
initModelWithTrainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [-0.5,0.1,-0.7,1.2], 20, 1, 0.0000001, 0).
%% Successful Tests
......@@ -132,7 +124,7 @@ test(random_forest_InitModelWithTrainWithWeights_Normal_Use) :-
test(random_forest_InitModelWithTrainWithWeights_CSV_Input) :-
open('src/data_csv/iris2.csv', read, File),
take_csv_row(File, skipFirstRow,10, Data),
initModelWithTrainWithWeights(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0).
initModelWithTrainWithWeights(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, [0.5,0.1,0.7,1.2,0.5,3.4,0.9,0.5,0.5,1.2], 20, 1, 0.0000001, 0).
:- end_tests(initModelWithTrainWithWeights).
......@@ -145,17 +137,27 @@ test(random_forest_InitModelWithTrainWithWeights_CSV_Input) :-
%% Failure Tests
test(random_forest_ClassifyPoint_Before_Train, [error(_,system_error('Error'))]) :-
test(random_forest_ClassifyPoint_Before_Train, [error(_,system_error('RandomForest::Classify(): no random forest trained!'))]) :-
reset_Model_NoTrain,
classifyPoint([5.1,3.5,1.4], _, _).
test(random_forest_ClassifyPoint_Smaller_Dim_To_Train, [error(_,system_error('Error'))]) :-
%% Point dim seems to not matter
test(random_forest_ClassifyPoint_Smaller_Dim_To_Train) :-
reset_Model_WithTrain,
classifyPoint([5.1,3.5], _, _).
classifyPoint([5.1,3.5], Prediction, ProbabilitiesList),
print('\nPrediction: '),
print(Prediction),
print('\nProbabilities: '),
print(ProbabilitiesList).
test(random_forest_ClassifyPoint_Larger_Dim_To_Train, [error(_,system_error('Error'))]) :-
%% Point dim seems to not matter
test(random_forest_ClassifyPoint_Larger_Dim_To_Train) :-
reset_Model_WithTrain,
classifyPoint([5.1,3.5,1.4,4.3,0.4], _, _).
classifyPoint([5.1,3.5,1.4,4.3,0.4], Prediction, ProbabilitiesList),
print('\nPrediction: '),
print(Prediction),
print('\nProbabilities: '),
print(ProbabilitiesList).
%% Successful Tests
......@@ -179,17 +181,27 @@ test(random_forest_ClassifyPoint_Normal_Use) :-
%% Failure Tests
test(random_forest_ClassifyMatrix_Before_Train, [error(_,system_error('Error'))]) :-
test(random_forest_ClassifyMatrix_Before_Train, [error(_,system_error('RandomForest::Classify(): no random forest trained!'))]) :-
reset_Model_NoTrain,
classifyMatrix([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, _, _, _).
test(random_forest_ClassifyMatrix_Smaller_Dim_To_Train, [error(_,system_error('Error'))]) :-
%% Classify dim seems to not matter
test(random_forest_ClassifyMatrix_Smaller_Dim_To_Train) :-
reset_Model_WithTrain,
classifyMatrix([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 4, _, _, _).
classifyMatrix([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 4, Prediction, ProbabilitiesList, _),
print('\nPrediction: '),
print(Prediction),
print('\nProbabilities: '),
print(ProbabilitiesList).
test(random_forest_ClassifyMatrix_Larger_Dim_To_Train, [error(_,system_error('Error'))]) :-
%% Classify dim seems to not matter
test(random_forest_ClassifyMatrix_Larger_Dim_To_Train) :-
reset_Model_WithTrain,
classifyMatrix([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 2, _, _, _).
classifyMatrix([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 2, Prediction, ProbabilitiesList, _),
print('\nPrediction: '),
print(Prediction),
print('\nProbabilities: '),
print(ProbabilitiesList).
%% Successful Tests
......@@ -207,15 +219,18 @@ test(random_forest_ClassifyMatrix_Normal_Use) :-
%%
%% TESTING predicate numTrees/10
%% TESTING predicate numTrees/1
%%
:- begin_tests(numTrees).
%% Failure Tests
test(random_forest_NumTrees_Before_Train, [error(_,system_error('Error'))]) :-
%% doesnt cause an error
test(random_forest_NumTrees_Before_Train) :-
reset_Model_NoTrain,
numTrees(_).
numTrees(NumTrees),
print('\nNumber of Trees: '),
print(NumTrees).
%% Successful Tests
......@@ -231,7 +246,7 @@ test(random_forest_NumTrees_Normal_Use) :-
%%
%% TESTING predicate trainNoWeights/10
%% TESTING predicate trainNoWeights/9
%%
:- begin_tests(trainNoWeights).
......@@ -241,10 +256,6 @@ test(random_forest_TrainNoWeights_Negative_NumClasses, fail) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], -2, 20, 1, 0.0000001, 0, _).
test(random_forest_TrainNoWeights_Too_Many_NumClasses, fail) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 15, 20, 1, 0.0000001, 0, _).
test(random_forest_TrainNoWeights_Negative_NumTrees, fail) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, -20, 1, 0.0000001, 0, _).
......@@ -262,15 +273,15 @@ test(random_forest_TrainNoWeights_Negative_MaxDepth, fail) :-
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, 20, 1, 0.0000001, -1, _).
test(random_forest_TrainNoWeights_Too_Short_Label, [error(_,system_error('Error'))]) :-
test(random_forest_TrainNoWeights_Too_Short_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1], 2, 20, 1, 0.0000001, 0, _).
test(random_forest_TrainNoWeights_Too_Long_Label, [error(_,system_error('Error'))]) :-
test(random_forest_TrainNoWeights_Too_Long_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1,0,1], 2, 20, 1, 0.0000001, 0, _).
test(random_forest_TrainNoWeights_Too_Many_Label_Classes, [error(_,system_error('Error'))]) :-
test(random_forest_TrainNoWeights_Too_Many_Label_Classes, [error(_,system_error('The given Labels dont fit the format [0,Numclasses-1]!'))]) :-
reset_Model_NoTrain,
trainNoWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,2,3], 2, 20, 1, 0.0000001, 0, _).
......@@ -306,10 +317,6 @@ test(random_forest_TrainWithWeights_Negative_NumClasses, fail) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], -2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Many_NumClasses, fail) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 15, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Negative_NumTrees, fail) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2], -20, 1, 0.0000001, 0, _).
......@@ -327,31 +334,27 @@ test(random_forest_TrainWithWeights_Negative_MaxDepth, fail) :-
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, -1, _).
test(random_forest_TrainWithWeights_Too_Short_Label, [error(_,system_error('Error'))]) :-
test(random_forest_TrainWithWeights_Too_Short_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Long_Label, [error(_,system_error('Error'))]) :-
test(random_forest_TrainWithWeights_Too_Long_Label, [error(_,system_error('The number of data points does not match the number of labels!'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1,0,1], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Many_Label_Classes, [error(_,system_error('Error'))]) :-
test(random_forest_TrainWithWeights_Too_Many_Label_Classes, [error(_,system_error('The given Labels dont fit the format [0,Numclasses-1]!'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,2,3], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Short_Weights, [error(_,system_error('Error'))]) :-
test(random_forest_TrainWithWeights_Too_Short_Weights, [error(_,system_error('The number of data points does not match the number of weights!'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Long_Weights, [error(_,system_error('Error'))]) :-
test(random_forest_TrainWithWeights_Too_Long_Weights, [error(_,system_error('The number of data points does not match the number of weights!'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [0.5,0.1,0.7,1.2,0.43,2.0], 20, 1, 0.0000001, 0, _).
test(random_forest_TrainWithWeights_Too_Many_Weights_Classes, [error(_,system_error('Error'))]) :-
reset_Model_NoTrain,
trainWithWeights([5.1,3.5,1.4,4.9,3.0,1.4,4.7,3.2,1.3,4.6,3.1,1.5], 3, [0,1,0,1], 2, [-0.5,0.1,-0.7,1.2], 20, 1, 0.0000001, 0, _).
%% Successful Tests
......@@ -365,7 +368,7 @@ test(random_forest_TrainWithWeights_CSV_Input) :-
reset_Model_NoTrain,
open('src/data_csv/iris2.csv', read, File),
take_csv_row(File, skipFirstRow,10, Data),
trainWithWeights(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, [0.5,0.1,0.7,1.2], 20, 1, 0.0000001, 0, Entropy),
trainWithWeights(Data, 4, [0,1,0,1,1,0,1,1,1,0], 2, [0.5,0.1,0.7,1.2,0.5,3.4,0.9,0.5,0.5,1.2], 20, 1, 0.0000001, 0, Entropy),
print('\nEntropy: '),
print(Entropy).
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment