File: RandomForestClassifier.cxx

package info (click to toggle)
itksnap 3.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,196 kB
  • ctags: 9,196
  • sloc: cpp: 62,895; sh: 175; makefile: 13
file content (37 lines) | stat: -rw-r--r-- 772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "RandomForestClassifier.h"
#include "Library/classification.h"

void RandomForestClassifier::Reset()
{
  if(m_Forest)
    delete m_Forest;

  m_Forest = new RandomForestType(true);
  m_ClassToLabelMapping.clear();
  m_BiasParameter = 0.5;
  m_PatchRadius.Fill(0);
  m_UseCoordinateFeatures = false;
  m_ClassWeights.clear();
}

void RandomForestClassifier::SetClassWeight(size_t class_id, double weight)
{
  m_ClassWeights[class_id] = weight;
}

bool RandomForestClassifier::IsValidClassifier() const
{
  return m_ClassToLabelMapping.size() >= 2 && m_Forest->GetForestSize() > 0;
}

RandomForestClassifier::RandomForestClassifier()
{
  m_Forest = NULL;
  this->Reset();
}

RandomForestClassifier::~RandomForestClassifier()
{
  if(m_Forest)
    delete m_Forest;
}