aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBTranslator4ContinuousVariable.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
47#ifndef GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
48#define GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H
49
50#include <string>
51
52#include <agrum/agrum.h>
53
56
57namespace gum {
58
59 namespace learning {
60
61
145 public:
146 // ##########################################################################
148 // ##########################################################################
149
151
153
164 DBTranslator4ContinuousVariable(const std::vector< std::string >& missing_symbols,
165 const bool fit_range = false);
166
168
177 DBTranslator4ContinuousVariable(const bool fit_range = false);
178
180
191 template < typename GUM_SCALAR >
193 const std::vector< std::string >& missing_symbols,
194 const bool fit_range = false);
195
208 template < typename GUM_SCALAR >
210 const bool fit_range = false);
211
213
225 const std::vector< std::string >& missing_symbols,
226 const bool fit_range = false);
227
240 DBTranslator4ContinuousVariable(const IContinuousVariable& var, const bool fit_range = false);
241
244
247
250
253
255
256
257 // ##########################################################################
259 // ##########################################################################
260
262
265
268
270
271
272 // ##########################################################################
274 // ##########################################################################
275
277
279
314 virtual DBTranslatedValue translate(const std::string& str) final;
315
317
321 virtual std::string translateBack(const DBTranslatedValue translated_val) const final;
322
324 virtual std::size_t domainSize() const final;
325
327 virtual bool needsReordering() const final;
328
331 virtual HashTable< std::size_t, std::size_t > reorder() final;
332
334 virtual const IContinuousVariable* variable() const final;
335
337 virtual DBTranslatedValue missingValue() const final;
338
340
341
342#ifndef DOXYGEN_SHOULD_SKIP_THIS
343
344 private:
345 // the ContinuousVariable really used by the translator. As its values
346 // are floats, this speeds-up translations
348
349 // the ContinuousVariablee returned by method variable ()
350 // We must return a IContinuousVariable because the user may have
351 // saved into the translator a ContinuousVariable<X>, with X != float
352 IContinuousVariable* _real_variable_;
353
354 // assign to each float missing symbol a Boolean indicating whether
355 // we already translated it or not. If we translated it, then we cannot
356 // change the range of the variable so that this range contains the symbol.
357 HashTable< std::string, bool > _status_float_missing_symbols_;
358
359 // a string containing a non real missing symbol
360 // (useful for back translations)
361 std::string _nonfloat_missing_symbol_;
362
363 // indicates whether we should fit the range of the observed values
364 bool _fit_range_;
365
366#endif /* DOXYGEN_SHOULD_SKIP_THIS */
367 };
368
369 } /* namespace learning */
370
371} /* namespace gum */
372
373// always include the template implementation
375
377#ifndef GUM_NO_INLINE
379#endif /* GUM_NO_INLINE */
380
381#endif /* GUM_LEARNING_DB_TRANSLATOR_4_CONTINUOUS_VARIABLE_H */
The databases' cell translators for continuous variables.
The base class for all the tabular databases' cell translators.
Defines a continuous random variable.
The class for generic Hash Tables.
Definition hashTable.h:637
A base class for continuous variables, independent of the GUM_SCALAR type.
virtual DBTranslator4ContinuousVariable * clone() const
virtual copy constructor
DBTranslator4ContinuousVariable(const std::vector< std::string > &missing_symbols, const bool fit_range=false)
default constructor without any initial variable
DBTranslator4ContinuousVariable(const ContinuousVariable< GUM_SCALAR > &var, const bool fit_range=false)
default constructor with a continuous variable as translator but without missing symbol
DBTranslator4ContinuousVariable & operator=(const DBTranslator4ContinuousVariable &from)
copy operator
DBTranslator4ContinuousVariable(const IContinuousVariable &var, const bool fit_range=false)
default constructor with a IContinuous variable as translator but without missing symbol
virtual DBTranslatedValue missingValue() const final
returns the translation of a missing value
virtual HashTable< std::size_t, std::size_t > reorder() final
returns an empty mapping, indicating that old tanslations are equal to the newly reordered ones.
DBTranslator4ContinuousVariable(const IContinuousVariable &var, const std::vector< std::string > &missing_symbols, const bool fit_range=false)
default constructor with a IContinuous variable as translator
virtual DBTranslatedValue translate(const std::string &str) final
returns the translation of a string
DBTranslator4ContinuousVariable & operator=(DBTranslator4ContinuousVariable &&from)
move operator
DBTranslator4ContinuousVariable(DBTranslator4ContinuousVariable &&from)
move constructor
virtual bool needsReordering() const final
indicates that the translations should never be reordered
virtual std::string translateBack(const DBTranslatedValue translated_val) const final
returns the original value for a given translation
DBTranslator4ContinuousVariable(const DBTranslator4ContinuousVariable &from)
copy constructor
virtual const IContinuousVariable * variable() const final
returns the variable stored into the translator
DBTranslator4ContinuousVariable(const ContinuousVariable< GUM_SCALAR > &var, const std::vector< std::string > &missing_symbols, const bool fit_range=false)
default constructor with a continuous variable as translator
virtual std::size_t domainSize() const final
returns std::numeric_limits<std::size_t>::max ()
DBTranslator4ContinuousVariable(const bool fit_range=false)
default constructor without any initial variable nor missing symbol
DBTranslator(DBTranslatedValueType val_type, const bool is_lossless, const std::vector< std::string > &missing_symbols, const bool editable_dictionary=true, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
default constructor
Header of ContinuousVariable.
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
STL namespace.
The union class for storing the translated values in learning databases.