LinearRegressionEstimator#
Currently, this API is unsupported in Python
-
class LinearRegressionEstimator : public helayers::SaveableBasic#
A class for fitting and/or predicting with a Linear-Regression Model based on training or inference inputs.
Public Functions
-
inline LinearRegressionEstimator(const HeContext &he)#
Construct a new LinearRegressionEstimator object.
- Parameters:
he – The cryptographic context used to make the computations
-
inline void setEstimatedXDistributionNormal(double mean, double std)#
Assume that X distributes according to a normal distribution.
- Parameters:
mean – Mean of normal distribution of X
std – Standard-Deviation of normal distribution of X
-
inline void setEstimatedXDistributionUniform(double min, double max)#
Assume that X distributes according to a uniform distribution.
- Parameters:
min – Min of uniform distribution of X
max – Max of uniform distribution of X
-
inline void setEstimatedXDistributionUnknownInRange(double min, double max)#
Assume that X distributes according to a uniform distribution.
- Parameters:
min – Min of uniform distribution of X
max – Max of uniform distribution of X
-
void addInput(CTileTensorCPtr input)#
Add an input to the set of inputs used for training.
- Parameters:
input –
-
void fit()#
Train the model parameters based on the previously added inputs.
-
inline const CTileTensor &getPhi0()#
Get Phi0.
-
inline const CTileTensor &getPhi1()#
Get Phi1.
-
inline const CTileTensor &getPhi0() const#
Gets the fitted phi0 (intercept) Linear-Regression parameter.
-
inline const CTileTensor &getPhi1() const#
Gets the fitted phi1 (slope) Linear-Regression parameter.
-
inline void setVerbosity(Verbosity _verbosity)#
Sets the verbosity of the debug information logged by this class.
- Parameters:
_verbosity – The required verbosity level.
-
virtual void debugPrint(const std::string &title = "", Verbosity verbosity = VERBOSITY_REGULAR, std::ostream &out = std::cout) const override#
Prints the content of this object.
- Parameters:
title – Text to add to the print
verbosity – Verbosity level
out – Output stream
-
virtual std::streamoff save(std::ostream &stream) const override#
Saves this object to a stream in binary form.
Returns the number of bytes written to the output stream.
- Parameters:
stream – [in] output stream to write to
-
virtual std::streamoff load(std::istream &stream) override#
Loads this object from the given stream.
Returns the number of bytes read from the input stream.
- Parameters:
stream – [in] input stream to read from
Public Static Functions
-
static DoubleTensor getSimulatedInputsUniform(double phi0, double phi1, double minX, double maxX, int numSamples, int seed = 17)#
Get simulated (fabricated) random inputs nicely modeled by Linear-Regression where the X values are distributed uniformly in a given range.
- Parameters:
phi0 – The intercept of the Linear-Regression model.
phi1 – The slope of the Linear-Regression model.
minX – Bottom of range of X values to simulate.
maxX – Top of range of X values to simulate.
numSamples – Number of samples generated.
seed – Random seed for consistent samples in test.
-
static DoubleTensor getSimulatedInputsNormal(double phi0, double phi1, double meanX, double stdX, int numSamples, int seed = 17)#
Get simulated (fabricated) random inputs nicely modeled by Linear-Regression where the X values are distributed normally with a give mean and standard-deviation.
- Parameters:
phi0 – The intercept of the Linear-Regression model.
phi1 – The slope of the Linear-Regression model.
meanX – Mean of normally distributed X values.
stdX – Standard-deviation of normally distributed X values.
numSamples – Number of samples generated.
seed – Random seed for consistent samples in test.
-
static void packDoubleTensor(CTileTensor &out, const DoubleTensor &doubleTensor)#
Pack an input DoubleTensor into a CTileTensor in the correct packing for the estimator.
- Parameters:
out – The output CTileTensor.
doubleTensor – The input DoubleTensor.
-
inline LinearRegressionEstimator(const HeContext &he)#