Line data Source code
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 : 14 : InputParameters 15 100 : CrossValidationScores::validParams() 16 : { 17 100 : InputParameters params = GeneralReporter::validParams(); 18 100 : params.addClassDescription( 19 : "Tool for extracting cross-validation scores and storing them in a reporter for output."); 20 : 21 200 : params.addRequiredParam<std::vector<UserObjectName>>("models", "Names of surrogate models."); 22 : 23 100 : return params; 24 0 : } 25 : 26 48 : CrossValidationScores::CrossValidationScores(const InputParameters & parameters) 27 48 : : GeneralReporter(parameters), SurrogateModelInterface(this) 28 : { 29 200 : for (const auto & mn : getParam<std::vector<UserObjectName>>("models")) 30 : { 31 104 : _models.push_back(&getSurrogateModelByName(mn)); 32 208 : _cv_scores.push_back(&declareValueByName<std::vector<std::vector<Real>>>(mn)); 33 : } 34 48 : } 35 : 36 : void 37 48 : CrossValidationScores::execute() 38 : { 39 152 : for (unsigned int m = 0; m < _models.size(); ++m) 40 312 : (*_cv_scores[m]) = _models[m]->getModelData<std::vector<std::vector<Real>>>("cv_scores"); 41 48 : }