JS#
- class frouros.detectors.data_drift.batch.distance_based.JS(num_bins: int = 10, callbacks: BaseCallbackBatch | list[BaseCallbackBatch] | None = None, **kwargs: Any)#
JS (Jensen-Shannon distance) [lin1991divergence] detector.
- Parameters:
num_bins (int) – number of bins in which to divide probabilities, defaults to 10
callbacks (Optional[Union[BaseCallbackBatch, list[BaseCallbackBatch]]]) – callbacks, defaults to None
kwargs (dict[str, Any]) – additional keyword arguments to pass to scipy.spatial.distance.jensenshannon
- References:
[lin1991divergence]Lin, Jianhua. “Divergence measures based on the Shannon entropy.” IEEE Transactions on Information theory 37.1 (1991): 145-151.
- Example:
>>> from frouros.detectors.data_drift import JS >>> import numpy as np >>> np.random.seed(seed=31) >>> X = np.random.normal(loc=0, scale=1, size=100) >>> Y = np.random.normal(loc=1, scale=1, size=100) >>> detector = JS(num_bins=20) >>> _ = detector.fit(X=X) >>> detector.compare(X=Y)[0] DistanceResult(distance=0.41702877367162156)
- property num_bins: int#
Number of bins property.
- Returns:
number of bins in which to divide probabilities
- Return type:
int
- property X_ref: ndarray | None#
Reference data property.
- Returns:
reference data
- Return type:
Optional[numpy.ndarray]
- property callbacks: list[BaseCallback] | None#
Callbacks property.
- Returns:
callbacks
- Return type:
Optional[list[BaseCallback]]
- compare(X: ndarray, **kwargs: Any) Tuple[ndarray, dict[str, Any]] #
Compare values.
- Parameters:
X (numpy.ndarray) – test data
- Returns:
compare result and callbacks logs
- Return type:
Tuple[numpy.ndarray, dict[str, Any]]
- property data_type: BaseDataType#
Data type property.
- Returns:
data type
- Return type:
BaseDataType
- fit(X: ndarray, **kwargs: Any) dict[str, Any] #
Fit detector.
- Parameters:
X (numpy.ndarray) – feature data
kwargs (Any) – additional fit parameters
- Returns:
callbacks logs
- Return type:
dict[str, Any]
- reset() None #
Reset method.
- property statistical_kwargs: dict[str, Any]#
Statistical kwargs property.
- Returns:
statistical kwargs
- Return type:
dict[str, Any]
- property statistical_method: Callable#
Statistical method property.
- Returns:
statistical method
- Return type:
Callable
- property statistical_type: BaseStatisticalType#
Statistical type property.
- Returns:
statistical type
- Return type:
BaseStatisticalType