Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hinge loss issue #32

Open
valeman opened this issue Apr 18, 2024 · 0 comments
Open

Hinge loss issue #32

valeman opened this issue Apr 18, 2024 · 0 comments

Comments

@valeman
Copy link

valeman commented Apr 18, 2024

Hinge loss does not seem to work unless y_cal is re-indexed from zero.

alphas_cal = hinge(model.predict_proba(X_cal), model.classes_, y_cal)

KeyError: 0

The above exception was the direct cause of the following exception:

KeyError Traceback (most recent call last)
in <cell line: 1>()
----> 1 alphas_cal = hinge(model.predict_proba(X_cal), model.classes_, y_cal)

/usr/local/lib/python3.10/dist-packages/crepes/extras.py in hinge(X_prob, classes, y)
69 if y is not None:
70 class_indexes = np.array(
---> 71 [np.argwhere(classes == y[i])[0][0] for i in range(len(y))])
72 result = 1-X_prob[np.arange(len(y)),class_indexes]
73 else:

/usr/local/lib/python3.10/dist-packages/crepes/extras.py in (.0)
69 if y is not None:
70 class_indexes = np.array(
---> 71 [np.argwhere(classes == y[i])[0][0] for i in range(len(y))])
72 result = 1-X_prob[np.arange(len(y)),class_indexes]
73 else:

/usr/local/lib/python3.10/dist-packages/pandas/core/series.py in getitem(self, key)
1005
1006 elif key_is_scalar:
-> 1007 return self._get_value(key)
1008
1009 if is_hashable(key):

/usr/local/lib/python3.10/dist-packages/pandas/core/series.py in _get_value(self, label, takeable)
1114
1115 # Similar to Index.get_value, but we do not fall back to positional
-> 1116 loc = self.index.get_loc(label)
1117
1118 if is_integer(loc):

/usr/local/lib/python3.10/dist-packages/pandas/core/indexes/base.py in get_loc(self, key)
3653 return self._engine.get_loc(casted_key)
3654 except KeyError as err:
-> 3655 raise KeyError(key) from err
3656 except TypeError:
3657 # If we have a listlike key, _check_indexing_error will raise

KeyError: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant