/usr/include/openturns/GeneralizedLinearModelAlgorithm.hxx is in libopenturns-dev 1.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | // -*- C++ -*-
/**
* @brief The class builds generalized linear models
*
* Copyright 2005-2015 Airbus-EDF-IMACS-Phimeca
*
* This library is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef OPENTURNS_GENERALIZEDLINEARMODELALGORITHM_HXX
#define OPENTURNS_GENERALIZEDLINEARMODELALGORITHM_HXX
#include "MetaModelAlgorithm.hxx"
#include "Basis.hxx"
#include "CovarianceModel.hxx"
#include "KrigingResult.hxx"
#include "HMatrix.hxx"
#include "OptimizationSolver.hxx"
#include "GeneralizedLinearModelResult.hxx"
BEGIN_NAMESPACE_OPENTURNS
/**
* @class GeneralizedLinearModelAlgorithm
*
* The class building generalized linear model
*/
class OT_API GeneralizedLinearModelAlgorithm
: public MetaModelAlgorithm
{
CLASSNAME;
public:
typedef GeneralizedLinearModelResult::BasisCollection BasisCollection;
typedef GeneralizedLinearModelResult::BasisPersistentCollection BasisPersistentCollection;
/** Default constructor */
GeneralizedLinearModelAlgorithm();
/** Parameters constructor */
GeneralizedLinearModelAlgorithm (const NumericalSample & inputSample,
const NumericalSample & outputSample,
const CovarianceModel & covarianceModel,
const Bool normalize = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-NormalizeData"),
const Bool keepCovariance = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-KeepCovariance"));
GeneralizedLinearModelAlgorithm (const NumericalSample & inputSample,
const NumericalSample & outputSample,
const CovarianceModel & covarianceModel,
const Basis & basis,
const Bool normalize = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-NormalizeData"),
const Bool keepCovariance = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-KeepCovariance"));
/** Parameters constructor */
GeneralizedLinearModelAlgorithm (const NumericalSample & inputSample,
const NumericalMathFunction & inputTransformation,
const NumericalSample & outputSample,
const CovarianceModel & covarianceModel,
const Basis & basis,
const Bool keepCovariance = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-KeepCovariance"));
/** Parameters constructor */
GeneralizedLinearModelAlgorithm (const NumericalSample & inputSample,
const NumericalSample & outputSample,
const CovarianceModel & covarianceModel,
const BasisCollection & multivariateBasis,
const Bool normalize = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-NormalizeData"),
const Bool keepCovariance = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-KeepCovariance"));
/** Parameters constructor */
GeneralizedLinearModelAlgorithm (const NumericalSample & inputSample,
const NumericalMathFunction & inputTransformation,
const NumericalSample & outputSample,
const CovarianceModel & covarianceModel,
const BasisCollection & multivariateBasis,
const Bool keepCovariance = ResourceMap::GetAsBool("GeneralizedLinearModelAlgorithm-KeepCovariance"));
/** Virtual constructor */
GeneralizedLinearModelAlgorithm * clone() const;
/** String converter */
String __repr__() const;
/** Perform regression */
void run();
/** input transformation accessor */
void setInputTransformation(const NumericalMathFunction & inputTransformation);
NumericalMathFunction getInputTransformation() const;
/** Sample accessors */
NumericalSample getInputSample() const;
NumericalSample getOutputSample() const;
/** result accessor */
GeneralizedLinearModelResult getResult();
/** Objective function (log-Likelihood) accessor */
NumericalMathFunction getObjectiveFunction();
/** Optimization solver accessor */
OptimizationSolver getOptimizationSolver() const;
void setOptimizationSolver(const OptimizationSolver & solver);
/** Method save() stores the object through the StorageManager */
virtual void save(Advocate & adv) const;
/** Method load() reloads the object from the StorageManager */
virtual void load(Advocate & adv);
protected:
// Optimize the log-likelihood
NumericalPoint optimizeLogLikelihood();
// Compute the output log-likelihood function
NumericalScalar computeLogLikelihood(const NumericalPoint & theta) const;
NumericalScalar computeLapackLogLikelihood(const NumericalPoint & theta) const;
NumericalScalar computeHMatLogLikelihood(const NumericalPoint & theta) const;
// Compute the design matrix on the normalized input sample
void computeF();
// Normalize the input sample
void normalizeInputSample();
/** Method accessor (lapack/hmat) */
void initializeMethod();
void setMethod(const UnsignedInteger method);
// Initialize default optimization solver
void initializeDefaultOptimizationSolver();
friend class Factory<GeneralizedLinearModelAlgorithm>;
friend class KrigingAlgorithm;
NumericalPoint getRho() const;
private:
/** set sample method */
void setData(const NumericalSample & inputSample,
const NumericalSample & outputSample);
/** set covariance method */
void setCovariance(const CovarianceModel & covarianceModel);
/** Set basis collection method */
void setBasis(const BasisCollection & basisCollection);
/** check that sample is centered to precison eps */
void checkYCentered(const NumericalSample & Y);
// The input data
NumericalSample inputSample_;
// Standardized version of the input data
NumericalSample normalizedInputSample_;
// Standardization funtion
NumericalMathFunction inputTransformation_;
mutable Bool normalize_;
// The associated output data
NumericalSample outputSample_;
// The covariance model parametric familly
CovarianceModel covarianceModel_;
// The member of the covariance model fitted to the data
CovarianceModel conditionalCovarianceModel_;
// The optimization algorithm used for the meta-parameters estimation
mutable OptimizationSolver solver_;
// The coefficients of the current output conditional expectation part
mutable NumericalPoint beta_;
// Temporarly used to compute gamma
mutable NumericalPoint rho_;
// The current output Gram matrix
mutable Matrix F_;
/** Result */
GeneralizedLinearModelResult result_;
/** BasisCollection */
BasisPersistentCollection basis_;
/** Cholesky factor ==> TriangularMatrix */
mutable TriangularMatrix covarianceCholeskyFactor_;
/** Cholesky factor when using hmat-oss */
mutable HMatrix covarianceHMatrix_;
/** Boolean argument for keep covariance */
mutable Bool keepCovariance_;
/** Method : 0 (lapack), 1 (hmat) */
UnsignedInteger method_;
/** Bool to tell if optimization has run */
Bool hasRun_;
}; // class GeneralizedLinearModelAlgorithm
END_NAMESPACE_OPENTURNS
#endif
|