MRCpy.phi
.ThresholdPhi
- class MRCpy.phi.ThresholdPhi(n_classes, fit_intercept=True, n_thresholds=200, one_hot=False)[source]
Threshold features
A threshold feature is a function, \(f(x_d,t)=1\) when \(x_d<t\) and 0 otherwise, for a given x in dimension d and threshold t in that dimension. A product of threshold features is an indicator of a region and its expectation is closely related to cumulative distributions. This class obtains the thresholds fitting multiple one-dimensional decision stumps on the training data.
See also
For more information about MRC, one can refer to the
following resources:
- Parameters:
- n_classes
int
Number of classes in the dataset
- fit_intercept
bool
, default =True
Whether to calculate the intercept. If set to false, no intercept will be used in calculations (i.e. data is expected to be already centered).
- one_hot
bool
, default =False
Controls the method used for evaluating the features of the given instances in the binary case. Only applies in the binary case, namely, only when there are two classes. If set to true, one-hot-encoding will be used. If set to false a more efficient shorcut will be performed.
- n_thresholds
int
, default =200
Maximum number of allowed threshold values for each dimension.
- n_classes
- Attributes:
- self.thrsVal
array
-like of shape (n_thresholds
) Threshold values learned from the training data.
- self.thrsDim
array
-like of shape (n_thresholds
) Dimensions corresponding to the learned threshold value in
self.thrsVal
.- is_fitted_
bool
Whether the feature mappings has learned its hyperparameters (if any) and the length of the feature mapping is set.
- len_
int
Length of the feature mapping vector.
- self.thrsVal
Methods
d_tree_split
(X, Y[, n_thresholds])Learn the univariate thresholds by using the split points of decision trees for each dimension of data.
est_exp
(X, Y)Average value of \(\phi(x,y)\) in the supervised dataset (X,Y).
est_std
(X, Y)Standard deviation of \(\phi(x,y)\) in the supervised dataset (X,Y).
eval_x
(X)Evaluates the one-hot encoded features of the given instances i.e., X, \(\phi(x,y)\), x \(\in\) X and all the labels.
eval_xy
(X, Y)Evaluates the one-hot encoded features of the given instances i.e., X, \(\phi(x,y)\), x \(\in\) X and y \(\in\) Y.
fit
(X[, Y])Learns the set of thresholds using one-dimensional decision stumps obtained from the dataset.
transform
(X)Compute the threshold features (0/1) by comparing with the thresholds obtained in each dimension.
- d_tree_split(X, Y, n_thresholds=None)[source]
Learn the univariate thresholds by using the split points of decision trees for each dimension of data.
- Parameters:
- Returns:
- est_exp(X, Y)
Average value of \(\phi(x,y)\) in the supervised dataset (X,Y). Used in the learning stage to estimate the expectation of \(\phi(x,y)\), denoted by \({\tau}\)
- est_std(X, Y)
Standard deviation of \(\phi(x,y)\) in the supervised dataset (X,Y). Used in the learning stage to estimate the variance in the expectation of \(\phi(x,y)\), denoted by \(\lambda\)
- eval_x(X)
Evaluates the one-hot encoded features of the given instances i.e., X, \(\phi(x,y)\), x \(\in\) X and all the labels. The output is 3D matrix that is composed of 2D matrices corresponding to each of the instance. These 2D matrices are the one-hot encodings of the instances’ features corresponding to all the possible labels in the data.
- Parameters:
- Returns:
- phi
array
-like of shape (
n_samples
,n_classes
,n_features
*n_classes
)Matrix containing the one-hot encoding for all the classes for each of the instances given.
- phi
- eval_xy(X, Y)
Evaluates the one-hot encoded features of the given instances i.e., X, \(\phi(x,y)\), x \(\in\) X and y \(\in\) Y. The encodings are calculated, corresponding to the given labels, which is used by the learning stage for estimating the expectation of \(\phi(x,y)\).
- Parameters:
- Returns:
- phi
array
-like of shape (
n_samples
,n_features
*n_classes
)Matrix containing the one-hot encoding with respect to the labels given for all the instances.
- phi
- fit(X, Y=None)[source]
Learns the set of thresholds using one-dimensional decision stumps obtained from the dataset.
- Parameters:
- Returns:
- self
Fitted estimator
- transform(X)[source]
Compute the threshold features (0/1) by comparing with the thresholds obtained in each dimension.
- Parameters:
- Returns:
- X_feat
array
-like of shape (n_samples
,n_features
) Transformed features from the given instances.
- X_feat