efc.EnergyBasedFlowClassifier¶
- class efc.EnergyBasedFlowClassifier(pseudocounts=0.5, cutoff_quantile=0.95, n_bins=30, n_jobs=None)[source]¶
The Energy-based Flow Classifier algorithm.
- Parameters:
- pseudocountsfloat, default=`0.5`
The weight of the pseudocounts added to empirical frequencies. Must be in the interval (0,1).
- cutoff_quantilefloat, default=`0.95`
The quantile used to define the model’s energy threshold. It must be in range (0,1).
- n_binsint, default=`30`
The number of bins to produce when discretizing data features. Using the quantile strategy.
- n_jobsint, default=None
The number of parallel jobs to run on
fit()andpredict().Nonemeans 1 unless in ajoblib.parallel_backendcontext.-1means using all processors.
- Attributes:
- max_bin_int
The maximum value of the features in X.
- n_features_in_int
The number of features in X.
- classes_ndarray, shape (n_classes,)
The classes seen at
fit().- target_type_string
The type of target seen at
fit()according toutils.multiclass.type_of_target().- base_class_idx_int
The index of the base class passed to
fit()in the classes_ vector. Only used when target is binary.- estimators_list of BaseEFC instances
The collection of fitted sub-estimators. When the target is binary, this collection consists of only one estimator.
- fit(X, y, base_class=None, categorical_columns=[])[source]¶
Fit the Energy-based Flow Classifier model according to X.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
The training input samples.
- yarray-like, shape (n_samples,)
The target values.
- base_classint or string, depending on y’s dtype
Only used for binary target. Defines the class that will be used for training among the classes in the target vector. If no class is passed, the first class in the array np.unique(y) will be used.
- categorical_columnsarray-like
Indicates categorical attributes so that they are not normalized and discretized as numeric attributes. These attributes must be encoded before being passed to EFC.
- Returns:
- selfobject
Returns the fitted estimator.
- predict(X, return_energies=False, unknown_class=False)[source]¶
Perform classification on samples in X.
- Parameters:
- Xarray-like, shape (n_samples, n_features)
Input samples for classification.
- return_energiesboolean, default=False,
Whether to return the energy vector of samples in X.
- unknown_classboolean, default=False,
Whether to use the unknown class for samples with low similarity to all training classes. If targets dtype is numeric, the unknown class will be represented by -1.
- Returns:
- y_predarray-like, shape (n_samples, )
Class labels for samples in X.
- y_energiesarray-like, shape (n_samples, )
Computed energies for samples in X.
Examples using efc.EnergyBasedFlowClassifier¶
Energy-based Flow Classifier for anomaly detection