24 "regression_type", rtype,
"The type of regression to perform.");
26 "Maximum polynomial degree to use for the regression.");
27 params.
addParam<
Real>(
"penalty", 0.0,
"Penalty for Ridge regularization.");
34 _predictor_row(getPredictorData()),
35 _regression_type(getParam<
MooseEnum>(
"regression_type")),
36 _penalty(getParam<
Real>(
"penalty")),
37 _coeff(declareModelData<
std::vector<
std::vector<
Real>>>(
"_coeff")),
39 declareModelData<unsigned
int>(
"_max_degree", getParam<unsigned
int>(
"max_degree"))),
40 _power_matrix(declareModelData<
std::vector<
std::vector<unsigned
int>>>(
42 StochasticTools::MultiDimPolynomialGenerator::generateTuple(_n_dims, _max_degree + 1))),
43 _n_poly_terms(_power_matrix.size()),
44 _matrix(_n_poly_terms, _n_poly_terms),
45 _rhs(1, DenseVector<
Real>(_n_poly_terms, 0.0)),
56 mooseError(
"Number of data points must be greater than the number of terms in the polynomial.");
72 for (
unsigned int r = 0; r <
_rhs.size(); ++r)
77 calc->initializeCalculator();
94 for (
unsigned int r =
_rhs.size(); r <
_rvecval->size(); ++r)
103 for (
unsigned int ii = 0; ii <
_n_dims; ++ii)
109 for (
unsigned int jj = 0; jj <
_n_dims; ++jj)
116 for (
unsigned int c = i * 3;
c < (i + 1) * 3; ++
c)
122 for (
unsigned int r = 0; r <
_rvecval->size(); ++r)
123 _rhs[r](i) += i_value * (*_rvecval)[r];
129 for (
unsigned int r = 0; r <
_rvecval->size(); ++r)
142 unsigned int nrval =
_rhs.size();
144 for (
unsigned int r =
_rhs.size(); r < nrval; ++r)
152 for (
auto & it :
_rhs)
160 calc->finalizeCalculator(
true);
170 sig[i] = i > 0 ?
_calculators[3 * i + 1]->getValue() : 1.0;
175 const Real n = sum_pf[0];
184 for (
unsigned int r = 0; r <
_rhs.size(); ++r)
188 DenseVector<Real> sol;
191 for (
unsigned int r = 0; r <
_rhs.size(); ++r)
194 _coeff[r] = sol.get_values();
virtual void preTrain() override
virtual void train() override
const unsigned int _n_poly_terms
Number of terms in the polynomial expression.
const Real * _rval
Response value.
unsigned int _n_dims
Dimension of predictor data - either _sampler.getNumberOfCols() or _pvals.size() + _pcols...
virtual void zero() override final
virtual void postTrain() override
const std::vector< Real > * _rvecval
Vector response value.
const std::vector< Real > & _predictor_row
Data from the current predictor row.
std::vector< std::unique_ptr< RealCalculator > > _calculators
Calculators used in standardizing polynomial features.
std::vector< std::vector< Real > > & _coeff
Coefficients of regression model.
const Real & _penalty
The penalty parameter for Ridge regularization.
std::vector< Real > _r_sum
Calculator used to sum response values.
void mooseWarning(Args &&... args) const
PolynomialRegressionTrainer(const InputParameters ¶meters)
const std::vector< std::vector< unsigned int > > & _power_matrix
Matirx co containing the touples of the powers for each term.
static const std::string mu
const unsigned int & _max_degree
Maximum polynomial degree, limiting the sum of constituent polynomial degrees.
std::vector< Real > & get_values()
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
dof_id_type getNumberOfRows() const
void lu_solve(const DenseVector< Real > &b, DenseVector< Real > &x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
This is the main trainer base class.
std::vector< DenseVector< Real > > _rhs
const MooseEnum & _regression_type
Types for the polynomial regression.
IntRange< T > make_range(T beg, T end)
void mooseError(Args &&... args) const
static const std::complex< double > j(0, 1)
Complex number "j" (also known as "i")
static InputParameters validParams()
static InputParameters validParams()
DenseMatrix< Real > _matrix
void ErrorVector unsigned int
registerMooseObject("StochasticToolsApp", PolynomialRegressionTrainer)