Gaia
svmpredict.h
1 /*
2  * Copyright (C) 2006-2013 Music Technology Group - Universitat Pompeu Fabra
3  *
4  * This file is part of Gaia
5  *
6  * Gaia is free software: you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License as published by the Free
8  * Software Foundation (FSF), either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the Affero GNU General Public License
17  * version 3 along with this program. If not, see http://www.gnu.org/licenses/
18  */
19 
20 #ifndef GAIA_SVMPREDICT_H
21 #define GAIA_SVMPREDICT_H
22 
23 #include <QByteArray>
24 #include "applier.h"
25 #include "3rdparty/libsvm/svm.h"
26 
27 namespace gaia2 {
28 
33 class SVMPredict : public Applier {
34 
35  public:
36  SVMPredict(const Transformation& transfo);
37  virtual ~SVMPredict();
38 
42  virtual Point* mapPoint(const Point* p) const;
43 
44  virtual DataSet* mapDataSet(const DataSet* dataset) const;
45 
46  protected:
47  Point* svmPredict(const Point* p, Point* result,
48  const struct svm_model* model, const Region& region,
49  DescriptorLengthType classLType, int classIdx,
50  DescriptorLengthType classProbLType, int classProbIdx) const;
51 
52  struct svm_model* loadModel() const;
53 
54  QStringList _classMapping;
55  QString _className;
56  QStringList _descriptorNames;
57  QByteArray _modelData;
58  bool _probability;
59  struct svm_model* _model;
60  int* _cmap; // reverse class map, used for getting correct class number from libsvm probabilities
61 };
62 
63 } // namespace gaia2
64 
65 #endif // GAIA_SVMPREDICT_H
A region is a physical location in the point layout which consists in a list of segments.
Definition: region.h:125
Class containing all info pertaining to a specific transformation, ie: the name of the analyzer class...
Definition: transformation.h:41
This class represents a dataset and all related information.
Definition: dataset.h:91
virtual Point * mapPoint(const Point *p) const
Ownership of resulting point is handed to caller of this function.
Definition: svmpredict.cpp:122
DescriptorLengthType
Either fixed-length or variable-length.
Definition: region.h:46
Main Gaia namespace, which contains all the library functions.
Definition: addfield.cpp:22
The Applier abstract base class.
Definition: applier.h:44
SVMPredict applier class.
Definition: svmpredict.h:33
Definition: point.h:106
virtual DataSet * mapDataSet(const DataSet *dataset) const
Provides a default function that maps a whole dataset but which can be overriden in derived classes t...
Definition: svmpredict.cpp:179