Skip to content

Commit

Permalink
Added transformer classes to OneToOneFeatureMixin class hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
vruusmann committed Jan 6, 2024
1 parent d689688 commit c2d3d8a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sklearn2pmml/preprocessing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
from scipy.interpolate import BSpline
from scipy.sparse import lil_matrix
from sklearn.base import BaseEstimator, TransformerMixin
try:
# SkLearn 1.2.0+
from sklearn.base import OneToOneFeatureMixin
except:
from sklearn.base import _OneToOneFeatureMixin as OneToOneFeatureMixin
from sklearn.pipeline import Pipeline
from sklearn2pmml.util import cast, dt_transform, ensure_1d, ensure_def, eval_rows, to_expr_func, to_numpy, Expression, Predicate

Expand Down Expand Up @@ -81,7 +86,7 @@ def transform(self, X):
X = ensure_1d(X)
return self.bspline(X)

class CastTransformer(BaseEstimator, TransformerMixin):
class CastTransformer(BaseEstimator, TransformerMixin, OneToOneFeatureMixin):
"""Change data type."""

def __init__(self, dtype):
Expand Down Expand Up @@ -253,7 +258,7 @@ def _eval_row(x):
Xt = cast(Xt, self.dtype)
return _col2d(Xt)

class IdentityTransformer(BaseEstimator, TransformerMixin):
class IdentityTransformer(BaseEstimator, TransformerMixin, OneToOneFeatureMixin):
"""Passes data through as-is."""

def __init__(self):
Expand Down

0 comments on commit c2d3d8a

Please sign in to comment.