Main Page · Modules · All Classes · Class Hierarchy
MAClassifierModels.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include <string>
25 
26 #include <boost/unordered_map.hpp>
27 
28 #include "ml/MAClassifier.hpp"
29 #include "ml/MAModel.hpp"
30 
36 namespace MA
37 {
38 #if !defined(__AIBO_BUILD__)
39 typedef boost::unordered_map<std::string, ClassifierSPtr> StringClassifierSPtrMap;
41 #endif
42 
44 typedef boost::unordered_map<std::string, ModelSPtr> StringModelSPtrMap;
45 
46 static const std::string FloorSurfacesID = "FloorSurfaces";
47 static const std::string FloorSurfaceVectorID = "FloorSurfaceVector";
48 static const std::string RecognizedFloorSurfaceID = "RecognizedFloorSurface";
49 static const std::string RealFloorSurfaceID = "RealSurface";
50 static const std::string UserDefinedFloorSurfaceID = "UserDefinedFloorSurface";
51 static const std::string FloorSurfaceRemarkID = "FloorSurfaceRemark";
52 static const std::string DataCollectorDogSocksID = "DataCollectorDogSocks";
53 static const std::string DataCollectorLocationID = "DataCollectorLocation";
54 static const std::string DataCollectorEmailID = "DataCollectorEmail";
55 static const std::string DataCollectorUsernameID = "DataCollectorUsername";
56 static const std::string DataCollectorEaID = "DataCollectorEmotionalAttachment";
57 static const std::string FloorSurfaceModelID = "FloorSurfaceModel";
58 static const std::string BodyStateID = "BodyState";
59 static const std::string BodyStateModelID = "BodyStateModel";
60 static const std::string SoundEventModelID = "SoundEventModel";
61 // The maximum wait time is 3 minutes for user feedback (in msec)
62 static const int MaxFeedbackWaitTime = 3*60*1000;
63 }
64 
65 /*
66  * @brief Get the feature vector partitions to create a weak model
67  *
68  * @param model_name Model name
69  *
70  * @return Feature vector partition sizes
71  *
72  */
73 
74 extern MC::IntList MAGetWeakModelPartitions(const std::string& model_name);
75 
80 {
81 public:
82 
85 
86 private:
87 
88  /*
89  * @brief Load a model from a file
90  *
91  * @param file_name File name
92  * @param model_name Model name
93  *
94  */
95 
96  void LoadModelFromFile(const std::string& file_name, const std::string& model_name);
97 
98 public:
99 
100  /*
101  * @brief Recognize a feature vector with a model
102  *
103  * @param model_name Model name
104  * @param feature_vector Feature vector to be recognized
105  * @param[out] confidence Confidence value for the prediction
106  *
107  * @return Output of the model for the feature vector otherwise infinity
108  *
109  */
110 
111  float Recognize(const std::string& model_name, MC::FloatList& feature_vector,
112  MC::FloatList& confidence);
113 
114 private:
115 #if !defined(__AIBO_BUILD__)
116  MA::StringClassifierSPtrMap RawModels;
118 #endif
119  MA::StringModelSPtrMap Models;
121 };
122 
Classifier models class.