0

I am trying to print out the content of both train and test sets, i need the proper line of codes to do this, please help

void split_dataset(int perc_train,
    vector<vector<float>>& vec_X_dataset, vector<int>& vec_Y_dataset,
    vector<vector<float>>& vec_X_train, vector<int>& vec_Y_train,
    vector<vector<float>>& vec_X_test, vector<int>& vec_Y_test) {
    size_t len = vec_X_dataset.size();
    size_t len2 = vec_Y_dataset.size();
    size_t len3 = vec_X_train.size();
    size_t len4 = vec_X_test.size();
    size_t division = static_cast<size_t>(len * (perc_train * 0.01));
    vector<float> data_point;
    for (size_t i = 0; i < len; ++i) {
        if (i < division) {
            vec_X_train.push_back(vec_X_dataset[i]);
            vec_Y_train.push_back(vec_Y_dataset[i]);
            
                   }
        else {
            vec_X_test.push_back(vec_X_dataset[i]);
            vec_Y_test.push_back(vec_Y_dataset[i]);
        }
            
    }

    cout << "len:" << len << "  " << "len2:" << len2 << "  " << "division:" << division <<"  " <<"len3:"<< len3 ;
    cout<< "len4:" << len4 << endl;
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
wala
  • 23
  • 5
  • We need to info to answer this. What is the actual problem you're having? How do you want it printed? In what way does your code not do what you expect? – Korosia Jun 08 '21 at 13:01
  • I want to print the training set and testing set, i don't know how – wala Jun 08 '21 at 15:54
  • As in you don't know how to print to the screen? You'll need to know the basics of outputting to the console https://www.cplusplus.com/doc/tutorial/basic_io/ – Korosia Jun 08 '21 at 15:57
  • If you don't know how to print a vector in particular, then this question should help (found by googling "how to print vector c++") https://stackoverflow.com/questions/10750057/how-do-i-print-out-the-contents-of-a-vector – Korosia Jun 08 '21 at 16:01
  • If it's something more than this, you'll need to edit the question to explain precisely what it is you want. – Korosia Jun 08 '21 at 16:02

0 Answers0