aGrUM  0.16.0
DBTranslator4ContinuousVariable.h
Go to the documentation of this file.
1 
28 #ifndef GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
29 #define GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
30 
31 #include <string>
32 
33 #include <agrum/agrum.h>
34 #include <agrum/core/hashTable.h>
37 
38 
39 namespace gum {
40 
41  namespace learning {
42 
43 
126  template < template < typename > class ALLOC = std::allocator >
128  public:
131 
132 
133  // ##########################################################################
135  // ##########################################################################
136 
138 
140 
153  template < template < typename > class XALLOC >
155  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
156  const bool fit_range = false,
157  const allocator_type& alloc = allocator_type());
158 
160 
172  const bool fit_range = false,
173  const allocator_type& alloc = allocator_type());
174 
176 
189  template < typename GUM_SCALAR, template < typename > class XALLOC >
192  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
193  const bool fit_range = false,
194  const allocator_type& alloc = allocator_type());
195 
210  template < typename GUM_SCALAR >
213  const bool fit_range = false,
214  const allocator_type& alloc = allocator_type());
215 
217 
230  template < template < typename > class XALLOC >
232  const IContinuousVariable& var,
233  const std::vector< std::string, XALLOC< std::string > >& missing_symbols,
234  const bool fit_range = false,
235  const allocator_type& alloc = allocator_type());
236 
252  const IContinuousVariable& var,
253  const bool fit_range = false,
254  const allocator_type& alloc = allocator_type());
255 
259 
263  const allocator_type& alloc);
264 
268 
272  const allocator_type& alloc);
273 
276 
279  clone(const allocator_type& alloc) const;
280 
283 
285 
286 
287  // ##########################################################################
289  // ##########################################################################
290 
292 
296 
300 
302 
303 
304  // ##########################################################################
306  // ##########################################################################
307 
309 
311 
346  virtual DBTranslatedValue translate(const std::string& str) final;
347 
349 
353  virtual std::string
354  translateBack(const DBTranslatedValue translated_val) const final;
355 
357  virtual std::size_t domainSize() const final;
358 
360  virtual bool needsReordering() const final;
361 
364  virtual HashTable< std::size_t,
365  std::size_t,
366  ALLOC< std::pair< std::size_t, std::size_t > > >
367  reorder() final;
368 
370  virtual const IContinuousVariable* variable() const final;
371 
373  virtual DBTranslatedValue missingValue() const final;
374 
376 
377 
378 #ifndef DOXYGEN_SHOULD_SKIP_THIS
379 
380  private:
381  // the ContinuousVariable really used by the translator. As its values
382  // are floats, this speeds-up translations
383  ContinuousVariable< float > __variable;
384 
385  // the ContinuousVariablee returned by method variable ()
386  // We must return a IContinuousVariable because the user may have
387  // saved into the translator a ContinuousVariable<X>, with X != float
388  IContinuousVariable* __real_variable;
389 
390  // assign to each float missing symbol a Boolean indicating whether
391  // we already translated it or not. If we translated it, then we cannot
392  // change the range of the variable so that this range contains the symbol.
394  __status_float_missing_symbols;
395 
396  // a string containing a non real missing symbol
397  // (useful for back translations)
398  std::string __nonfloat_missing_symbol;
399 
400  // indicates whether we should fit the range of the observed values
401  bool __fit_range;
402 
403 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
404  };
405 
406  } /* namespace learning */
407 
408 } /* namespace gum */
409 
410 
411 // always include the template implementation
413 
414 #endif /* GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H */
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
Defines a continuous random variable.
ALLOC< DBTranslatedValue > allocator_type
type for the allocators passed in arguments of methods
Definition: DBTranslator.h:120
typename DBTranslator< ALLOC >::allocator_type allocator_type
type for the allocators passed in arguments of methods
A base class for continuous variables, independent of the GUM_SCALAR type.
virtual DBTranslator4ContinuousVariable< ALLOC > * clone() const
virtual copy constructor
STL namespace.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
The union class for storing the translated values in learning databases.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
Definition: hashTable.h:679
DBTranslator4ContinuousVariable< ALLOC > & operator=(const DBTranslator4ContinuousVariable< ALLOC > &from)
copy operator
virtual std::size_t domainSize() const final
returns std::numeric_limits<std::size_t>::max ()
DBTranslator4ContinuousVariable(const std::vector< std::string, XALLOC< std::string > > &missing_symbols, const bool fit_range=false, const allocator_type &alloc=allocator_type())
default constructor without any initial variable
virtual bool needsReordering() const final
indicates that the translations should never be reordered
The base class for all the tabular database cell translators.
Definition: DBTranslator.h:117
virtual HashTable< std::size_t, std::size_t, ALLOC< std::pair< std::size_t, std::size_t > > > reorder() final
returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones...
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
The databases&#39; cell translators for continuous variables.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual const IContinuousVariable * variable() const final
returns the variable stored into the translator
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value