aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
multiDimLogit.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief class for LOGIT implementation as multiDim
25  *
26  * @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
27  */
28 #ifndef GUM_MULTI_DIM_LOGIT_H
29 #define GUM_MULTI_DIM_LOGIT_H
30 
31 #include <agrum/tools/multidim/ICIModels/multiDimICIModel.h>
32 
33 namespace gum {
34 
35  /**
36  * @class MultiDimLogit
37  * @headerfile multiDimLogit.h <agrum/tools/multidim/ICIModels/multiDimLogit.h>
38  * @ingroup multidim_group
39  *
40  * @brief Logit representation
41  *
42  * Logit instantiation of GLM (Generalized Linear Models)
43  *
44  * @warning
45  * - The first variable is assumed to be the class estimated by a logit.
46  * The latter are the features.
47  * - This code give probabilities for BINARY VARIABLES (other values are
48  * assumed to be of probability 0). But for optimization reason, we will
49  * never check if it is the case.
50  */
51  template < typename GUM_SCALAR >
53  public:
54  // ============================================================================
55  /// @name Constructors / Destructors
56  // ============================================================================
57  /// @{
58 
59  /**
60  * @brief Default constructor.
61  *
62  * default_weight is 0 for logit model.
63  **/
64  MultiDimLogit(GUM_SCALAR external_weight, GUM_SCALAR default_weight = (GUM_SCALAR)0.0);
65 
66  MultiDimLogit(const MultiDimLogit< GUM_SCALAR >& from);
67 
68  /**
69  * Copy constructor using a bijection to swap variables from source.
70  *
71  * @param bij First variables are new variables, seconds are in from.
72  * @param from the copied instance
73  */
74  MultiDimLogit(const Bijection< const DiscreteVariable*, const DiscreteVariable* >& bij,
75  const MultiDimLogit< GUM_SCALAR >& from);
76 
77  /// Destructor.
78  virtual ~MultiDimLogit();
79 
80  /// @}
81 
82  /**
83  * This method creates a clone of this object, withouth its content
84  * (including variable), you must use this method if you want to ensure
85  * that the generated object has the same type than the object containing
86  * the called newFactory()
87  *
88  * For example :
89  * MultiDimArray<double> y;
90  * MultiDimContainer<double>* x = y.newFactory();
91  * Then x is a MultiDimArray<double>*
92  *
93  * @warning you must desallocate by yourself the memory
94  * @return an empty clone of this object with the same type
95  */
96  virtual MultiDimContainer< GUM_SCALAR >* newFactory() const;
97 
98  // ============================================================================
99  /// @name Accessors / Modifiers
100  // ============================================================================
101  /// @{
102 
103  public:
104  virtual GUM_SCALAR get(const Instantiation& i) const;
105 
106  std::string toString() const;
107 
108  /**
109  * @brief Returns the real name of the multiDimArray.
110  *
111  * In aGrUM, all the types of multi-dimensional arrays/functionals have a
112  * name that describes what they are in reality. For instance, a table
113  * stored in extension is a "MultiDimArray", one that stores only non zero
114  * elements is a "MultiDimSparseArray", and so on. These names are unique
115  * for each type of implementation and is used by the system to determine
116  * which is the best functions to use, say, when we wish to use operators
117  * such as operator+ on two MultiDimImplementations.
118  */
119  virtual const std::string& name() const;
120 
121  /// @}
122  };
123 
124 
125 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
126  extern template class MultiDimLogit< double >;
127 #endif
128 
129  /// For friendly displaying the content of the array.
130  template < typename GUM_SCALAR >
132 
133 } /* namespace gum */
134 
135 #include <agrum/tools/multidim/ICIModels/multiDimLogit_tpl.h>
136 
137 #endif /* GUM_MULTI_DIM_LOGIT_H */
std::string toString() const
Returns the real name of the multiDimArray.
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
MultiDimLogit(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const MultiDimLogit< GUM_SCALAR > &from)
Copy constructor using a bijection to swap variables from source.
virtual const std::string & name() const
Returns the real name of the multiDimArray.
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the real name of the multiDimArray.
MultiDimLogit(const MultiDimLogit< GUM_SCALAR > &from)
Default constructor.
Logit representation.
Definition: multiDimLogit.h:52
std::ostream & operator<<(std::ostream &s, const MultiDimLogit< GUM_SCALAR > &ag)
For friendly displaying the content of the array.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
This method creates a clone of this object, withouth its content (including variable), you must use this method if you want to ensure that the generated object has the same type than the object containing the called newFactory()
virtual ~MultiDimLogit()
Destructor.
MultiDimLogit(GUM_SCALAR external_weight, GUM_SCALAR default_weight=(GUM_SCALAR) 0.0)
Default constructor.