Skip to content

Commit

Permalink
Merge pull request #3470 from pycaret/fix_array_check
Browse files Browse the repository at this point in the history
fix np array check  when get_feature_names_out is unavailable
  • Loading branch information
tvdboom committed Apr 9, 2023
2 parents 4559ead + 58d8195 commit b44ac84
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pycaret/internal/preprocess/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype
from scipy import stats
from sklearn.base import BaseEstimator, TransformerMixin, clone
from sklearn.covariance import EllipticEnvelope
Expand Down Expand Up @@ -81,7 +82,15 @@ def _name_cols(self, array, df):
# If columns were added or removed
temp_cols = []
for i, col in enumerate(array.T, start=2):
mask = df.apply(lambda c: np.array_equal(c, col, equal_nan=True))
# equal_nan=True fails for non-numeric arrays
mask = df.apply(
lambda c: np.array_equal(
c,
col,
equal_nan=is_numeric_dtype(c)
and np.issubdtype(col.dtype, np.number),
)
)
if any(mask) and mask[mask].index.values[0] not in temp_cols:
temp_cols.append(mask[mask].index.values[0])
else:
Expand Down

0 comments on commit b44ac84

Please sign in to comment.