Skip to content

Commit

Permalink
Update kprototypes.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodv authored Jan 10, 2019
1 parent 431dac4 commit 9f74a05
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kmodes/kprototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@ def fit(self, X, y=None, categorical=None):
categorical : Index of columns that contain categorical data
"""
if categorical is not None:
assert isinstance(categorical, (list, tuple)), "The 'categorical' \
argument needs to be a list or tuple of integer indices \
but is: {}.".format(type(categorical))
assert isinstance(categorical, (int, list, tuple)), "The 'categorical' \
argument needs to be an integer with the index of the categorical \
column in your data, or a list or tuple of several of them, \
but it is a {}.".format(type(categorical))

random_state = check_random_state(self.random_state)
# If self.gamma is None, gamma will be automatically determined from
Expand Down Expand Up @@ -478,9 +479,10 @@ def predict(self, X, categorical=None):
"""
assert hasattr(self, '_enc_cluster_centroids'), "Model not yet fitted."
if categorical is not None:
assert isinstance(categorical, (list, tuple)), "The 'categorical' \
argument needs to be a list or tuple of integer indices \
but is: {}.".format(type(categorical))
assert isinstance(categorical, (int, list, tuple)), "The 'categorical' \
argument needs to be an integer with the index of the categorical \
column in your data, or a list or tuple of several of them, \
but it is a {}.".format(type(categorical))

Xnum, Xcat = _split_num_cat(X, categorical)
Xnum, Xcat = check_array(Xnum), check_array(Xcat, dtype=None)
Expand Down

0 comments on commit 9f74a05

Please sign in to comment.