A collection of machine learning algorithms for object pascal.
Category | Type | Model | Notes |
---|---|---|---|
Unsupervised | Clustering | K-Means | Only random centroid initialization. Gladly accept your contribution. |
Supervised | Classification | Decision Tree | C4.5 implementation. Continuous data handling only for now. |
Supervised | Classification | Naive Bayes | Gaussian naive bayes |
Supervised | Regression | MLP Regressor | Multi-layer perceptron regressor. Requires noe. |
Dataset := ReadCSV('datasets/iris.csv');
X := Dataset[[_ALL_, [0, 1, 2, 3]]];
y := Dataset[[_ALL_, 4]];
kmeans := TKMeans.Create(3);
kmeans.Fit(X);
WriteLn('Clustering result:');
PrintMultiArray(kmeans.Predict(X));
nb := TNaiveBayesClassifier.Create;
nb.Fit(X, y);
pred := nb.Predict(X);
WriteLn('Accuracy:');
WriteLn(Mean(pred = Ravel(y)).Item);
PasML has gnuplot integration support. Please ensure that you have installed gnuplot and add the executable path to the environment variable. Currently only scatter and line plots are supported.
fig := TFigure.Create('Iris Flower Features', 'Petal length', 'Petal width');
fig.AddScatterPlot(X[[_ALL_, [2, 3]]].SliceBool([y = 0]), 'Iris Setosa');
fig.AddScatterPlot(X[[_ALL_, [2, 3]]].SliceBool([y = 1]), 'Iris Virginica');
fig.AddScatterPlot(X[[_ALL_, [2, 3]]].SliceBool([y = 2]), 'Iris Versicolor');
fig.LegendPosition := lpLeftTop;
fig.Show;
fig.Free;