https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CrossValidationScores.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
11
13
16{
19 "Tool for extracting cross-validation scores and storing them in a reporter for output.");
20
21 params.addRequiredParam<std::vector<UserObjectName>>("models", "Names of surrogate models.");
22
23 return params;
24}
25
27 : GeneralReporter(parameters), SurrogateModelInterface(this)
28{
29 for (const auto & mn : getParam<std::vector<UserObjectName>>("models"))
30 {
31 _models.push_back(&getSurrogateModelByName(mn));
32 _cv_scores.push_back(&declareValueByName<std::vector<std::vector<Real>>>(mn));
33 }
34}
35
36void
38{
39 for (unsigned int m = 0; m < _models.size(); ++m)
40 (*_cv_scores[m]) = _models[m]->getModelData<std::vector<std::vector<Real>>>("cv_scores");
41}
registerMooseObject("StochasticToolsApp", CrossValidationScores)
A tool to output CV scores.
virtual void execute() override
CrossValidationScores(const InputParameters &parameters)
std::vector< const SurrogateModel * > _models
Model to extract CV values from.
static InputParameters validParams()
std::vector< std::vector< std::vector< Real > > * > _cv_scores
Storage for cross-validation scores.
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
T & declareValueByName(const ReporterValueName &value_name, Args &&... args)
Interface for objects that need to use samplers.
T & getSurrogateModelByName(const UserObjectName &name) const
Get a sampler with a given name.