SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Hierarchical.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2007-2009 Soeren Sonnenburg
8  * Copyright (C) 2007-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9  */
10 
11 #ifndef _HIERARCHICAL_H__
12 #define _HIERARCHICAL_H__
13 
14 #include <stdio.h>
15 #include <shogun/lib/common.h>
16 #include <shogun/io/SGIO.h>
19 
20 namespace shogun
21 {
22 class CDistanceMachine;
23 
38 {
39  public:
41  CHierarchical();
42 
48  CHierarchical(int32_t merges, CDistance* d);
49  virtual ~CHierarchical();
50 
56 
62  virtual bool load(FILE* srcfile);
63 
69  virtual bool save(FILE* dstfile);
70 
75  inline void set_merges(int32_t m)
76  {
77  ASSERT(m>0);
78  merges=m;
79  }
80 
85  int32_t get_merges();
86 
91 
96 
101 
103  inline virtual const char* get_name() const { return "Hierarchical"; }
104 
105  protected:
114  virtual bool train_machine(CFeatures* data=NULL);
115 
119  virtual void store_model_features();
120 
122  virtual CLabels* apply();
123 
125  virtual CLabels* apply(CFeatures* data);
126 
128  virtual float64_t apply(int32_t num);
129 
130  protected:
132  int32_t merges;
133 
135  int32_t dimensions;
136 
139 
141  int32_t* assignment;
142 
144  int32_t table_size;
145 
147  int32_t* pairs;
148 
151 };
152 }
153 #endif
virtual bool save(FILE *dstfile)
SGVector< float64_t > get_merge_distances()
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:77
EClassifierType
Definition: Machine.h:27
The class Labels models labels, i.e. class assignments of objects.
Definition: Labels.h:35
Agglomerative hierarchical single linkage clustering.
Definition: Hierarchical.h:37
int32_t merges
the number of merges in hierarchical clustering
Definition: Hierarchical.h:132
virtual const char * get_name() const
Definition: Hierarchical.h:103
void set_merges(int32_t m)
Definition: Hierarchical.h:75
int32_t * assignment
cluster assignment for the num_points
Definition: Hierarchical.h:141
A generic DistanceMachine interface.
#define ASSERT(x)
Definition: SGIO.h:102
virtual bool train_machine(CFeatures *data=NULL)
SGMatrix< int32_t > get_cluster_pairs()
int32_t table_size
size of the below tables
Definition: Hierarchical.h:144
double float64_t
Definition: common.h:56
int32_t assignment_size
size of assignment table
Definition: Hierarchical.h:138
shogun matrix
SGVector< int32_t > get_assignment()
virtual void store_model_features()
virtual bool load(FILE *srcfile)
The class Features is the base class of all feature objects.
Definition: Features.h:56
virtual CLabels * apply()
float64_t * merge_distance
distance at which pair i/j was added
Definition: Hierarchical.h:150
virtual EClassifierType get_classifier_type()
int32_t dimensions
number of dimensions
Definition: Hierarchical.h:135
int32_t * pairs
tuples of i/j
Definition: Hierarchical.h:147

SHOGUN Machine Learning Toolbox - Documentation