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

Fixed GridSearchCV to use default log-likelihood scoring for model selection #30326

Closed
wants to merge 2 commits into from
Closed

Conversation

ghost
Copy link

@ghost ghost commented Nov 21, 2024

Updated GridSearchCV to include scoring=None for utilizing the default log-likelihood scoring of GaussianMixture, ensuring appropriate evaluation during cross-validation.

Copy link

github-actions bot commented Nov 21, 2024

❌ Linting issues

This PR is introducing linting issues. Here's a summary of the issues. Note that you can avoid having linting issues by enabling pre-commit hooks. Instructions to enable them can be found here.

You can see the details of the linting issues under the lint job here


black

black detected issues. Please run black . locally and push the changes. Here you can see the detected issues. Note that running black might also fix some of the issues which might be detected by ruff. Note that the installed black version is black=24.3.0.


--- /home/runner/work/scikit-learn/scikit-learn/examples/mixture/plot_gmm_selection.py	2024-11-22 07:14:12.965432+00:00
+++ /home/runner/work/scikit-learn/scikit-learn/examples/mixture/plot_gmm_selection.py	2024-11-22 07:14:21.265867+00:00
@@ -69,23 +69,22 @@
 # `best_estimator_`, respectively.
 
 from sklearn.mixture import GaussianMixture
 from sklearn.model_selection import GridSearchCV
 
+
 def gmm_bic_score(estimator, X):
     """Callable to pass to GridSearchCV that will use the BIC score."""
     # Make it negative since GridSearchCV expects a score to maximize
     return -estimator.bic(X)
 
 
 param_grid = {
     "n_components": range(1, 7),
     "covariance_type": ["spherical", "tied", "diag", "full"],
 }
-grid_search = GridSearchCV(
-    GaussianMixture(), param_grid=param_grid, scoring=None
-)
+grid_search = GridSearchCV(GaussianMixture(), param_grid=param_grid, scoring=None)
 grid_search.fit(X)
 
 # %%
 # Plot the BIC scores
 # -------------------
would reformat /home/runner/work/scikit-learn/scikit-learn/examples/mixture/plot_gmm_selection.py

Oh no! 💥 💔 💥
1 file would be reformatted, 923 files would be left unchanged.

ruff

ruff detected issues. Please run ruff check --fix --output-format=full . locally, fix the remaining issues, and push the changes. Here you can see the detected issues. Note that the installed ruff version is ruff=0.5.1.


examples/mixture/plot_gmm_selection.py:71:1: I001 [*] Import block is un-sorted or un-formatted
   |
69 |   # `best_estimator_`, respectively.
70 |   
71 | / from sklearn.mixture import GaussianMixture
72 | | from sklearn.model_selection import GridSearchCV
73 | | 
74 | | def gmm_bic_score(estimator, X):
   | |_^ I001
75 |       """Callable to pass to GridSearchCV that will use the BIC score."""
76 |       # Make it negative since GridSearchCV expects a score to maximize
   |
   = help: Organize imports

Found 1 error.
[*] 1 fixable with the `--fix` option.

Generated for commit: 72bf89d. Link to the linter CI: here

@ghost ghost closed this Nov 21, 2024
@ghost ghost reopened this Nov 21, 2024
@ghost ghost closed this Nov 21, 2024
@ghost ghost deleted the gmm branch November 21, 2024 20:46
@ghost ghost restored the gmm branch November 22, 2024 07:08
@ghost ghost reopened this Nov 22, 2024
@ghost
Copy link
Author

ghost commented Nov 22, 2024

pre-commit.ci autofix

@ogrisel
Copy link
Member

ogrisel commented Nov 22, 2024

Closing in favor of #30329 which seems closer to what I described in the original issue (#30323).

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