mv_machine_learning: use carnel notation
[platform/core/api/mediavision.git] / mv_machine_learning / training / src / data_set_manager.cpp
1 /**
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "data_set_manager.h"
18
19 using namespace std;
20
21 DataSetManager::DataSetManager() : _data(), _labels(), _label_index(), _feature_vector_size(), _label_count()
22 {}
23
24 DataSetManager::~DataSetManager()
25 {
26         clear();
27 }
28
29 void DataSetManager::clear()
30 {
31         for (auto &data : _data)
32                 data.clear();
33
34         _data.clear();
35
36         for (auto &label : _labels)
37                 label.clear();
38
39         _labels.clear();
40         _label_index.clear();
41         _fv_cnt_per_label.clear();
42 }
43
44 bool DataSetManager::isFeatureVectorDuplicated(const vector<float> &vec)
45 {
46         if (_data.empty())
47                 return false;
48
49         for (const auto &data : _data)
50                 if (data == vec)
51                         return true;
52
53         return false;
54 }
55
56 vector<vector<float> > &DataSetManager::getData(void)
57 {
58         return _data;
59 }
60
61 vector<vector<float> > &DataSetManager::getLabel(void)
62 {
63         return _labels;
64 }
65
66 size_t DataSetManager::getFeaVecSize(void)
67 {
68         return _feature_vector_size;
69 }
70
71 vector<unsigned int> &DataSetManager::getLabelIdx(void)
72 {
73         return _label_index;
74 }