PlainModelHyperParams#
- class PlainModelHyperParams#
A struct for the hyperparameters of the plain AI model.
- property aml_delta#
The weight of the risk of the other banks in the evaluation of the risks of the next iteration in the Aml model
- property aml_iterations#
The number of iterations in the AML model.
- property d#
number of differentiations
- Type:
Arima model parameter
- property feature_ranges#
A list of pairs specifying the minimum and maximum supported values for each feature for XGBoost and DTree
- property features_bin_size#
Controls the approximation of the feature values and thresholds for XGBoost and DTree. The feature values will be approximated to the closest multiple of features_bin_size. The thresholds will be approximated to the mid-point between the two closest multiples of features_bin_size.
- property features_scale_target#
Controls the scale of the features and thresholds for XGBoost and DTree. The features and thresholds will be scaled so they will be in the range [0, featuresScaleTarget]. Defaults to 500.
- property fit_hyper_params#
Hyper parameters common to most fitting algorithm
- property frep#
Controls the accuracy of the comparison approximation in XGBoost and DTree prediction. A higher frep increases the accuracy on the account of deeper and slower computation.
- property grep#
Controls the accuracy of the comparison approximation in XGBoost and DTree prediction. A higher grep increases the accuracy on the account of deeper and slower computation.
- property init_random_weights#
Initialize the PlainModel with random weights.
- property inverse_approximation_precision#
The approximation precision of the linear regression inverse operation.
- property linear_regression_distribution_x#
The distribution type of X values in linear regression training
- property linear_regression_max_x#
The maximum of the values of X in linear regression training with uniform or unknown distribution.
- property linear_regression_mean_x#
The mean of the values of X in linear regression training with normal distribution.
- property linear_regression_min_x#
The minimum of the values of X in linear regression training with uniform or unknown distribution.
- property linear_regression_std_x#
The standard deviation of the values of X in linear regression training with normal distribution.
- load(self: pyhelayers.PlainModelHyperParams, file: str) None #
Load the object from JSON file.
- Parameters:
file – The name of the JSON file.
- load_from_buffer(self: pyhelayers.PlainModelHyperParams, buffer: bytes) None #
Load the object from JSON buffer.
- Parameters:
buffer – The buffer to load from.
- property logistic_regression_activation#
Activation used in logistic regression.
- property max_rand_value#
Relevant when init_random_weights is set to True. An upper limit for the random values.
- property min_rand_value#
Relevant when init_random_weights is set to True. A lower limit for the random values.
- property model_specified_fixed_batch_size#
Indication to whether a model-specified fixed batch size is effective (default: false). With such fixed batch size, the batch size is fixed to the batch size specified in the plain NN model, and future runs of predict with the plain model and the HE model created from it, must provide exactly that much elements per batch. If this flag is turned off, the batch size is dynamic, meaning it can be changed and the HE model can be optimized for any batch size desired, but in this case the batch dimension must not be changed, manipulated or involved in operations by the NN in any way.
- property model_subclass#
A named parameter allowing to specify some specific model type, e.g., a specific class of NN architecture.
- property mu#
The mu coefficient of the Arima model.
- property negate_sigmoid_input#
Whether to negate the input to the Sigmoid activation function.
- property num_accounts#
The combined number of accounts at all banks in the Aml model.
- property num_centers#
The number of centers for KMeans.
- property num_samples#
Number of values to use for fitting and training.
- property num_values_used_for_prediction#
The number of previous values of the time series to be used in prediction. A greater value will increase the prediction precision (compared to a plain ARIMA model) on the account of higher multiplication depth.
- property number_of_cached_nodes#
Number of nodes that are shared among trees and their results are cached as an optimization.
- property number_of_classes#
Number of classes.
- property number_of_features#
Number of features in an input sample. Value of -1 indicates it will be determined by the model file.
- property p#
number of past values effecting current value
- Type:
Arima model parameter
- property phi#
The phi coefficients of the Arima model.
- property plain_batch_norm_in_encrypted_nn#
An indication to whether the batch normalization constants of an encrypted NN should remain exposed in a plaintext form and not be encrypted. May often result in improved performance. Not relevant for non-encrypted NN.
- property plain_poly_activation_coeffs_in_encrypted_nn#
An indication to whether the coefficients of a polynomial activation function of an encrypted NN should remain exposed in a plaintext form and not be encrypted. May often result in improved performance. Not relevant for non-encrypted NN.
- property q#
number of past errors effecting current value
- Type:
Arima model parameter
- property round_before_storing_thresholds#
In case storeThresholds is true, decides whether the thresholds should be scaled and rounded before they are stored. Turning this flag on makes close thresholds considered the same one, thus reducing runtime on the account of possibly reducing accuracy.
- property sparse_rate#
Relevant when init_random_weights is set to True. The rate of zeroed values. Must be in the range of [0,1]. For example, 0 means no values will be set to zero, while 0.3 means ~30% of the values will be set to zero and ~70% will get values in the range of [min,max).
- property store_thresholds#
If true, XGBoost and DTree will store all thresholds of the model in the user side, in the plain. This has the advantage of making prediction faster and more accurate, on the account of storing additional, possibly sensitive, data in the user side, and requiring the user to do some additional pre-processing. Note that the additional data will be kept in the user side and it will not be exposed to the server at any time.
- property theta1#
The theta1 coefficient of the Arima model.
- property trainable#
Whether the PlainModel object should allow to call fit().
- property use_linear_regression_estimator#
- property varw#
The error variance of the Arima model.
- property verbose#
Verbosity flag.
-
struct PlainModelHyperParams#
A struct for the hyperparameters of the plain AI model.
Public Functions
-
void load(const std::string &hyperParamsJsonFile)#
Load the object from JSON file.
- Parameters:
hyperParamsJsonFile – The name of the JSON file.
-
void load(std::istream &hyperParamsJsonStream)#
Load the object from streams containing JSON file content.
- Parameters:
hyperParamsJsonStream – The stream.
-
void load(const JsonWrapper &hyperParams)#
Load the object from JSON wrapper.
- Parameters:
hyperParams – The JSON wrapper.
-
void loadBin(std::istream &stream)#
Loads this object from the given binary stream.
- Parameters:
stream – The stream to load from.
-
void saveBin(std::ostream &stream) const#
Saves this object to the given binary stream.
- Parameters:
stream – The stream to save to.
Public Members
-
bool debugMode = false#
Debug mode.
-
bool verbose = false#
Verbosity flag.
-
bool trainable = false#
Whether the PlainModel object should allow to call fit().
-
bool initRandomWeights = false#
Initialize the PlainModel with random weights.
-
double minRandValue = -0.5#
Constraints over the random values in case where random weights are used.
-
double maxRandValue = 0.5#
-
double sparseRate = 0#
-
FitHyperParams fitHyperParams#
Hyper parameters common to most fitting algorithm.
-
int numberOfFeatures = -1#
Number of features in an input sample.
Value of -1 indicates it will be determined by the model file.
-
std::string modelSubclass = ""#
A named parameter allowing to specify some specific model type, e.g., a specific class of NN architecture.
-
LRActivationType logisticRegressionActivation = LR_ACTIVATION_DEFAULT#
Activation used in logistic regression.
-
bool negateSigmoidInput = false#
Whether to negate the input to the Sigmoid activation function.
-
int numberOfClasses = 2#
Number of classes.
-
bool useLinearRegressionEstimator = true#
Whether to use the linear regression estimator (that provides a closed solution, but is limited to a single feature) when performing linear regression fit, or use gradient descent algorithm.
-
LRDistribution linearRegressionDistributionX = LR_UNIFORM_DISTRIBUTION#
The distribution type of X values in linear regression training.
-
double linearRegressionMinX = 0.0#
The minimum of the values of X in linear regression training with uniform or unknown distribution.
-
double linearRegressionMaxX = 1.0#
The maximum of the values of X in linear regression training with uniform or unknown distribution.
-
double linearRegressionMeanX = 0.0#
The mean of the values of X in linear regression training with normal distribution.
-
double linearRegressionStdX = 1.0#
The standard deviation of the values of X in linear regression training with normal distribution.
-
int inverseApproximationPrecision = 5#
The approximation precision of the linear regression inverse operation.
-
int p = 1#
The number of past time lags to depend on.
-
int d = 0#
The number of differentiations.
-
int q = 1#
The number of past errors to depend on.
-
int numValuesUsedForPrediction = -1#
See ArimaPlain::numValuesUsedForPrediction.
-
int numSamples = -1#
See ArimaPlain::numSamples.
-
double mu = std::nan("0")#
The mu coefficient of the ARIMA model, which has the following formula: x_(t+1) = mu + sum(phi[i]*x[t-i]) + theta1*e[t] + e_[t+1].
-
std::vector<double> phi#
The phi coefficients of the ARIMA model, which has the following formula: x_(t+1) = mu + sum(phi[i]*x[t-i]) + theta1*e[t] + e_[t+1].
-
double theta1 = std::nan("0")#
The theta1 coefficient of the ARIMA model, which has the following formula: x_(t+1) = mu + sum(phi[i]*x[t-i]) + theta1*e[t] + e_[t+1].
-
double varw = std::nan("0")#
The variance of the error of the ARIMA model.
-
int numCenters = -1#
The number of centers.
-
double featuresScaleTarget = 500#
Controls the scale of the features and thresholds.
The features and thresholds will be scaled so they will be in the range [0, featuresScaleTarget].
-
int featuresBinSize = 4#
Controls the approximation of the feature values and thresholds.
The feature values will be approximated to the closest multiple of featuresBinSize. The thresholds will be approximated to the mid-point between the two closest multiples of featuresBinSize.
-
int gRep = 3#
Controls the accuracy of the comparison approximation in XGBoost and DTree prediction.
A higher grep increases the accuracy on the account of deeper and slower computation.
-
int fRep = 1#
Controls the accuracy of the comparison approximation in XGBoost and DTree prediction.
A higher frep increases the accuracy on the account of deeper and slower computation.
-
std::vector<std::pair<double, double>> featureRanges#
A vector specifying the minimum and maximum supported values for each feature.
-
int numberOfCachedNodes = 10#
Number of nodes that are shared among trees and their results are cached as an optimization.
-
bool storeThresholds = false#
If true, XGBoost and DTree will store all thresholds of the model in the user side, in the plain.
This has the advantage of making prediction faster and more accurate, on the account of storing additional, possibly sensitive, data in the user side, and requiring the user to do some additional pre-processing. Note that the additional data will be kept in the user side and it will not be exposed to the server at any time.
-
bool roundBeforeStoringThresholds = false#
In case storeThresholds is true, decides whether the thresholds should be scaled and rounded before they are stored.
Turning this flag on makes close thresholds considered the same one, thus reducing runtime on the account of possibly reducing accuracy.
-
bool modelSpecifiedFixedBatchSize = false#
Indication to whether a model-specified fixed batch size is effective (default: false).
With such fixed batch size, the batch size is fixed to the batch size specified in the plain NN model, and future runs of predict with the plain model and the HE model created from it, must provide exactly that much elements per batch. If this flag is turned off, the batch size is dynamic, meaning it can be changed and the HE model can be optimized for any batch size desired, but in this case the batch dimension must not be changed, manipulated or involved in operations by the NN in any way.
-
bool plainPolyActivationCoeffsInEncryptedNn = false#
An indication to whether the coefficients of a polynomial activation function of an encrypted NN should remain exposed in a plaintext form and not be encrypted.
May often result in improved performance. Not relevant for non-encrypted NN.
-
bool plainBatchNormInEncryptedNn = false#
An indication to whether the batch normalization constants of an encrypted NN should remain exposed in a plaintext form and not be encrypted.
May often result in improved performance. Not relevant for non-encrypted NN.
-
double amlDelta = 0.5#
The weight of the risk of the other banks in the evaluation of the risks of the next iteration.
-
double amlIterations = 0.5#
The number of iterations in the AML model.
-
int numAccounts = 0#
The combined number of accounts at all banks.
-
void load(const std::string &hyperParamsJsonFile)#