179 std::unordered_map<ReporterName, std::shared_ptr<TrainingDataBase>>
_training_data;
213 auto data = std::dynamic_pointer_cast<TrainingData<T>>(it->second);
215 mooseError(
"Reporter value ", rname,
" already exists but is of different type.");
220 const std::vector<T> & rval = getReporterValueByName<std::vector<T>>(rname);
222 return std::dynamic_pointer_cast<TrainingData<T>>(
_training_data[rname])->get();
233 virtual dof_id_type
size()
const = 0;
247 virtual dof_id_type
size()
const override {
return _vector.size(); }
const InputParameters & parameters() const
void mooseError(Args &&... args) const
An interface class which manages the model data save and load functionalities from moose objects (suc...
Interface for objects that need to use samplers.
This is the base trainer class whose main functionality is the API for declaring model data.
static InputParameters validParams()
virtual void initialize()
virtual void threadJoin(const UserObject &) final
This is the main trainer base class.
const std::vector< Real > & getPredictorData() const
std::vector< Real > crossValidate()
const bool _doing_cv
Set to true if cross validation is being performed, controls behavior in execute().
void updatePredictorRow()
dof_id_type _local_row
During training loop, this is the local row index of the data.
std::unordered_map< ReporterName, std::shared_ptr< TrainingDataBase > > _training_data
Vector of reporter names and their corresponding values (to be filled by getTrainingData)
virtual std::vector< Real > evaluateModelError(const SurrogateModel &surr)
unsigned int getCurrentSampleSize() const
unsigned int getLocalSampleSize() const
const std::vector< Real > * _rvecval
Vector response value.
const unsigned int & _cv_seed
Seed used for _cv_generator.
std::vector< Real > _row_data
Sampler data for the current row.
virtual void finalize() final
const std::vector< Real > & getSamplerData() const
void checkIntegrity() const
const MooseEnum & _cv_type
Type of cross validation to perform - for now, just 'none' (no CV) or 'k_fold'.
unsigned int & _n_outputs
The number of outputs.
const Real * _rval
Response value.
dof_id_type _row
During training loop, this is the row index of the data.
virtual void execute() final
std::vector< Real > _predictor_data
Predictor data for current row - can be combination of Sampler and Reporter values.
MooseRandom _cv_generator
Random number generator used for shuffling sampler rows during splitting.
const T & getTrainingData(const ReporterName &rname)
const SurrogateModel * _cv_surrogate
SurrogateModel used to evaluate model error relative to test points.
std::vector< dof_id_type > _skip_indices
std::vector< const Real * > _pvals
Predictor values from reporters.
unsigned int _local_sample_size
Number of samples (locally) used to train the model.
static InputParameters validParams()
const unsigned int & _n_splits
Number of splits (k) to split sampler data into.
std::vector< std::vector< Real > > & _cv_trial_scores
RMSE scores from each CV trial - can be grabbed by VPP or Reporter.
unsigned int _n_dims
Dimension of predictor data - either _sampler.getNumberOfCols() or _pvals.size() + _pcols....
std::vector< unsigned int > _pcols
Columns from sampler for predictors.
const unsigned int & _cv_n_trials
Number of repeated trials of cross validation to perform.
unsigned int _current_sample_size
Number of samples used to train the model.
virtual void initialize() final
const bool _skip_unconverged
Whether or not we are skipping samples that have unconverged solutions.
const bool * _converged
Whether or not the current sample has a converged solution.
virtual void setCurrentIndex(dof_id_type index)=0
virtual dof_id_type size() const =0
virtual ~TrainingDataBase()=default
TrainingData(const std::vector< T > &vector)
virtual dof_id_type size() const override
const std::vector< T > & _vector
virtual void setCurrentIndex(dof_id_type index) override