| 122 | } |
| 123 | |
| 124 | void DataSet::load_from_sparse(int row_size, float* val, int* row_ptr, int* col_ptr, float* label) { |
| 125 | y_.clear(); |
| 126 | instances_.clear(); |
| 127 | total_count_ = 0; |
| 128 | n_features_ = 0; |
| 129 | for(int i = 0; i < row_size; i++){ |
| 130 | int ind; |
| 131 | float v; |
| 132 | if(label != NULL) |
| 133 | y_.push_back(label[i]); |
| 134 | instances_.emplace_back(); |
| 135 | for(int i = row_ptr[total_count_]; i < row_ptr[total_count_ + 1]; i++){ |
| 136 | ind = col_ptr[i]; |
| 137 | ind++; //convert to one-based format |
| 138 | v = val[i]; |
| 139 | instances_[total_count_].emplace_back(ind, v); |
| 140 | if(ind > n_features_) n_features_ = ind; |
| 141 | } |
| 142 | total_count_++; |
| 143 | |
| 144 | } |
| 145 | // n_features_++; |
| 146 | LOG(INFO)<<"#instances = "<<this->n_instances()<<", #features = "<<this->n_features(); |
| 147 | |
| 148 | } |
| 149 | |
| 150 | void DataSet::load_from_dense(int row_size, int features, float* data, float* label){ |
| 151 | y_.clear(); |
no test coverage detected