MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / load_from_sparse

Method load_from_sparse

src/thundersvm/dataset.cpp:124–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124void 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
150void DataSet::load_from_dense(int row_size, int features, float* data, float* label){
151 y_.clear();

Callers 3

sparse_model_scikitFunction · 0.80
sparse_predictFunction · 0.80
sparse_decisionFunction · 0.80

Calls 3

n_instancesMethod · 0.95
n_featuresMethod · 0.95
clearMethod · 0.80

Tested by

no test coverage detected