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

Method load_from_python

src/thundersvm/dataset.cpp:102–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102void DataSet::load_from_python(float *y, char **x, int len) {
103 y_.clear();
104 instances_.clear();
105 total_count_ = 0;
106 n_features_ = 0;
107 for (int i = 0; i < len; i++) {
108 int ind;
109 float v;
110 string line = x[i];
111 stringstream ss(line);
112 y_.push_back(y[i]);
113 instances_.emplace_back();
114 string tuple;
115 while (ss >> tuple) {
116 CHECK_EQ(sscanf(tuple.c_str(), "%d:%f", &ind, &v), 2) << "read error, using [index]:[value] format";
117 instances_[total_count_].emplace_back(ind, v);
118 if (ind > n_features_) n_features_ = ind;
119 };
120 total_count_++;
121 }
122}
123
124void DataSet::load_from_sparse(int row_size, float* val, int* row_ptr, int* col_ptr, float* label) {
125 y_.clear();

Callers 1

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected