8 #ifndef SWOOSE_MOLECULARMACHINELEARNINGMODEL_H
9 #define SWOOSE_MOLECULARMACHINELEARNINGMODEL_H
12 #include <Eigen/Dense>
19 class MolecularTrajectory;
24 using ForcesCollection = Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor>;
26 namespace MachineLearning {
87 void setDefaultHyperparameters();
89 void trainSingleForceModel(
int atomIndex);
91 std::pair<double, double> evaluateSingleForceModel(
int atomIndex,
int k);
93 Eigen::MatrixXd getEnergyFeatures();
95 Eigen::VectorXd getEnergyTargets();
97 Eigen::MatrixXd getSingleForceFeatures(
int atomIndex);
99 Eigen::MatrixXd getSingleForceTargets(
int atomIndex);
104 std::vector<Utils::MachineLearning::KernelRidgeRegression> forcePredictors_;
106 std::vector<Eigen::VectorXd> coulombMatrixFeatures_;
108 std::vector<std::vector<Eigen::VectorXd>> forcesFeatures_;
110 std::vector<double> refEnergies_;
112 std::vector<ForcesCollection> refForces_;
119 #endif // SWOOSE_MOLECULARMACHINELEARNINGMODEL_H
void setReferenceData(const Utils::MolecularTrajectory &structures, const std::vector< ForcesCollection > &refForces)
Sets the reference data.
Definition: MolecularMachineLearningModel.cpp:20
std::pair< double, double > evaluateForcesModel(int k, bool pooledVariance=true)
Validates the model for the atomic forces via k-fold cross validation.
Definition: MolecularMachineLearningModel.cpp:134
void trainEnergyModel()
Trains the energy model.
Definition: MolecularMachineLearningModel.cpp:73
The combination of the machine learning models for molecular energies and atomic forces.
Definition: MolecularMachineLearningModel.h:32
MolecularMachineLearningModel()=default
Default constructor.
std::pair< double, double > evaluateEnergyModel(int k)
Validates the energy model via k-fold cross validation.
Definition: MolecularMachineLearningModel.cpp:123
Utils::MachineLearning::KernelRidgeRegression & energyPredictor()
Accessor for the underlying energy model.
Definition: MolecularMachineLearningModel.cpp:202
ForcesCollection predictForces(const Utils::AtomCollection &structure)
Predicts the forces for a given structure.
Definition: MolecularMachineLearningModel.cpp:111
double predictEnergy(const Utils::AtomCollection &structure)
Predicts the energy for a given structure.
Definition: MolecularMachineLearningModel.cpp:105
void trainForcesModel()
Trains the forces model.
Definition: MolecularMachineLearningModel.cpp:84
Utils::MachineLearning::KernelRidgeRegression & forcePredictor(int atomIndex)
Accessor for the underlying force model of the atom with index 'atomIndex'.
Definition: MolecularMachineLearningModel.cpp:206