Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1.  class DataEntry {
  2.  public :
  3.     std::vector<double> attributes;
  4.      int EntryClass;
  5.    
  6.      DataEntry(std::vector<std::string> input) {
  7.         for (int i = 0; i < input.size() - 1; i++) {
  8.             attributes.push_back( atof(input[i].c_str()));
  9.         }
  10.         EntryClass =atoi(input[input.size() - 1].c_str());
  11.     }
  12.  
  13.      DataEntry() {
  14.          EntryClass = 0;
  15.      }
  16.  };
  17.  
  18.  size_t TrainingDataSize;
  19.  size_t TestDataSize;
  20.  DataEntry* TrainingData;
  21.  DataEntry* TestData;
  22.  std::string datainfo;
  23.  void ReadData(char* path, int rowNumber) {
  24.      std::vector<std::string> row;
  25.      int count4 = 0;
  26.      int count2 = 0;
  27.      std::string s = path;
  28.      std::vector<std::string> rows;
  29.      std::ifstream file(s, std::ios::in);
  30.  
  31.      while (!(file.eof()) && rowNumber>0)
  32.      {
  33.          getline(file, s);
  34.          rows.push_back(s);
  35.          rowNumber--;
  36.      };
  37.      file.close();
  38.  
  39.      for (int i = 0; i<rows.size() / 2; i++) {
  40.          row = split(rows[i], ',');
  41.          TrainingData[i] = *(new DataEntry(row));
  42.      }
  43.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement