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

Logistic Regression classifier does not output proper ranking #11429

Closed
twerkmeister opened this issue Aug 10, 2022 · 0 comments · Fixed by #11430
Closed

Logistic Regression classifier does not output proper ranking #11429

twerkmeister opened this issue Aug 10, 2022 · 0 comments · Fixed by #11430
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.

Comments

@twerkmeister
Copy link
Contributor

twerkmeister commented Aug 10, 2022

Rasa Open Source version

3.2.5

Rasa SDK version

No response

Python version

3.8

What operating system are you using?

Linux, OSX

What happened?

The component does not create a proper intent ranking ... see code. It just picks 10 intents out of all intents (in whatever order they originally were) and then orders them according to confidence...

def process(self, messages: List[Message]) -> List[Message]:
"""Return the most likely intent and its probability for a message."""
X = self._create_X(messages)
pred = self.clf.predict(X)
probas = self.clf.predict_proba(X)
for idx, message in enumerate(messages):
intent = {"name": pred[idx], "confidence": probas[idx].max()}
intents = self.clf.classes_
intent_info = {
k: v
for i, (k, v) in enumerate(zip(intents, probas[idx]))
if i < LABEL_RANKING_LENGTH
}
intent_ranking = [
{"name": k, "confidence": v} for k, v in intent_info.items()
]
sorted_ranking = sorted(intent_ranking, key=lambda e: -e["confidence"])
message.set("intent", intent, add_to_output=True)
message.set("intent_ranking", sorted_ranking, add_to_output=True)
return messages

Command / Request

No response

Relevant log output

No response

@twerkmeister twerkmeister added type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors. area:rasa-oss 🎡 Anything related to the open source Rasa framework labels Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:rasa-oss 🎡 Anything related to the open source Rasa framework type:bug 🐛 Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant