[pixkit ml] mldata: machine learning data RW - yunfuliu/pixkit GitHub Wiki
readTrain
Read machine learning data with class number and its feature vector from a specific file.
[Developer] Li-Ying Chang ([email protected])
C++: void mldata::readTrain(std::vector < pixkit::classification::SSample >& data, const std::string file)
Parameters:
- data - Training data. Notably, it should be in the format of pixkit::classification::SSample.
- file - File name.
[Data format] Class-number feature1 feature2 feature3 ...
Such as an instance with four samples and each has four features as below,
Iris-setosa 5.100000 3.500000 1.400000 0.200000
Iris-setosa 4.900000 3.000000 1.400000 0.200000
Iris-versicolor 7.000000 3.200000 4.700000 1.400000
Iris-versicolor 6.400000 3.200000 4.500000 1.500000
Example:
readTrain(dataset, "a.txt");
// or
string file = "a.txt";
readTrain(dataset, file.c_str());
readTest
Read machine learning data with its feature vector from a specific file.
[Developer] Li-Ying Chang ([email protected])
C++: void mldata::readTest(std::vector < pixkit::classification::SSample >& data, const std::string file)
Parameters:
- data - Testing data. Notably, it should be in the format of pixkit::classification::SSample.
- file - File name.
[Data format] feature1 feature2 feature3 ...
Such as an instance with four features as below,
5.200000 3.500000 1.500000 0.200000
5.500000 4.200000 1.400000 0.200000
6.500000 2.800000 4.600000 1.500000
5.700000 2.800000 4.500000 1.300000
Example:
readTest(dataset, "a.txt");
// or
string file = "a.txt";
readTest(dataset, file.c_str());
write
Write out the results of machine learning data with a class number and its feature vector from classification procedure.
[Developer] Li-Ying Chang ([email protected])
C++: void mldata::write(std::vector < pixkit::classification::SSample >& data, const std::string file)
Parameters:
- data - Output the final data into the file. Notably, it should be in the format of pixkit::classification::SSample.
- file - The file Name.
[Output of data format] Class-number feature1 feature2 feature3 ...
Such as an instance with four samples and each has four features as below,
Iris-setosa 5.200000 3.500000 1.500000 0.200000
Iris-setosa 5.500000 4.200000 1.400000 0.200000
Iris-versicolor 6.500000 2.800000 4.600000 1.500000
Iris-versicolor 5.700000 2.800000 4.500000 1.300000
Example:
write(dataset, "a.txt");
// or
string file = "a.txt";
write(dataset, file.c_str());