graforvfl.shared package¶
graforvfl.shared.activator module¶
This module provides a comprehensive collection of activation functions used in machine learning and deep learning. Activation functions play a critical role in neural networks by introducing non-linearity, enabling the network to learn and approximate complex patterns in data.
Functions:¶
- none(x):
A no-op function that returns the input as is.
- relu(x):
Rectified Linear Unit (ReLU), returns the input if positive, otherwise returns zero.
- leaky_relu(x, alpha=0.01):
Leaky ReLU allows a small gradient when the input is negative.
- celu(x, alpha=1.0):
Continuously Differentiable Exponential Linear Unit, a smooth alternative to ReLU.
- prelu(x, alpha=0.5):
Parametric ReLU, where the slope for negative inputs is a learnable parameter.
- gelu(x, alpha=0.044715):
Gaussian Error Linear Unit, combines tanh approximation for smooth activation.
- elu(x, alpha=1):
Exponential Linear Unit, returns an exponential for negative inputs.
- selu(x, alpha=1.67326324, scale=1.05070098):
Scaled Exponential Linear Unit, normalizes outputs for self-normalizing networks.
- rrelu(x, lower=1./8, upper=1./3):
Randomized Leaky ReLU, introduces randomized slopes for negative inputs.
- tanh(x):
Hyperbolic tangent function, outputs values between -1 and 1.
- hard_tanh(x, lower=-1., upper=1.):
A clipped version of the tanh function.
- sigmoid(x):
Logistic sigmoid function, outputs values between 0 and 1.
- hard_sigmoid(x, lower=-2.5, upper=2.5):
A piecewise linear approximation of the sigmoid function.
- log_sigmoid(x):
Logarithmic sigmoid function for numerical stability.
- swish(x):
Swish (or SiLU), smooth and bounded non-linearity.
- hard_swish(x, lower=-3., upper=3.):
A piecewise linear approximation of the swish function.
- soft_plus(x, beta=1.0):
Smooth approximation of the ReLU function.
- mish(x, beta=1.0):
Mish activation, smooth non-monotonic function.
- soft_sign(x):
Smooth approximation of the sign function.
- tanh_shrink(x):
Difference between input and tanh, providing a shrinkage effect.
- soft_shrink(x, alpha=0.5):
Threshold-based shrinkage operator with soft boundaries.
- hard_shrink(x, alpha=0.5):
Hard thresholding function with a predefined alpha.
- softmin(x):
Normalizes the negative inputs into a probability distribution.
- softmax(x):
Converts inputs into a probability distribution over multiple classes.
- log_softmax(x):
Numerically stable logarithmic version of softmax.
Aliases:¶
silu(x): Alias for swish(x).
- graforvfl.shared.activator.silu(x)¶
graforvfl.shared.boundary_controller module¶
- graforvfl.shared.boundary_controller.check_bool(name: str, value: bool, bound=(True, False))[source]¶
- graforvfl.shared.boundary_controller.check_tuple_float(name: str, values: tuple, bounds=None)[source]¶
graforvfl.shared.data_processor module¶
- class graforvfl.shared.data_processor.Data(X=None, y=None, name='Unknown')[source]¶
Bases:
objectThe structure of our supported Data class
- Parameters:
X (np.ndarray) – The features of your data
y (np.ndarray) – The labels of your data
- SUPPORT = {'scaler': ['standard', 'minmax', 'max-abs', 'log1p', 'loge', 'sqrt', 'sinh-arc-sinh', 'robust', 'box-cox', 'yeo-johnson']}¶
- class graforvfl.shared.data_processor.DataTransformer(scaling_methods=('standard',), list_dict_paras=None)[source]¶
Bases:
BaseEstimator,TransformerMixin- SUPPORTED_SCALERS = {'box-cox': <class 'graforvfl.shared.scaler.BoxCoxScaler'>, 'log1p': <class 'graforvfl.shared.scaler.Log1pScaler'>, 'loge': <class 'graforvfl.shared.scaler.LogeScaler'>, 'max-abs': <class 'sklearn.preprocessing._data.MaxAbsScaler'>, 'minmax': <class 'sklearn.preprocessing._data.MinMaxScaler'>, 'robust': <class 'sklearn.preprocessing._data.RobustScaler'>, 'sinh-arc-sinh': <class 'graforvfl.shared.scaler.SinhArcSinhScaler'>, 'sqrt': <class 'graforvfl.shared.scaler.SqrtScaler'>, 'standard': <class 'sklearn.preprocessing._data.StandardScaler'>, 'yeo-johnson': <class 'graforvfl.shared.scaler.YeoJohnsonScaler'>}¶
- class graforvfl.shared.data_processor.FeatureEngineering[source]¶
Bases:
object- create_threshold_binary_features(X, threshold)[source]¶
Perform feature engineering to add binary indicator columns for values below the threshold. Add each new column right after the corresponding original column.
Args: X (numpy.ndarray): The input 2D matrix of shape (n_samples, n_features). threshold (float): The threshold value for identifying low values.
Returns: numpy.ndarray: The updated 2D matrix with binary indicator columns.
graforvfl.shared.randomer module¶
graforvfl.shared.scaler module¶
- class graforvfl.shared.scaler.BoxCoxScaler(lmbda=None)[source]¶
Bases:
BaseEstimator,TransformerMixin
- class graforvfl.shared.scaler.LabelEncoder[source]¶
Bases:
objectEncode categorical features as integer labels.
- fit(y)[source]¶
Fit label encoder to a given set of labels.
- Parameters:
y (array-like) – Labels to encode.
- fit_transform(y)[source]¶
Fit label encoder and return encoded labels.
- Parameters:
y (array-like of shape (n_samples,)) – Target values.
- Returns:
y – Encoded labels.
- Return type:
array-like of shape (n_samples,)
- class graforvfl.shared.scaler.ObjectiveScaler(obj_name='sigmoid', ohe_scaler=None)[source]¶
Bases:
objectFor label scaler in classification (binary and multiple classification)
- class graforvfl.shared.scaler.SinhArcSinhScaler(epsilon=0.1, delta=1.0)[source]¶
Bases:
BaseEstimator,TransformerMixin