| 148 | } |
| 149 | |
| 150 | void DataSet::load_from_dense(int row_size, int features, float* data, float* label){ |
| 151 | y_.clear(); |
| 152 | instances_.clear(); |
| 153 | total_count_ = 0; |
| 154 | n_features_ = 0; |
| 155 | int off = 0; |
| 156 | for(int i = 0; i < row_size; i++){ |
| 157 | int ind; |
| 158 | float v; |
| 159 | if(label != NULL) |
| 160 | y_.push_back(label[i]); |
| 161 | instances_.emplace_back(); |
| 162 | for(int j = 1; j <= features; j++){ |
| 163 | ind = j; |
| 164 | v = data[off]; |
| 165 | off++; |
| 166 | instances_[total_count_].emplace_back(ind, v); |
| 167 | } |
| 168 | total_count_++; |
| 169 | } |
| 170 | n_features_ = features; |
| 171 | LOG(INFO)<<"#instances = "<<this->n_instances()<<", #features = "<<this->n_features(); |
| 172 | } |
| 173 | |
| 174 | const vector<int> &DataSet::count() const {//return the number of instances of each class |
| 175 | return count_; |
no test coverage detected