-
Notifications
You must be signed in to change notification settings - Fork 68
[DOC] Add docstrings for best_estimator.py
#235
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
Open
omkar-334
wants to merge
1
commit into
hyperactive-project:main
Choose a base branch
from
omkar-334:estimator-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,43 +20,159 @@ class BestEstimator: | |
|
|
||
| @available_if(_estimator_has("score_samples")) | ||
| def score_samples(self, X): | ||
| """Score Samples function.""" | ||
| """Call score_samples on the estimator with the best found parameters. | ||
|
|
||
| Only available if ``refit=True`` and the underlying estimator supports | ||
| ``score_samples``. | ||
|
|
||
| .. versionadded:: 0.24 | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : iterable | ||
| Data to predict on. Must fulfill input requirements | ||
| of the underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| y_score : ndarray of shape (n_samples,) | ||
| The ``best_estimator_.score_samples`` method. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be more detailed. |
||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.score_samples(X) | ||
|
|
||
| @available_if(_estimator_has("predict")) | ||
| def predict(self, X): | ||
| """Predict function.""" | ||
| """Call predict on the estimator with the best found parameters. | ||
|
|
||
| Only available if ``refit=True`` and the underlying estimator supports | ||
| ``predict``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| y_pred : ndarray of shape (n_samples,) | ||
| The predicted labels or values for `X` based on the estimator with | ||
| the best found parameters. | ||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.predict(X) | ||
|
|
||
| @available_if(_estimator_has("predict_proba")) | ||
| def predict_proba(self, X): | ||
| """Predict Proba function.""" | ||
| """Call predict_proba on the estimator with the best found parameters. | ||
|
|
||
| Only available if ``refit=True`` and the underlying estimator supports | ||
| ``predict_proba``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| y_pred : ndarray of shape (n_samples,) or (n_samples, n_classes) | ||
| Predicted class probabilities for `X` based on the estimator with | ||
| the best found parameters. The order of the classes corresponds | ||
| to that in the fitted attribute :term:`classes_`. | ||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.predict_proba(X) | ||
|
|
||
| @available_if(_estimator_has("predict_log_proba")) | ||
| def predict_log_proba(self, X): | ||
| """Predict Log Proba function.""" | ||
| """Call predict_log_proba on the estimator with the best found parameters. | ||
|
|
||
| Only available if ``refit=True`` and the underlying estimator supports | ||
| ``predict_log_proba``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| y_pred : ndarray of shape (n_samples,) or (n_samples, n_classes) | ||
| Predicted class log-probabilities for `X` based on the estimator | ||
| with the best found parameters. The order of the classes | ||
| corresponds to that in the fitted attribute :term:`classes_`. | ||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.predict_log_proba(X) | ||
|
|
||
| @available_if(_estimator_has("decision_function")) | ||
| def decision_function(self, X): | ||
| """Decision Function function.""" | ||
| """Call decision_function on the estimator with the best found parameters. | ||
|
|
||
| Only available if ``refit=True`` and the underlying estimator supports | ||
| ``decision_function``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| y_score : ndarray of shape (n_samples,) or (n_samples, n_classes) \ | ||
| or (n_samples, n_classes * (n_classes-1) / 2) | ||
| Result of the decision function for `X` based on the estimator with | ||
| the best found parameters. | ||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.decision_function(X) | ||
|
|
||
| @available_if(_estimator_has("transform")) | ||
| def transform(self, X): | ||
| """Transform function.""" | ||
| """Call transform on the estimator with the best found parameters. | ||
|
|
||
| Only available if the underlying estimator supports ``transform`` and | ||
| ``refit=True``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
| Returns | ||
| ------- | ||
| Xt : {ndarray, sparse matrix} of shape (n_samples, n_features) | ||
| `X` transformed in the new space based on the estimator with | ||
| the best found parameters. | ||
| """ | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.transform(X) | ||
|
|
||
| @available_if(_estimator_has("inverse_transform")) | ||
| def inverse_transform(self, X=None, Xt=None): | ||
| """Inverse Transform function.""" | ||
| """Call inverse_transform on the estimator with the best found params. | ||
|
|
||
| Only available if the underlying estimator implements | ||
| ``inverse_transform`` and ``refit=True``. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| X : indexable, length n_samples | ||
| Must fulfill the input assumptions of the | ||
| underlying estimator. | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'Xt' is not documented here. |
||
| Returns | ||
| ------- | ||
| X_original : {ndarray, sparse matrix} of shape (n_samples, n_features) | ||
| Result of the `inverse_transform` function for `X` based on the | ||
| estimator with the best found parameters. | ||
| """ | ||
| X = _deprecate_Xt_in_inverse_transform(X, Xt) | ||
| check_is_fitted(self) | ||
| return self.best_estimator_.inverse_transform(X) | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is that?