Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class DataEntry {
- public :
- std::vector<double> attributes;
- int EntryClass;
- DataEntry(std::vector<std::string> input) {
- for (int i = 0; i < input.size() - 1; i++) {
- attributes.push_back( atof(input[i].c_str()));
- }
- EntryClass =atoi(input[input.size() - 1].c_str());
- }
- DataEntry() {
- EntryClass = 0;
- }
- };
- size_t TrainingDataSize;
- size_t TestDataSize;
- DataEntry* TrainingData;
- DataEntry* TestData;
- std::string datainfo;
- void ReadData(char* path, int rowNumber) {
- std::vector<std::string> row;
- int count4 = 0;
- int count2 = 0;
- std::string s = path;
- std::vector<std::string> rows;
- std::ifstream file(s, std::ios::in);
- while (!(file.eof()) && rowNumber>0)
- {
- getline(file, s);
- rows.push_back(s);
- rowNumber--;
- };
- file.close();
- for (int i = 0; i<rows.size() / 2; i++) {
- row = split(rows[i], ',');
- TrainingData[i] = *(new DataEntry(row));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement