Skip to content

Commit

Permalink
Merge 45083ac into cff2153
Browse files Browse the repository at this point in the history
  • Loading branch information
Genie-Liu committed Apr 14, 2019
2 parents cff2153 + 45083ac commit 4df4a16
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kmodes/kmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,11 @@ def predict(self, X, **kwargs):
labels : array, shape [n_samples,]
Index of the cluster each sample belongs to.
"""

# Convert pandas objects to numpy arrays.
if 'pandas' in str(X.__class__):
X = X.values

assert hasattr(self, '_enc_cluster_centroids'), "Model not yet fitted."

if self.verbose and self.cat_dissim == ng_dissim:
Expand Down
5 changes: 5 additions & 0 deletions kmodes/kprototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,11 @@ def predict(self, X, categorical=None):
Index of the cluster each sample belongs to.
"""
assert hasattr(self, '_enc_cluster_centroids'), "Model not yet fitted."

# Convert pandas objects to numpy arrays.
if 'pandas' in str(X.__class__):
X = X.values

if categorical is not None:
assert isinstance(categorical, (int, list, tuple)), "The 'categorical' \
argument needs to be an integer with the index of the categorical \
Expand Down

0 comments on commit 4df4a16

Please sign in to comment.