SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
KMeansBase.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) 1999-2008 Gunnar Raetsch
8  * Written (W) 2007-2009 Soeren Sonnenburg
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
12 #ifndef _KMEANSBASE_H__
13 #define _KMEANSBASE_H__
14 
15 #include <shogun/lib/config.h>
16 
17 #include <shogun/lib/common.h>
18 #include <shogun/io/SGIO.h>
22 
23 namespace shogun
24 {
25 class CDistanceMachine;
26 
31 {
32  public:
34  CKMeansBase();
35 
42  CKMeansBase(int32_t k, CDistance* d, bool kmeanspp=false);
43 
49  CKMeansBase(int32_t k_i, CDistance* d_i, SGMatrix<float64_t> centers_i);
50 
51  virtual ~CKMeansBase();
52 
53 
55 
56 
61 
67  virtual bool load(FILE* srcfile);
68 
74  virtual bool save(FILE* dstfile);
75 
80  void set_k(int32_t p_k);
81 
86  int32_t get_k();
87 
92  void set_use_kmeanspp(bool kmpp);
93 
98  bool get_use_kmeanspp() const;
99 
104  void set_fixed_centers(bool fixed);
105 
110  bool get_fixed_centers();
111 
116  void set_max_iter(int32_t iter);
117 
123 
129 
135 
140  int32_t get_dimensions();
141 
143  virtual const char* get_name() const { return "KMeansBase"; }
144 
149  virtual void set_initial_centers(SGMatrix<float64_t> centers);
150 
151  protected:
153  void initialize_training(CFeatures* data=NULL);
154 
156  virtual void store_model_features();
157 
158  virtual bool train_require_labels() const { return false; }
159 
165 
166  void init();
167 
172  void set_random_centers();
173 
175 
176  protected:
178  int32_t max_iter;
179 
182 
184  int32_t k;
185 
187  int32_t dimensions;
188 
191 
194 
197 
200 
201 };
202 }
203 #endif
204 
SGVector< float64_t > get_radiuses()
Definition: KMeansBase.cpp:232
EMachineType
Definition: Machine.h:33
virtual void store_model_features()
Definition: KMeansBase.cpp:264
Class Distance, a base class for all the distances used in the Shogun toolbox.
Definition: Distance.h:87
virtual bool save(FILE *dstfile)
Definition: KMeansBase.cpp:193
void set_max_iter(int32_t iter)
Definition: KMeansBase.cpp:221
SGMatrix< float64_t > mus
Definition: KMeansBase.h:199
A generic DistanceMachine interface.
void compute_cluster_variances()
Definition: KMeansBase.cpp:94
void initialize_training(CFeatures *data=NULL)
Definition: KMeansBase.cpp:142
float64_t get_max_iter()
Definition: KMeansBase.cpp:227
#define MACHINE_PROBLEM_TYPE(PT)
Definition: Machine.h:120
virtual const char * get_name() const
Definition: KMeansBase.h:143
double float64_t
Definition: common.h:50
int32_t get_dimensions()
Definition: KMeansBase.cpp:249
void set_k(int32_t p_k)
Definition: KMeansBase.cpp:210
virtual EMachineType get_classifier_type()
Definition: KMeansBase.h:60
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
bool get_use_kmeanspp() const
Definition: KMeansBase.cpp:205
virtual bool load(FILE *srcfile)
Definition: KMeansBase.cpp:186
The class Features is the base class of all feature objects.
Definition: Features.h:68
virtual bool train_require_labels() const
Definition: KMeansBase.h:158
SGMatrix< float64_t > kmeanspp()
Definition: KMeansBase.cpp:276
SGVector< float64_t > R
Definition: KMeansBase.h:190
SGMatrix< float64_t > get_cluster_centers()
Definition: KMeansBase.cpp:237
virtual ~CKMeansBase()
Definition: KMeansBase.cpp:52
void set_use_kmeanspp(bool kmpp)
Definition: KMeansBase.cpp:200
virtual void set_initial_centers(SGMatrix< float64_t > centers)
Definition: KMeansBase.cpp:56
void set_fixed_centers(bool fixed)
Definition: KMeansBase.cpp:254
SGMatrix< float64_t > mus_initial
Definition: KMeansBase.h:193

SHOGUN Machine Learning Toolbox - Documentation