tadkit.base packageο
Submodulesο
tadkit.base.basedensitydetector moduleο
- class tadkit.base.basedensitydetector.BaseDensityOutlierDetector(contamination: float = 0.1)[source]ο
Bases:
BaseEstimator,OutlierMixinBase class for density-based outlier detection.
- Subclasses must implement:
_fit_density(X)
_score_density(X)
Accepts pandas DataFrame/Series but works internally with NumPy arrays. Returns results with same index as input if input is pandas.
- contamination: floatο
- offset_: float | Noneο
tadkit.base.dataframe_type moduleο
- class tadkit.base.dataframe_type.DataFrameType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]ο
Bases:
EnumData type of datasets: long (asynchronous) vs wide (synchronous).
- ASYNCHRONOUS = 'asynchronous'ο
- SYNCHRONOUS = 'synchronous'ο
- static infer_from_df(df: DataFrame) DataFrameType[source]ο
tadkit.base.formatter moduleο
- class tadkit.base.formatter.Formatter[source]ο
Bases:
ABCAbstract base class for all formalizers. Provides array-agnostic interface for ML pipelines.
- property available_properties: List[str]ο
- default_query() Dict[str, Any][source]ο
Return default query parameters based on query_description.
- abstract format(**query) ndarray | DataFrame[source]ο
Transform raw data into standard array-like format. Return type depends on backend (numpy array, pandas DataFrame, etc.)
- property query_description: Dict[str, Any]ο
tadkit.base.registry moduleο
- class tadkit.base.registry.Registry[source]ο
Bases:
objectRegistry for dynamically tracking and matching learner classes.
- match_learners(formatter: Any) List[Type][source]ο
Return learner classes compatible with the given formatter.
- register_learner(name: str, learner: Type | str, condition: Callable[[Any], bool], optional: bool = False)[source]ο
Register a learner with a compatibility condition.
- Parameters:
name (str) β Display name for the learner.
learner (class or str) β The learner class OR an import path (βmodule.submodule.ClassNameβ).
condition (callable(formatter) -> bool) β Determines whether this learner is compatible.
optional (bool) β If True, missing imports are ignored instead of raising.
tadkit.base.tadlearner moduleο
- class tadkit.base.tadlearner.TADLearner(*args, **kwargs)[source]ο
Bases:
ProtocolAbstract class of Time Anomaly Detection Learner (model).
Avoid explicit inheritance from this class. Better to simply do it implicitly.
- score_samples()[source]ο
The measure of normality of an observation according to the fitted model. The lower, the more abnormal.
- predict()[source]ο
Predict if a particular sample is an outlier or not. For each observation, tells whether or not (+1 or -1) it should be considered as an inlier according to the fitted model.
- Class attributes:
params_description: Description of the arguments of the __init__ method. See examples in the catalog. required_properties: Get the properties that the input data must satisfies. See examples in the catalog.
Example
>>> assert isinstance(MyLearner, TADLearner) >>> MyLearner.required_properties # The required property of input data >>> MyLearner.params_description # The description of the params >>> params = ... # Params to initiate learner >>> learner = MyLearner(**params) >>> learner.fit(X) # X, y must satisfy MyLearner.required_properties >>> score_sample_pred = learner.score_samples(X_test)
- fit(X: ndarray | list | DataFrame, y: ndarray | list | DataFrame | None = None) TADLearner[source]ο
- predict(X: ndarray | list | DataFrame) ndarray | list | DataFrame[source]ο
Predict if a particular sample is an outlier or not. Scikit-learn compatible.
- Parameters:
X ({array-like, sparse matrix} of shape (n_samples, n_features)) β The input samples.
- Returns:
is_inlier β For each observation, tells whether or not (+1 or -1) it should be considered as an inlier according to the fitted model.
- Return type:
ndarray of shape (n_samples,)
- score_samples(X: ndarray | list | DataFrame) ndarray | list | DataFrame[source]ο
The measure of normality of an observation according to the fitted model. Scikit-learn compatible.
- Parameters:
X ({array-like, sparse matrix} of shape (n_samples, n_features)) β The input samples.
- Returns:
scores β The anomaly score of the input samples. The lower, the more abnormal.
- Return type:
ndarray of shape (n_samples,)