Module pipeline
mlpype.sklearn.pipeline
Provides type checkers and data models for numpy and pandas.
mlpype.sklearn.pipeline.NumpyTypeChecker
Bases: TypeChecker[ndarray]
Provides a TypeChecker for numpy arrays.
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/numpy_type_checker.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | |
fit(data)
Fit this Numpy TypeChecker to the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The data to fit. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
NumpyTypeChecker |
NumpyTypeChecker
|
self. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/numpy_type_checker.py
44 45 46 47 48 49 50 51 52 53 54 55 | |
get_pydantic_type()
Creates a Pydantic model for this data to handle serialisation/deserialisation.
Returns:
| Type | Description |
|---|---|
Type[NumpyData]
|
Type[NumpyData]: A NumpyData model that fits the data this wat fitted on. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/numpy_type_checker.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |
supports_object(obj)
classmethod
Returns True if the object is a numpy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the given object is a numpy array, False otherwise. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/numpy_type_checker.py
100 101 102 103 104 105 106 107 108 109 110 | |
transform(data)
Checks if the given data fits the specifications this TypeChecker was fitted for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ndarray
|
The data to check. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: data, if the data fits the specifications. Otherwise, an assertion error is thrown. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/numpy_type_checker.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
mlpype.sklearn.pipeline.PandasTypeChecker
Bases: TypeChecker[DataFrame]
A TypeChecker for pandas DataFrames.
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/pandas_type_checker.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
fit(data)
Fit this PandasTypeChecker to the given data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data to fit. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PandasTypeChecker |
PandasTypeChecker
|
self |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/pandas_type_checker.py
47 48 49 50 51 52 53 54 55 56 57 | |
get_pydantic_type()
Creates a Pydantic model for this data to handle serialisation/deserialisation.
Returns:
| Type | Description |
|---|---|
Type[PandasData]
|
Type[PandasData]: A PandasData model that fits the data this wat fitted on. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/pandas_type_checker.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
supports_object(obj)
classmethod
Returns True if the object is a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
The object to check. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the given object is a pandas DataFrame, False otherwise. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/pandas_type_checker.py
111 112 113 114 115 116 117 118 119 120 121 | |
transform(data)
Checks if the given data fits the specifications this TypeChecker was fitted for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
The data to check. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: data, if the data fits the specifications. Otherwise, an assertion error is thrown. |
Source code in packages/mlpype-sklearn/src/mlpype/sklearn/pipeline/pandas_type_checker.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |