-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
49 lines (42 loc) · 1.45 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <opencv2/opencv.hpp>
#include "dataset.hpp"
#include "knn.hpp"
#include "normalBayes.hpp"
#include "logisticRegression.hpp"
#include "decisionTree.hpp"
#include "randomForest.hpp"
#include "svm.hpp"
#include "mlp.hpp"
int main()
{
//Create Dataset
const char* imagePath = "digits.png";
auto dataSet = createTrainData(imagePath);
dataSet->setTrainTestSplitRatio(0.8,true);
//Train
trainKnn(dataSet);
trainNormalBayes(dataSet);
trainLogisticRegression(dataSet);
trainDecisionTree(dataSet);
trainRandomForests(dataSet);
trainSVM(dataSet);
trainMLP(dataSet);
//Test
float knnError = testKnn(dataSet);
float nbError = testNormalBayes(dataSet);
float lrError = testLogisticRegression(dataSet);
float dtError = testDecisionTree(dataSet);
float rfError = testRandomForest(dataSet);
float svmError = testSVM(dataSet);
float mlpError = testMLP(dataSet);
//Accuracy
std::cout << "KNN error: " << knnError << "%" << std::endl;
std::cout << "Normal Bayes error: " << nbError << "%" << std::endl;
std::cout << "Logistic Regression error: " << lrError << "%" << std::endl;
std::cout << "Decision Tree error: " << dtError << "%" << std::endl;
std::cout << "Random Forest error: " << rfError << "%" << std::endl;
std::cout << "SVM error: " << svmError << "%" << std::endl;
std::cout << "MLP error: " << mlpError << "%" << std::endl;
return 0;
}