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

Update to work with Python 3.12 and Scikit-Learn >= 1.2 #77

Merged
merged 1 commit into from
May 9, 2024

Conversation

steppi
Copy link
Collaborator

@steppi steppi commented May 9, 2024

This PR makes the following changes:

  1. No longer vendor _score.c, instead require Cython as a build dependency.
  2. Change to pyproject.toml build
  3. Move to src layout
  4. Update adeft/modeling/classify.py so that it works with the latest Scikit_learn.

This supersedes #76. Hopefully everything in CI passes.

Comment on lines +106 to +109
self.stop = list(
set(english_stopwords).union([sf.lower() for sf
in self.shortforms])
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TfidfVectorizer now only allows lists for stop_words and no longer accepts generic containers.

Comment on lines 221 to +222
f1_scorer = make_scorer(f1_score, labels=self.pos_labels,
pos_label=None,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input validation for f1_score and friends now requires explicitly setting pos_label=None when no pos_labels are desired. Before, if average was not binary, pos_label was completely ignored.

Comment on lines -427 to +432
feature_names = tfidf.get_feature_names()
feature_names = tfidf.get_feature_names_out()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method changed names in scikit-learn 1.0, the old one was deprecated and then removed in 1.2.

@bgyori
Copy link
Member

bgyori commented May 9, 2024

Thanks @steppi, this looks great - I tested with Gilda and it works well on Python 3.12.

@steppi steppi merged commit 346fe89 into gyorilab:master May 9, 2024
12 checks passed
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

Successfully merging this pull request may close these issues.

2 participants