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 objective computation: multiply quadratic biases with (1-alpha) #18

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

aivarsoo
Copy link

@aivarsoo aivarsoo commented Mar 15, 2024

The current implementation is not consistent with the documentation, which states that:

   """
    ``alpha=1`` places the maximum weight on the quality of the features,
    and therefore will be equivalent to using
    :class:`sklearn.feature_selection.SelectKBest`.
   """

Closes #17

To make the docs consistent with the code, we change the code and multiply the off-diagonal terms of the objective matrix (or quadratic biases) with 1-alpha

@arcondello
Copy link
Member

Looks like the CI failures are not related to this PR. I will fix in a followup.

Copy link
Member

@arcondello arcondello left a comment

Choose a reason for hiding this comment

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

It would also be good to have a test that confirms that at the extreme ends of alpha we get what we expect.

# copying the correlations with the target column
target_correlations = correlations[:, -1].copy()
# multiplying all terms with (1 - alpha)
np.multiply(correlations, (1 - alpha), out=correlations)
Copy link
Member

Choose a reason for hiding this comment

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

Rather than saving a separate target_correlations array, why not just

Suggested change
np.multiply(correlations, (1 - alpha), out=correlations)
np.multiply(correlations[:-1, :-1], (1 - alpha), out=correlations)

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.

Consider multiplying the quadratic biases in SelectFromQuadraticModel.correlation_cqm() by 1-alpha.
2 participants