Turi Create  4.0
ml_data_entry.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_DML_DATA_ENTRY_H_
7 #define TURI_DML_DATA_ENTRY_H_
8 
9 #include <cstdlib>
10 #include <core/storage/serialization/serialization_includes.hpp>
11 
12 namespace turi {
13 
14 
15 /**
16  * \ingroup mldata
17  * \{
18  * Information relevant to a single entry of ml_data.
19  */
21  size_t column_index; /**< Column id .*/
22  size_t feature_index; /**< Local index within the column.*/
23  size_t global_index; /**< Global index, referenced off of the training index sizes. */
24  double value; /**< Value */
25 };
26 
27 /**
28  * Information relevant to a single entry of ml_data.
29  */
30 struct ml_data_entry {
31  size_t column_index; /**< Column id .*/
32  size_t index; /**< Local index within the column.*/
33  double value; /**< Value */
34 
35  /// Simple equality test
36  bool operator==(const ml_data_entry& other) const {
37  return ((column_index == other.column_index)
38  && (index == other.index)
39  && (value == other.value));
40  }
41 
42  const ml_data_entry& operator=(const ml_data_full_entry& fe) {
43  column_index = fe.column_index;
44  index = fe.feature_index;
45  value = fe.value;
46 
47  return *this;
48  }
49 };
50 
51 
52 /**
53  * Information relevant to a single entry of ml_data.
54  */
56  size_t global_index; /**< Global index based on training indices. */
57  double value = 1.0; /**< Value */
58 
59  /// Simple equality test
60  bool operator==(const ml_data_entry_global_index& other) const {
61  return ((global_index == other.global_index)
62  && (value == other.value));
63  }
64 
65  const ml_data_entry_global_index& operator=(const ml_data_full_entry& fe) {
66  global_index = fe.global_index;
67  value = fe.value;
68 
69  return *this;
70  }
71 };
72 
73 /// \}
74 }
75 
76 SERIALIZABLE_POD(ml_data_entry);
77 
78 
79 #endif /* TURI_DML_DATA_ENTRY_H_ */
double value
bool operator==(const ml_data_entry_global_index &other) const
Simple equality test.
double value
bool operator==(const ml_data_entry &other) const
Simple equality test.
size_t global_index
double value
size_t column_index
size_t index
size_t feature_index
size_t global_index
size_t column_index