Repository navigation
Add Class Core Set - #353
Merged
mherde merged 44 commits intoJan 10, 2024
Merged
Conversation
2. Make k_center_greedy as static function
mherde
requested changes
Nov 29, 2023
| from ..utils import MISSING_LABEL, simple_batch | ||
|
|
||
| class CoreSet(SingleAnnotatorPoolQueryStrategy): | ||
|
|
Contributor
There was a problem hiding this comment.
- Performing a query must be deterministic for a given random seed, e.g.:
qs = CoreSet(random_state=42)
query_indices_1 = qs.query(X, y)
query_indices_2 = qs.query(X, y)
np.testing.assertArrayEqual(query_indices_1, query_indices_2)
- The name convention of functions/methods in Python is lowercase with _ as separators, e.g.,
kCenterGreedy -> k_center_greedy. - Use the
min_distancesasutilities, which can be returned ifreturn_utilities=True. - Change
np.random.choice(np.arange(X.shape[0]))toself.random_state_.choice(np.arange(X.shape[0]))
| If candidates is of shape (n_candidates, n_features), the indexing | ||
| refers to samples in candidates. | ||
| """ | ||
| # read the labeled aka selected samples from the y vector |
Contributor
There was a problem hiding this comment.
Could you check whether the parameters are valid? For example:
X = check_array(X, allow_nd=True)
y = check_array(y, ensure_2d=False, force_all_finite="allow-nan", dtype=None)
check_consistent_length(X, y)
Cf. base.by to see which checks are possible.
| X: array-like of shape (n_samples, n_features) | ||
| Training data set, usually complete, i.e. including the labeled and | ||
| unlabeled samples | ||
| selected_samples: np.ndarray of shape (n_selected_samples, ) |
Contributor
There was a problem hiding this comment.
Adjust documentation according to the new parameters.
|
|
||
| return query_indices, utilities | ||
|
|
||
| def update_distances(X, cluster_centers, mapping): |
Contributor
There was a problem hiding this comment.
Add an additional parameter, which contains already computed distances for the previous cluster centers.
|
|
||
| return query_indices, utilities | ||
|
|
||
| def update_distances(X, cluster_centers, mapping): |
Contributor
There was a problem hiding this comment.
Suggested change
| def update_distances(X, cluster_centers, mapping): | |
| def _update_distances(X, cluster_centers, mapping): |
Merged
mherde
requested changes
Jan 9, 2024
| candidates=None, | ||
| batch_size=1, | ||
| return_utilities=False, | ||
| **kwargs |
mherde
approved these changes
Jan 10, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add Class Core Set with the corresponding query strategy, k_greedy_center.
Features