RapidLib  v2.1.0
A simple library for interactive machine learning
modelSet.h
Go to the documentation of this file.
1 //
2 // modelSet.h
3 // RapidLib
4 //
5 // Created by mzed on 26/09/2016.
6 // Copyright © 2016 Goldsmiths. All rights reserved.
7 //
8 
9 #ifndef modelSet_h
10 #define modelSet_h
11 
12 #include <vector>
13 #include "trainingExample.h"
14 #include "baseModel.h"
15 #include "neuralNetwork.h"
16 #include "knnClassification.h"
17 #include "svmClassification.h"
18 #ifndef EMSCRIPTEN
19 #include "../dependencies/json/json.h"
20 #endif
21 
23 template<typename T>
24 class modelSet {
25 public:
26  modelSet();
27  virtual ~modelSet();
29  virtual bool train(const std::vector<trainingExampleTemplate<T> > &trainingSet);
31  bool reset();
33  std::vector<T> run(const std::vector<T> &inputVector);
34 
35 protected:
36  std::vector<baseModel<T>*> myModelSet;
37  int numInputs;
38  std::vector<std::string> inputNames;
40  bool created;
41 
42 #ifndef EMSCRIPTEN //The javascript code will do its own JSON parsing
43 public:
45  std::string getJSON();
47  void writeJSON(const std::string &filepath);
49  bool putJSON(const std::string &jsonMessage);
51  bool readJSON(const std::string &filepath);
52 
53 private:
54  Json::Value parse2json();
55  void json2modelSet(const Json::Value &root);
56 
57 #endif
58 };
59 
60 #endif
int numOutputs
Definition: modelSet.h:39
Definition: trainingExample.h:18
std::vector< T > run(const std::vector< T > &inputVector)
Definition: modelSet.cpp:78
Definition: modelSet.h:24
std::vector< std::string > inputNames
Definition: modelSet.h:38
std::string getJSON()
Definition: modelSet.cpp:132
modelSet()
Definition: modelSet.cpp:24
std::vector< baseModel< T > * > myModelSet
Definition: modelSet.h:36
bool putJSON(const std::string &jsonMessage)
Definition: modelSet.cpp:149
int numInputs
Definition: modelSet.h:37
void writeJSON(const std::string &filepath)
Definition: modelSet.cpp:138
bool readJSON(const std::string &filepath)
Definition: modelSet.cpp:232
bool reset()
Definition: modelSet.cpp:66
virtual bool train(const std::vector< trainingExampleTemplate< T > > &trainingSet)
Definition: modelSet.cpp:38
bool created
Definition: modelSet.h:40
virtual ~modelSet()
Definition: modelSet.cpp:31