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

Fix CVModel in TopicMembershipModel #45

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions adatest/_topic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def predict_prob(self, embeddings):

class CVModel():
def __init__(self, embeddings, labels):
self.inner_model = RidgeClassifierCV(class_weight={"pass": 1, "fail": 1})
class_weight = {label: 1 for label in labels}
self.inner_model = RidgeClassifierCV(class_weight=class_weight)
self.inner_model.fit(embeddings, labels)

def predict_prob(self, embeddings):
Expand Down Expand Up @@ -157,8 +158,7 @@ def __init__(self, topic, test_tree):
else:

# we are in a highly overparametrized situation, so we use a linear SVC to get "max-margin" based generalization
self.model = CVModel()
self.model.fit(embeddings, labels)
self.model = CVModel(embeddings, labels)

def __call__(self, input):
embeddings = adatest.embed([input])[0]
Expand Down