Skip to content
Snippets Groups Projects
Commit 99293857 authored by Dean Samuel Schmitz's avatar Dean Samuel Schmitz
Browse files

Updating documentation

parent 4750257f
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ void initModelNoTraining(double tol = 1e-6, char const *learner = "perceptron")
// arma::mat & probabilities
// output:
// description:
void classifyWithProb(float *testMatArr, SP_integer testMatSize, SP_integer testMatRowNum, float **predLabelsArr, SP_integer *predLabelsArrSize, float **probMatArr, SP_integer *probMatColNum, SP_integer *probMatRowNum)
void classify(float *testMatArr, SP_integer testMatSize, SP_integer testMatRowNum, float **predLabelsArr, SP_integer *predLabelsArrSize, float **probMatArr, SP_integer *probMatColNum, SP_integer *probMatRowNum)
{
// convert the Prolog arrays to arma::mat
mat data = convertArrayToMat(testMatArr, testMatSize, testMatRowNum);
......@@ -121,37 +121,6 @@ void classifyWithProb(float *testMatArr, SP_integer testMatSize, SP_integer test
*probMatArr = convertToArray(probMat);
}
// TODO:
// input: const MatType & test,
// arma::Row< size_t > & predictedLabels
// output:
// description:
void classifyNoProb(float *testMatArr, SP_integer testMatSize, SP_integer testMatRowNum, float **predLabelsArr, SP_integer *predLabelsArrSize)
{
// convert the Prolog arrays to arma::mat
mat data = convertArrayToMat(testMatArr, testMatSize, testMatRowNum);
// get the ReturnVector
Row< size_t > predLabelsVector;
if(usingPerceptron)
{
adaBoostPerceptron.Classify(data, predLabelsVector);
}
else
{
adaBoostDecisionStump.Classify(data, predLabelsVector);
}
vec convPredLabels = conv_to<vec>::from(predLabelsVector);
// return the Vector lenght
*predLabelsArrSize = convPredLabels.n_elem;
// return the Vector as Array
*predLabelsArr = convertToArray(convPredLabels);
}
// TODO:
// input:
// output: size_t classesNum
......
:- module(ada_boost, [ initModelWithTraining/9,
initModelNoTraining/2,
classifyWithProb/8,
classifyNoProb/5,
classify/8,
numClasses/1,
getTolerance/1,
modifyTolerance/1,
......@@ -22,75 +22,114 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% mat data,
%% vec labels,
%% int numClasses,
%% string learner => “decision_stump”, “perceptron”,
%% int iterations => 100,
%% float tolerance => 1e-6
%%
%% --Output--
%%
%% --Description--
foreign(initModelWithTraining, c, initModelWithTraining(+pointer(float_array), +integer, +integer, +pointer(float_array), +integer, +integer, +string, +integer , +float32)).
%% TODO:
%% --Input--
%% Needs to be called first before all other predicates exept initModelNoTraining!
%%
%% --Output--
%% Initiates the Adaboostmodel and trains it, so classify can be used immediately.
%%
%% --Description--
foreign(initModelNoTraining, c, initModelNoTraining(+float32, +string)).
foreign(initModelWithTraining, c, initModelWithTraining(+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
+string,
+integer , +float32)).
%% TODO:
%% --Input--
%% string learner => “decision_stump”, “perceptron”,
%% float tolerance => 1e-6
%%
%% --Output--
%%
%% --Description--
foreign(classifyWithProb, c, classifyWithProb(+pointer(float_array), +integer, +integer, -pointer(float_array), -integer, -pointer(float_array), -integer, -integer)).
%% Needs to be called first before all other predicates exept initModelWithTraining!
%% Initiates the Adaboostmodel but doesn’t train it, so train has to be used first before classify can be used.
%%
foreign(initModelNoTraining, c, initModelNoTraining(+float32, +string)).
%% TODO:
%% --Input--
%% mat test,
%%
%% --Output--
%% vec predictions,
%% mat probabilities
%%
%% --Description--
foreign(classifyNoProb, c, classifyNoProb(+pointer(float_array), +integer, +integer, -pointer(float_array), -integer)).
%% Classifies the given data into the number of classes the model was trained for.
%%
foreign(classify, c, classify( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer, -integer)).
%% TODO:
%% --Input--
%%
%% --Output--
%% float classesNum
%%
%% --Description--
%% Returns the amount of classes defined in the model for classification.
%%
foreign(numClasses, c, numClasses([-integer])).
%% TODO:
%% --Input--
%%
%% --Output--
%% float tolerance
%%
%% --Description--
%% Returns the tolerance of the model.
%%
foreign(getTolerance, c, getTolerance([-float32])).
%% TODO:
%% --Input--
%% float newTolerance
%%
%% --Output--
%%
%% --Description--
%% Modifies the tolerance of the model.
%%
foreign(modifyTolerance, c, modifyTolerance(+float32)).
%% TODO:
%% --Input--
%% mat data,
%% vec labels,
%% int numClasses,
%% string learner => “decision_stump”, “perceptron”,
%% int iterations => 100,
%% float tolerance => 1e-6
%%
%% --Output--
%% float double upper bound training error
%%
%% --Description--
foreign(train, c, train(+pointer(float_array), +integer, +integer, +pointer(float_array), +integer, +integer, +string, +integer , +float32, [-float32])).
foreign(train, c, train( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
+string,
+integer , +float32,
[-float32])).
%% Defines the functions that get connected from main.cpp
foreign_resource(ada_boost, [ initModelWithTraining,
initModelNoTraining,
classifyWithProb,
classifyNoProb,
classify,
numClasses,
getTolerance,
modifyTolerance,
......
:- module(approx_kfn, [ initDrusillaModelNoTrain/2,
initDrusillaModelWithTrain/5,
searchDrusilla/10,
......@@ -22,7 +23,7 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% int l,
%% int m
......@@ -30,9 +31,12 @@
%% --Output--
%%
%% --Description--
%% Initiates the DrusillaSearch Model but doesn’t train it.
%% trainDrusilla has to be used before searchDrusilla can be used.
%%
foreign(initDrusillaModelNoTrain, c, initDrusillaModelNoTrain(+integer, +integer)).
%% TODO:
%% --Input--
%% mat referenceSet,
%% int l,
......@@ -41,9 +45,13 @@ foreign(initDrusillaModelNoTrain, c, initDrusillaModelNoTrain(+integer, +integer
%% --Output--
%%
%% --Description--
foreign(initDrusillaModelWithTrain, c, initDrusillaModelWithTrain(+pointer(float_array), +integer, +integer, +integer, +integer)).
%% Initiates the DrusillaSearch Model and trains it with the given reference Set.
%% Afterwards searchDrusilla can be used.
%%
foreign(initDrusillaModelWithTrain, c, initDrusillaModelWithTrain( +pointer(float_array), +integer, +integer,
+integer, +integer)).
%% TODO:
%% --Input--
%% mat querySet,
%% int k
......@@ -53,9 +61,14 @@ foreign(initDrusillaModelWithTrain, c, initDrusillaModelWithTrain(+pointer(float
%% mat distances
%%
%% --Description--
foreign(searchDrusilla, c, searchDrusilla(+pointer(float_array), +integer, +integer, +integer, -pointer(float_array), -integer, -integer, -pointer(float_array), -integer, -integer)).
%%
%%
foreign(searchDrusilla, c, searchDrusilla( +pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)).
%% TODO:
%% --Input--
%% mat referenceSet,
%% int l => 0,
......@@ -64,9 +77,12 @@ foreign(searchDrusilla, c, searchDrusilla(+pointer(float_array), +integer, +inte
%% --Output--
%%
%% --Description--
foreign(trainDrusilla, c, trainDrusilla(+pointer(float_array), +integer, +integer, +integer, +integer)).
%% Trains the DrusillaSearch Model with the given reference Set.
%%
foreign(trainDrusilla, c, trainDrusilla(+pointer(float_array), +integer, +integer,
+integer, +integer)).
%% TODO:
%% --Input--
%% int l,
%% int m
......@@ -74,9 +90,12 @@ foreign(trainDrusilla, c, trainDrusilla(+pointer(float_array), +integer, +intege
%% --Output--
%%
%% --Description--
%% Initiates the QDAFNSearch Model but doesn’t train it.
%% trainQDAFN has to be used before searchQDAFN can be used.
%%
foreign(initQDAFNModelNoTrain, c, initQDAFNModelNoTrain(+integer, +integer)).
%% TODO:
%% --Input--
%% mat referenceSet,
%% int l,
......@@ -85,9 +104,13 @@ foreign(initQDAFNModelNoTrain, c, initQDAFNModelNoTrain(+integer, +integer)).
%% --Output--
%%
%% --Description--
foreign(initQDAFNModelWithTrain, c, initQDAFNModelWithTrain(+pointer(float_array), +integer, +integer, +integer, +integer)).
%% Initiates the QDAFNSearch Model and trains it with the given reference Set.
%% Afterwards searchQDAFN can be used.
%%
foreign(initQDAFNModelWithTrain, c, initQDAFNModelWithTrain( +pointer(float_array), +integer, +integer,
+integer, +integer)).
%% TODO:
%% --Input--
%% mat querySet,
%% int k
......@@ -97,7 +120,12 @@ foreign(initQDAFNModelWithTrain, c, initQDAFNModelWithTrain(+pointer(float_array
%% mat distances
%%
%% --Description--
foreign(searchQDAFN, c, searchQDAFN(+pointer(float_array), +integer, +integer, +integer, -pointer(float_array), -integer, -integer, -pointer(float_array), -integer, -integer)).
%%
%%
foreign(searchQDAFN, c, searchQDAFN( +pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)).
%% TODO:
%% --Input--
......@@ -108,7 +136,10 @@ foreign(searchQDAFN, c, searchQDAFN(+pointer(float_array), +integer, +integer, +
%% --Output--
%%
%% --Description--
foreign(trainQDAFN, c, trainQDAFN(+pointer(float_array), +integer, +integer, +integer, +integer)).
%% Trains the QDAFNSearch Model with the given reference Set.
%%
foreign(trainQDAFN, c, trainQDAFN( +pointer(float_array), +integer, +integer,
+integer, +integer)).
%% Defines the functions that get connected from main.cpp
......
......@@ -29,8 +29,13 @@
%% mat centroids => cent(float_array), centColNum, centRowNum
%%
%% --Description--
foreign(dbscan, c, dbscan(+float32, +integer, +integer, +string, +string, +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer, -pointer(float_array), -integer, -integer)).
%% This is a one predicate model where you configure the model with the input parameters and get returned the results in the same predicate.
%%
foreign(dbscan, c, dbscan( +float32, +integer, +integer,
+string, +string,
+pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer, -integer)).
%% Defines the functions that get connected from main.cpp
......
:- module(decision_tree, [ initModel/9,
classifyPoint/5,
classifyMatrix/7,
......@@ -18,7 +19,7 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% mat dataset,
%% vec labels,
......@@ -30,11 +31,14 @@
%% --Output--
%%
%% --Description--
%% Construct the decision tree on the given data and labels, assuming that the data is all of the numeric type.
%% Setting minimumLeafSize and minimumGainSplit too small may cause the tree to overfit, but setting them too large may cause it to underfit.
%%
foreign(initModel, c, initModel( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer, +integer, +float32, +integer)).
%% TODO:
%% --Input--
%% vec point
%%
......@@ -43,11 +47,13 @@ foreign(initModel, c, initModel( +pointer(float_array), +integer, +intege
%% vec probabilities
%%
%% --Description--
%% Classify the given point and also return estimates of the probability for each class in the given vector.
%%
foreign(classifyPoint, c, classifyPoint(+pointer(float_array), +integer,
-integer,
-pointer(float_array), -integer)).
%% TODO:
%% --Input--
%% mat data
%%
......@@ -56,11 +62,13 @@ foreign(classifyPoint, c, classifyPoint(+pointer(float_array), +integer,
%% vec probabilities
%%
%% --Description--
%% Classify the given points and also return estimates of the probabilities for each class in the given matrix.
%%
foreign(classifyMatrix, c, classifyMatrix( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer)).
%% TODO:
%% --Input--
%% mat data,
%% vec labels,
......@@ -73,6 +81,9 @@ foreign(classifyMatrix, c, classifyMatrix( +pointer(float_array), +integer,
%% float32 final entropy of decision tree
%%
%% --Description--
%% Train the decision tree on the given data, assuming that all dimensions are numeric.
%% This will overwrite the given model. Setting minimumLeafSize and minimumGainSplit too small may cause the tree to overfit, but setting them too large may cause it to underfit.
%%
foreign(train, c, train(+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer, +integer, +float32, +integer,
......
:- module(emst, [emst/7]).
%% requirements of library(struct)
......@@ -17,28 +18,19 @@
%% TODO:
%% --Input--
%% mat dataset,
%% bool naive => (1)true / (0)false
%%
%% --Output--
%% mat result
%%
%% --Description--
foreign(emst, c, emst(+pointer(float_array), +integer, +integer, +integer, -pointer(float_array), -integer, -integer)).
%% +integer , +float32, +string
%% [-integer] , [-float32], [-string]
%% matrix input
%% +pointer(float_array), +integer, +integer
%% array input
%% +pointer(float_array), +integer
%% matrix return
%% -pointer(float_array), -integer, -integer
%% Performs the MST calculation using the Dual-Tree Boruvka algorithm.
%%
foreign(emst, c, emst( +pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer)).
%% array return
%% -pointer(float_array), -integer
%% Defines the functions that get connected from main.cpp
foreign_resource(emst, [emst]).
......
:- module(fastmks, [ initModel/11,
searchWithQuery/11,
searchNoQuery/7]).
......@@ -17,7 +18,7 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% mat referenceData,
%% string kernel "linear", "polynomial", "cosine", "gaussian", "epanechnikov", "triangular", "hyptan"
......@@ -32,9 +33,15 @@
%% --Output--
%%
%% --Description--
foreign(initModel, c, initModel(+pointer(float_array), +integer, +integer, +string, +float32, +float32, +float32, +float32, +integer, +integer, +float32)).
%% Initializes the model on the given reference set.
%%
foreign(initModel, c, initModel(+pointer(float_array), +integer, +integer,
+string,
+float32, +float32, +float32, +float32,
+integer, +integer,
+float32)).
%% TODO:
%% --Input--
%% mat querySet,
%% int k,
......@@ -45,9 +52,15 @@ foreign(initModel, c, initModel(+pointer(float_array), +integer, +integer, +stri
%% mat kernels
%%
%% --Description--
foreign(searchWithQuery, c, searchWithQuery(+pointer(float_array), +integer, +integer, +integer, -pointer(float_array), -integer, -integer, -pointer(float_array), -integer, -integer, +float32)).
%% Search with a different query set.
%%
foreign(searchWithQuery, c, searchWithQuery( +pointer(float_array), +integer, +integer,
+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer,
+float32)).
%% TODO:
%% --Input--
%% int k
%%
......@@ -56,7 +69,11 @@ foreign(searchWithQuery, c, searchWithQuery(+pointer(float_array), +integer, +in
%% mat kernels
%%
%% --Description--
foreign(searchNoQuery, c, searchNoQuery(+integer, -pointer(float_array), -integer, -integer, -pointer(float_array), -integer, -integer)).
%% Search with the reference set as the query set.
%%
foreign(searchNoQuery, c, searchNoQuery(+integer,
-pointer(float_array), -integer, -integer,
-pointer(float_array), -integer, -integer)).
%% Defines the functions that get connected from main.cpp
......
:- module(hoeffding_tree, [ initAndBuildModel/14,
classify/7,
train/6]).
......@@ -17,7 +18,7 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% string treeType => "gini-hoeffding", "gini-binary", "info-hoeffding", "info-binary",
%% mat dataset,
......@@ -34,12 +35,15 @@
%% --Output--
%%
%% --Description--
%% Construct the Hoeffding tree with the given parameters and given training data.
%% The tree may be trained either in batch mode (which looks at all points before splitting, and propagates these points to the created children for further training), or in streaming mode, where each point is only considered once. (In general, batch mode will give better-performing trees, but will have higher memory and runtime costs for the same dataset.)
%%
foreign(initAndBuildModel, c, initAndBuildModel(+string,
+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer, +integer, +float32, +integer, +integer, +integer, +integer, +integer)).
%% TODO:
%% --Input--
%% mat data
%%
......@@ -48,11 +52,14 @@ foreign(initAndBuildModel, c, initAndBuildModel(+string,
%% vec probabilities
%%
%% --Description--
%% Classify the given points, using this node and the entire (sub)tree beneath it.
%% The predicted labels for each point are returned, as well as an estimate of the probability that the prediction is correct for each point. This estimate is simply the MajorityProbability for the leaf that each point bins to.
%%
foreign(classify, c, classify( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer)).
%% TODO:
%% --Input--
%% mat data,
%% vec labels,
......@@ -61,6 +68,9 @@ foreign(classify, c, classify( +pointer(float_array), +integer, +integer,
%% --Output--
%%
%% --Description--
%% Train in streaming mode on the given dataset.
%% This takes one pass. Be sure that initAndBuildModel/14 has been called first!
%%
foreign(train, c, train(+pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer)).
......
:- module(kde, [ initAndBuildModel/14,
evaluateWithQuery/5,
evaluateNoQuery/2]).
......@@ -18,7 +19,6 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% float32 bandwidth => 1.0,
%% float32 relError => 0.05,
......@@ -36,9 +36,15 @@
%% --Output--
%%
%% --Description--
foreign(initAndBuildModel, c, initAndBuildModel(+float32, +float32, +float32, +string, +string, +string, +integer, +float32, +integer, +float32, +float32, +pointer(float_array), +integer, +integer)).
%% Build the KDE model with the given parameters and then trains it with the given reference data.
%%
foreign(initAndBuildModel, c, initAndBuildModel(+float32, +float32, +float32,
+string, +string, +string,
+integer,
+float32, +integer, +float32, +float32,
+pointer(float_array), +integer, +integer)).
%% TODO:
%% --Input--
%% mat querySet
%%
......@@ -46,15 +52,23 @@ foreign(initAndBuildModel, c, initAndBuildModel(+float32, +float32, +float32, +s
%% vec estimations
%%
%% --Description--
foreign(evaluateWithQuery, c, evaluateWithQuery(+pointer(float_array), +integer, +integer, -pointer(float_array), -integer)).
%% Perform kernel density estimation on the given query set.
%% initAndBuildModel/14 has to be called before.
%%
foreign(evaluateWithQuery, c, evaluateWithQuery(+pointer(float_array), +integer, +integer,
-pointer(float_array), -integer)).
%% TODO:
%% --Input--
%%
%% --Output--
%% vec estimations
%%
%% --Description--
%% Perform kernel density estimation on the reference set.
%% If possible, it returns normalized estimations.
%% initAndBuildModel/14 has to be called before.
%%
foreign(evaluateNoQuery, c, evaluateNoQuery(-pointer(float_array), -integer)).
......
:- module(kernel_pca, [kernel_pca/20]).
%% requirements of library(struct)
......@@ -15,11 +16,11 @@
%% definitions for the connected function
%% TODO:
%% --Input--
%% string kernel "advb","agbadf",
%% bool name => (1)true / (0)false,
%% bool name => (1)true / (0)false,
%% bool centerTranformedData => (1)true / (0)false,
%% bool useNystoem => (1)true / (0)false,
%% string nystroemMethod "kmeans", "ordered", "random",
%% float32 degree needed by polynomial,
%% float32 offset needed by polynomial, hyptan,
......@@ -31,9 +32,11 @@
%% mat transformedData,
%% vec eigenValues,
%% mat eigenVectores,
%% int newDimension
%% int ""newDimension""
%%
%% --Description--
%% This program performs Kernel Principal Components Analysis (KPCA) on the specified dataset with the specified kernel. This will transform the data onto the kernel principal components, and optionally reduce the dimensionality by ignoring the kernel principal components with the smallest eigenvalues.
%%
foreign(kernel_pca, c, kernel_pca( +string, +integer, +integer, +string,
+float32, +float32, +float32, +float32,
+pointer(float_array), +integer, +integer,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment