https://mooseframework.inl.gov
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 
10 #include "CrossValidationScores.h"
11 
12 registerMooseObject("StochasticToolsApp", CrossValidationScores);
13 
16 {
18  params.addClassDescription(
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 
36 void
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 }
T & declareValueByName(const ReporterValueName &value_name, Args &&... args)
static InputParameters validParams()
registerMooseObject("StochasticToolsApp", CrossValidationScores)
std::vector< const SurrogateModel * > _models
Model to extract CV values from.
T & getSurrogateModelByName(const UserObjectName &name) const
Get a sampler with a given name.
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
const T & getParam(const std::string &name) const
CrossValidationScores(const InputParameters &parameters)
std::vector< std::vector< std::vector< Real > > * > _cv_scores
Storage for cross-validation scores.
virtual void execute() override
Interface for objects that need to use samplers.
A tool to output CV scores.
void addClassDescription(const std::string &doc_string)