SHOGUN  3.2.1
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
MixtureModel.cpp
浏览该文件的文档.
1 /*
2  * Copyright (c) The Shogun Machine Learning Toolbox
3  * Written (w) 2014 Parijat Mazumdar
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice, this
10  * list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * The views and conclusions contained in the software and documentation are those
27  * of the authors and should not be interpreted as representing official policies,
28  * either expressed or implied, of the Shogun Development Team.
29  */
30 
32 #include <shogun/mathematics/Math.h>
33 
34 using namespace shogun;
35 
37 {
38  init();
39 }
40 
42 {
43  init();
44  m_components=components;
45  SG_REF(components);
46  m_weights=weights;
47 }
48 
50 {
51  SG_UNREF(m_components);
52 }
53 
55 {
56  //TBD
57  return true;
58 }
59 
61 {
62  REQUIRE(num_param==1,"number of parameters in mixture model is 1"
63  " (i.e. number of components). num_components should be 1. %d supplied\n",num_param)
64 
66 }
67 
68 float64_t CMixtureModel::get_log_derivative(int32_t num_param, int32_t num_example)
69 {
70  // TBD
71  return 0;
72 }
73 
75 {
76  // TBD
77  return 0;
78 }
79 
81 {
82  return m_weights;
83 }
84 
86 {
87  m_weights=weights;
88 }
89 
91 {
92  SG_REF(m_components);
93  return m_components;
94 }
95 
97 {
98  if (m_components!=NULL)
99  SG_UNREF(m_components)
100 
101  m_components=components;
102  SG_REF(m_components);
103 }
104 
106 {
107  return m_components->get_num_elements();
108 }
109 
111 {
112  REQUIRE(index<get_num_components(),"index supplied (%d) is greater than total mixture components (%d)\n"
113  ,index,get_num_components())
114  return CDistribution::obtain_from_generic(m_components->get_element(index));
115 }
116 
118 {
119  // TBD
120  return SGVector<float64_t>();
121 }
122 
124 {
125  // TBD
126  return point;
127 }
128 
129 void CMixtureModel::init()
130 {
131  m_components=NULL;
132  m_weights=SGVector<float64_t>();
133 
134  SG_ADD((CSGObject**)&m_components,"m_components","components of mixture",MS_NOT_AVAILABLE);
135  SG_ADD(&m_weights,"m_weights","weights of components",MS_NOT_AVAILABLE);
136 }
SGVector< float64_t > cluster(SGVector< float64_t > point)
int32_t index_t
Definition: common.h:62
#define SG_UNREF(x)
Definition: SGRefObject.h:35
static CDistribution * obtain_from_generic(CSGObject *object)
#define REQUIRE(x,...)
Definition: SGIO.h:207
bool train(CFeatures *data=NULL)
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
virtual float64_t get_log_derivative(int32_t num_param, int32_t num_example)
virtual float64_t get_log_likelihood_example(int32_t num_example)
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:98
double float64_t
Definition: common.h:50
index_t get_num_components() const
#define SG_REF(x)
Definition: SGRefObject.h:34
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
CDistribution * get_component(index_t index) const
SGVector< float64_t > sample()
The class Features is the base class of all feature objects.
Definition: Features.h:68
CDynamicObjectArray * get_components() const
static float64_t log(float64_t v)
Definition: Math.h:505
float64_t get_log_model_parameter(int32_t num_param=1)
CSGObject * get_element(int32_t index) const
void set_components(CDynamicObjectArray *components)
#define SG_ADD(...)
Definition: SGObject.h:67
SGVector< float64_t > get_weights() const
void set_weights(SGVector< float64_t > weights)

SHOGUN 机器学习工具包 - 项目文档