lir.transform package
- class lir.transform.BinaryClassifierTransformer(estimator: SKLearnPipelineModule)[source]
Bases:
TransformerImplementation of a binary class classifier as scikit-learn Pipeline step.
- Parameters:
estimator (SKLearnPipelineModule) – Estimator used to produce transformed or scored outputs.
- apply(instances: InstanceData) InstanceData[source]
Convert instances by applying the fitted model.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the model on the provided instances.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This transformer instance after fitting.
- Return type:
Self
- class lir.transform.DataWriter(*args, **kwargs)[source]
Bases:
ProtocolRepresentation of a data writer and necessary methods.
- class lir.transform.FunctionTransformer(func: Callable)[source]
Bases:
TransformerImplementation of a transformer function as scikit-learn Pipeline step.
- Parameters:
func (Callable) – Callable used to transform input instances.
- apply(instances: InstanceData) FeatureData[source]
Call the custom defined function on the feature data instances and use output as features.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
FeatureData object parsed from the source.
- Return type:
- class lir.transform.Identity[source]
Bases:
TransformerRepresent the Identity function of a transformer.
When apply() is called on such a transformer, it simply returns the instances.
- class lir.transform.SKLearnPipelineModule(*args, **kwargs)[source]
Bases:
ProtocolRepresentation of the interface required for estimators by the scikit-learn Pipeline.
- class lir.transform.SklearnTransformer(transformer: SklearnTransformerType)[source]
Bases:
TransformerImplementation of a binary class classifier as scikit-learn Pipeline step.
- Parameters:
transformer (SklearnTransformerType) – Transformer instance wrapped by this adapter.
- apply(instances: InstanceData) InstanceData[source]
Convert instances by applying the fitted model.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- fit(instances: InstanceData) Self[source]
Fit the model on the provided instances.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This transformer instance after fitting.
- Return type:
Self
- fit_apply(instances: InstanceData) FeatureData[source]
Combine call to .fit() followed by .apply().
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
FeatureData object parsed from the source.
- Return type:
- class lir.transform.SklearnTransformerType(*args, **kwargs)[source]
Bases:
ProtocolRepresentation of the interface required for transformers by the scikit-learn Pipeline.
- class lir.transform.Tee(transformers: list[Transformer])[source]
Bases:
TransformerImplementation of a custom transformer allowing to perform two separate tasks on a given input.
- Parameters:
transformers (list[Transformer]) – Collection of transformers applied in sequence or parallel.
- apply(instances: InstanceData) InstanceData[source]
Delegate apply() to all specified transformers.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- fit(instances: InstanceData) Self[source]
Delegate fit() to all specified transformers.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This tee transformer instance after delegating fit.
- Return type:
Self
- class lir.transform.Transformer[source]
Bases:
ABCTransformer module which is compatible with the scikit-learn Pipeline.
The transformer should provide a transform() method. Since transformers are not fitted to the data, the fit() simply returns the object it was called upon without side effects.
- abstractmethod apply(instances: InstanceData) InstanceData[source]
Convert the instance data based on the (optionally fitted) model.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- fit(instances: InstanceData) Self[source]
Perform (optional) fitting of the instance data.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This transformer instance after fitting.
- Return type:
Self
- fit_apply(instances: InstanceData) InstanceData[source]
Combine call to fit() with directly following call to apply().
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- class lir.transform.TransformerWrapper(wrapped_transformer: Transformer)[source]
Bases:
TransformerBase class for a transformer wrapper.
This class is derived from AdvancedTransformer and has a default implementation of all functions by forwarding the call to the wrapped transformer. A subclass may add or change functionality by overriding functions.
- Parameters:
wrapped_transformer (Transformer) – Value passed via
wrapped_transformer.
- apply(instances: InstanceData) InstanceData[source]
Delegate calls to underlying wrapped transformer but return the Wrapper instance.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
Instance data object produced by this operation.
- Return type:
- fit(instances: InstanceData) Self[source]
Delegate calls to underlying wrapped transformer but return the Wrapper instance.
- Parameters:
instances (InstanceData) – Input instances to be processed by this method.
- Returns:
This wrapper instance after delegating fit.
- Return type:
Self
- lir.transform.as_transformer(transformer_like: Any) Transformer[source]
Provide a Transformer instance of the provided transformer like input.
For any transformer-like object, wrap if necessary, and return a Transformer.
The transformer-like object may be one of the following: - an instance of Transformer, which is returned as-is; - a scikit-learn style transformer which implements transform() and optionally fit() and/or fit_transform(); - a scikit-learn style estimator, which implements fit() and predict_proba(); or - a callable which takes an np.ndarray argument and returns another np.ndarray.
- Parameters:
transformer_like (Any) – Object to convert to the internal Transformer interface.
- Returns:
Equivalent object adapted to the internal
Transformerinterface.- Return type: