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

Class DataSet

include/thundersvm/dataset.h:14–94  ·  view source on GitHub ↗

* @brief Dataset reader */

Source from the content-addressed store, hash-verified

12 * @brief Dataset reader
13 */
14class DataSet {
15public:
16 struct node{
17 node(int index, kernel_type value) : index(index), value(value) {}
18
19 int index;
20 kernel_type value;
21 };
22
23 typedef vector<vector<DataSet::node>> node2d;
24
25 DataSet();
26
27 /**
28 * construct a dataset using given instances
29 * @param instances given instances
30 * @param n_features the number of features of given instances
31 * @param y the label of each instances
32 */
33 DataSet(const DataSet::node2d &instances, int n_features, const vector<float_type> &y);
34
35 ///load dataset from file
36 void load_from_file(string file_name);
37
38 ///load dataset from python
39 void load_from_python(float *y, char **x, int len);
40
41 ///load from sparse data
42 void load_from_sparse(int row_size, float* val, int* row_ptr, int* col_ptr, float* label);
43
44 ///load from dense data
45 void load_from_dense(int row_size, int features, float* data, float* label);
46
47 ///group instances in same class
48 void group_classes(bool classification = true);
49
50 size_t n_instances() const;
51
52 size_t n_features() const;
53
54 size_t n_classes() const;
55
56 ///the number of instances for each class
57 const vector<int> &count() const;
58
59 ///the start position of instances for each class
60 const vector<int> &start() const;
61
62 ///mapping logical label (0,1,2,3,...) to real label (maybe 2,4,5,6,...)
63 const vector<int> &label() const;
64
65 ///label for each instances, the instances are arranged as they are in file
66 const vector<float_type> &y() const;
67
68 const node2d & instances() const;
69
70 ///instances of class \f$y_i\f$
71 const node2d instances(int y_i) const;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected