source: src/FunctionApproximation/TrainingData.hpp@ 52e7da

Action_Thermostats Add_AtomRandomPerturbation Add_FitFragmentPartialChargesAction Add_RotateAroundBondAction Add_SelectAtomByNameAction Added_ParseSaveFragmentResults AddingActions_SaveParseParticleParameters Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_ParticleName_to_Atom Adding_StructOpt_integration_tests AtomFragments Automaking_mpqc_open AutomationFragmentation_failures Candidate_v1.5.4 Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator CombiningParticlePotentialParsing Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_BoundInBox_CenterInBox_MoleculeActions Fix_ChargeSampling_PBC Fix_ChronosMutex Fix_FitPartialCharges Fix_FitPotential_needs_atomicnumbers Fix_ForceAnnealing Fix_IndependentFragmentGrids Fix_ParseParticles Fix_ParseParticles_split_forward_backward_Actions Fix_PopActions Fix_QtFragmentList_sorted_selection Fix_Restrictedkeyset_FragmentMolecule Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns Fix_fitting_potentials Fixes ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion FragmentAction_writes_AtomFragments FragmentMolecule_checks_bonddegrees GeometryObjects Gui_Fixes Gui_displays_atomic_force_velocity ImplicitCharges IndependentFragmentGrids IndependentFragmentGrids_IndividualZeroInstances IndependentFragmentGrids_IntegrationTest IndependentFragmentGrids_Sole_NN_Calculation JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix MoreRobust_FragmentAutomation ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PdbParser_setsAtomName PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks Rewrite_FitPartialCharges RotateToPrincipalAxisSystem_UndoRedo SaturateAtoms_findBestMatching SaturateAtoms_singleDegree StoppableMakroAction Subpackage_CodePatterns Subpackage_JobMarket Subpackage_LinearAlgebra Subpackage_levmar Subpackage_mpqc_open Subpackage_vmg Switchable_LogView ThirdParty_MPQC_rebuilt_buildsystem TrajectoryDependenant_MaxOrder TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps TremoloParser_setsAtomName Ubuntu_1604_changes stable
Last change on this file since 52e7da was 68172a, checked in by Frederik Heber <heber@…>, 12 years ago

Shifted class TrainingData into its own module.

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * TrainingData.hpp
3 *
4 * Created on: 15.10.2012
5 * Author: heber
6 */
7
8#ifndef TRAININGDATA_HPP_
9#define TRAININGDATA_HPP_
10
11// include config.h
12#ifdef HAVE_CONFIG_H
13#include <config.h>
14#endif
15
16#include <iosfwd>
17#include <boost/function.hpp>
18
19#include "Fragmentation/Homology/HomologyContainer.hpp"
20#include "FunctionApproximation/FunctionApproximation.hpp"
21
22class Fragment;
23
24/** This class encapsulates the training data for a given potential function
25 * to learn.
26 *
27 * The data is added piece-wise by calling the operator() with a specific
28 * Fragment.
29 */
30class TrainingData
31{
32public:
33 //!> typedef for a range within the HomologyContainer at which fragments to look at
34 typedef std::pair<
35 HomologyContainer::const_iterator,
36 HomologyContainer::const_iterator> range_t;
37 //!> Training tuple input vector pair
38 typedef FunctionApproximation::inputs_t InputVector_t;
39 //!> Training tuple output vector pair
40 typedef FunctionApproximation::outputs_t OutputVector_t;
41 //!> Typedef for a function containing how to extract required information from a Fragment.
42 typedef boost::function< FunctionModel::arguments_t (const Fragment &, const size_t)> extractor_t;
43
44public:
45 /** Constructor for class TrainingData.
46 *
47 */
48 explicit TrainingData(const extractor_t &_extractor) :
49 extractor(_extractor)
50 {}
51 /** Destructor for class TrainingData.
52 *
53 */
54 ~TrainingData()
55 {}
56
57 /** We go through the given \a range of homologous fragments and call
58 * TrainingData::extractor on them in order to gather the distance and
59 * the energy value, stored internally.
60 *
61 * \param range given range within a HomologyContainer of homologous fragments
62 */
63 void operator()(const range_t &range);
64
65 /** Getter for const access to internal training data inputs.
66 *
67 * \return const ref to training tuple of input vector
68 */
69 const InputVector_t& getTrainingInputs() const {
70 return DistanceVector;
71 }
72
73 /** Getter for const access to internal training data outputs.
74 *
75 * \return const ref to training tuple of output vector
76 */
77 const OutputVector_t& getTrainingOutputs() const {
78 return EnergyVector;
79 }
80
81 /** Calculate the L2 error of a given \a model against the stored training data.
82 *
83 * \param model model whose L2 error to calculate
84 * \return sum of squared differences at training tuples
85 */
86 const double getL2Error(const FunctionModel &model) const;
87
88 /** Calculate the Lmax error of a given \a model against the stored training data.
89 *
90 * \param model model whose Lmax error to calculate
91 * \return maximum difference over all training tuples
92 */
93 const double getLMaxError(const FunctionModel &model) const;
94
95private:
96 // prohibit use of default constructor, as we always require extraction functor.
97 TrainingData();
98
99private:
100 //!> private training data vector
101 InputVector_t DistanceVector;
102 OutputVector_t EnergyVector;
103 //!> function to be used for training input data extraction from a fragment
104 const extractor_t extractor;
105};
106
107// print training data for debugging
108std::ostream &operator<<(std::ostream &out, const TrainingData &data);
109
110#endif /* TRAININGDATA_HPP_ */
Note: See TracBrowser for help on using the repository browser.