Skip to content

Commit

Permalink
Merge pull request #3543 from pycaret/remove_leaveoneout
Browse files Browse the repository at this point in the history
Remove leaveoneout
  • Loading branch information
tvdboom committed May 11, 2023
2 parents 11ddfff + 5674bdd commit 7f57794
Show file tree
Hide file tree
Showing 26 changed files with 7 additions and 232 deletions.
14 changes: 0 additions & 14 deletions pycaret/anomaly/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def setup(
profile: bool = False,
profile_kwargs: Optional[Dict[str, Any]] = None,
):

"""
This function initializes the training environment and creates the transformation
pipeline. Setup function must be called before executing any other function. It
Expand Down Expand Up @@ -516,7 +515,6 @@ def create_model(
experiment_custom_tags: Optional[Dict[str, Any]] = None,
**kwargs,
):

"""
This function trains a given model from the model library. All available
models can be accessed using the ``models`` function.
Expand Down Expand Up @@ -592,7 +590,6 @@ def create_model(
def assign_model(
model, transformation: bool = False, score: bool = True, verbose: bool = True
) -> pd.DataFrame:

"""
This function assigns anomaly labels to the dataset for a given model.
(1 = outlier, 0 = inlier).
Expand Down Expand Up @@ -643,7 +640,6 @@ def plot_model(
save: bool = False,
display_format: Optional[str] = None,
) -> Optional[str]:

"""
This function analyzes the performance of a trained model.
Expand Down Expand Up @@ -713,7 +709,6 @@ def evaluate_model(
feature: Optional[str] = None,
fit_kwargs: Optional[dict] = None,
):

"""
This function displays a user interface for analyzing performance of a trained
model. It calls the ``plot_model`` function internally.
Expand Down Expand Up @@ -759,7 +754,6 @@ def evaluate_model(

# not using check_if_global_is_not_none on purpose
def predict_model(model, data: pd.DataFrame) -> pd.DataFrame:

"""
This function generates anomaly labels on using a trained model.
Expand Down Expand Up @@ -811,7 +805,6 @@ def deploy_model(
authentication: dict,
platform: str = "aws",
):

"""
This function deploys the transformation pipeline and trained model on cloud.
Expand Down Expand Up @@ -903,7 +896,6 @@ def deploy_model(
def save_model(
model, model_name: str, model_only: bool = False, verbose: bool = True, **kwargs
):

"""
This function saves the transformation pipeline and trained model object
into the current working directory as a pickle file for later use.
Expand Down Expand Up @@ -961,7 +953,6 @@ def load_model(
authentication: Optional[Dict[str, str]] = None,
verbose: bool = True,
):

"""
This function loads a previously saved pipeline.
Expand Down Expand Up @@ -1039,7 +1030,6 @@ def models(
internal: bool = False,
raise_errors: bool = True,
) -> pd.DataFrame:

"""
Returns table of models available in the model library.
Expand Down Expand Up @@ -1071,7 +1061,6 @@ def models(

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def get_logs(experiment_name: Optional[str] = None, save: bool = False) -> pd.DataFrame:

"""
Returns a table of experiment logs. Only works when ``log_experiment``
is True when initializing the ``setup`` function.
Expand Down Expand Up @@ -1105,7 +1094,6 @@ def get_logs(experiment_name: Optional[str] = None, save: bool = False) -> pd.Da

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def get_config(variable: Optional[str] = None):

"""
This function is used to access global environment variables.
Expand All @@ -1132,7 +1120,6 @@ def get_config(variable: Optional[str] = None):

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def set_config(variable: str, value):

"""
This function is used to reset global environment variables.
Expand Down Expand Up @@ -1184,7 +1171,6 @@ def load_experiment(
preprocess_data: bool = True,
**cloudpickle_kwargs,
) -> AnomalyExperiment:

"""
Load an experiment saved with ``save_experiment`` from path
or file.
Expand Down
34 changes: 1 addition & 33 deletions pycaret/classification/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ def setup(
profile: bool = False,
profile_kwargs: Optional[Dict[str, Any]] = None,
):

"""
This function initializes the training environment and creates the transformation
pipeline. Setup function must be called before executing any other function. It takes
Expand Down Expand Up @@ -266,7 +265,7 @@ def setup(
encoding_method: category-encoders estimator, default = None
A `category-encoders` estimator to encode the categorical columns
with more than `max_encoding_ohe` unique values. If None,
`category_encoders.leave_one_out.LeaveOneOutEncoder` is used.
`category_encoders.target_encoder.TargetEncoder` is used.
rare_to_value: float or None, default=None
Expand Down Expand Up @@ -698,7 +697,6 @@ def compare_models(
verbose: bool = True,
parallel: Optional[ParallelBackend] = None,
) -> Union[Any, List[Any]]:

"""
This function trains and evaluates performance of all estimators available in the
model library using cross validation. The output of this function is a score grid
Expand Down Expand Up @@ -894,7 +892,6 @@ def create_model(
return_train_score: bool = False,
**kwargs,
) -> Any:

"""
This function trains and evaluates the performance of a given estimator
using cross validation. The output of this function is a score grid with
Expand Down Expand Up @@ -1047,7 +1044,6 @@ def tune_model(
return_train_score: bool = False,
**kwargs,
) -> Any:

"""
This function tunes the hyperparameters of a given estimator. The output of
this function is a score grid with CV scores by fold of the best selected
Expand Down Expand Up @@ -1255,7 +1251,6 @@ def ensemble_model(
verbose: bool = True,
return_train_score: bool = False,
) -> Any:

"""
This function ensembles a given estimator. The output of this function is
a score grid with CV scores by fold. Metrics evaluated during CV can be
Expand Down Expand Up @@ -1376,7 +1371,6 @@ def blend_models(
verbose: bool = True,
return_train_score: bool = False,
) -> Any:

"""
This function trains a Soft Voting / Majority Rule classifier for select
models passed in the ``estimator_list`` param. The output of this function
Expand Down Expand Up @@ -1499,7 +1493,6 @@ def stack_models(
verbose: bool = True,
return_train_score: bool = False,
) -> Any:

"""
This function trains a meta model over select estimators passed in
the ``estimator_list`` parameter. The output of this function is a
Expand Down Expand Up @@ -1637,7 +1630,6 @@ def plot_model(
verbose: bool = True,
display_format: Optional[str] = None,
) -> Optional[str]:

"""
This function analyzes the performance of a trained model on holdout set.
It may require re-training the model in certain cases.
Expand Down Expand Up @@ -1768,7 +1760,6 @@ def evaluate_model(
groups: Optional[Union[str, Any]] = None,
use_train_data: bool = False,
):

"""
This function displays a user interface for analyzing performance of a trained
model. It calls the ``plot_model`` function internally.
Expand Down Expand Up @@ -1847,7 +1838,6 @@ def interpret_model(
save: Union[str, bool] = False,
**kwargs,
):

"""
This function takes a trained model object and returns an interpretation plot
based on the test / hold-out set.
Expand Down Expand Up @@ -1959,7 +1949,6 @@ def calibrate_model(
verbose: bool = True,
return_train_score: bool = False,
) -> Any:

"""
This function calibrates the probability of a given estimator using isotonic
or logistic regression. The output of this function is a score grid with CV
Expand Down Expand Up @@ -2062,7 +2051,6 @@ def optimize_threshold(
plot_kwargs: Optional[dict] = None,
**shgo_kwargs,
):

"""
This function optimizes probability threshold for a trained classifier. It
uses the SHGO optimizer from ``scipy`` to optimize for the given metric.
Expand Down Expand Up @@ -2131,7 +2119,6 @@ def predict_model(
round: int = 4,
verbose: bool = True,
) -> pd.DataFrame:

"""
This function predicts ``Label`` and ``Score`` (probability of predicted
class) using a trained model. When ``data`` is None, it predicts label and
Expand Down Expand Up @@ -2217,7 +2204,6 @@ def finalize_model(
model_only: bool = False,
experiment_custom_tags: Optional[Dict[str, Any]] = None,
) -> Any:

"""
This function trains a given estimator on the entire dataset including the
holdout set.
Expand Down Expand Up @@ -2368,7 +2354,6 @@ def deploy_model(
def save_model(
model, model_name: str, model_only: bool = False, verbose: bool = True, **kwargs
):

"""
This function saves the transformation pipeline and trained model object
into the current working directory as a pickle file for later use.
Expand Down Expand Up @@ -2425,7 +2410,6 @@ def load_model(
authentication: Optional[Dict[str, str]] = None,
verbose: bool = True,
):

"""
This function loads a previously saved pipeline.
Expand Down Expand Up @@ -2486,7 +2470,6 @@ def automl(
turbo: bool = True,
return_train_score: bool = False,
) -> Any:

"""
This function returns the best model out of all trained models in
current session based on the ``optimize`` parameter. Metrics
Expand Down Expand Up @@ -2566,7 +2549,6 @@ def models(
internal: bool = False,
raise_errors: bool = True,
) -> pd.DataFrame:

"""
Returns table of models available in the model library.
Expand Down Expand Up @@ -2609,7 +2591,6 @@ def get_metrics(
include_custom: bool = True,
raise_errors: bool = True,
) -> pd.DataFrame:

"""
Returns table of available metrics used in the experiment.
Expand Down Expand Up @@ -2659,7 +2640,6 @@ def add_metric(
multiclass: bool = True,
**kwargs,
) -> pd.Series:

"""
Adds a custom metric to be used in the experiment.
Expand Down Expand Up @@ -2724,7 +2704,6 @@ def add_metric(

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def remove_metric(name_or_id: str):

"""
Removes a metric from the experiment.
Expand All @@ -2751,7 +2730,6 @@ def remove_metric(name_or_id: str):

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def get_logs(experiment_name: Optional[str] = None, save: bool = False) -> pd.DataFrame:

"""
Returns a table of experiment logs. Only works when ``log_experiment``
is True when initializing the ``setup`` function.
Expand Down Expand Up @@ -2785,7 +2763,6 @@ def get_logs(experiment_name: Optional[str] = None, save: bool = False) -> pd.Da

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def get_config(variable: Optional[str] = None):

"""
This function is used to access global environment variables.
Expand All @@ -2812,7 +2789,6 @@ def get_config(variable: Optional[str] = None):

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def set_config(variable: str, value):

"""
This function is used to reset global environment variables.
Expand Down Expand Up @@ -2866,7 +2842,6 @@ def load_experiment(
preprocess_data: bool = True,
**cloudpickle_kwargs,
) -> ClassificationExperiment:

"""
Load an experiment saved with ``save_experiment`` from path
or file.
Expand Down Expand Up @@ -2938,7 +2913,6 @@ def get_leaderboard(
groups: Optional[Union[str, Any]] = None,
verbose: bool = True,
) -> pd.DataFrame:

"""
This function returns the leaderboard of all models trained in the
current setup.
Expand Down Expand Up @@ -3049,7 +3023,6 @@ def dashboard(

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def convert_model(estimator, language: str = "python") -> str:

"""
This function transpiles trained machine learning models into native
inference script in different programming languages (Python, C, Java,
Expand Down Expand Up @@ -3102,7 +3075,6 @@ def convert_model(estimator, language: str = "python") -> str:

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def eda(display_format: str = "bokeh", **kwargs):

"""
This function generates AutoEDA using AutoVIZ library. You must
install Autoviz separately ``pip install autoviz`` to use this
Expand Down Expand Up @@ -3134,7 +3106,6 @@ def eda(display_format: str = "bokeh", **kwargs):

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def check_fairness(estimator, sensitive_features: list, plot_kwargs: dict = {}):

"""
There are many approaches to conceptualizing fairness. This function follows
the approach known as group fairness, which asks: Which groups of individuals
Expand Down Expand Up @@ -3180,7 +3151,6 @@ def check_fairness(estimator, sensitive_features: list, plot_kwargs: dict = {}):
def create_api(
estimator, api_name: str, host: str = "127.0.0.1", port: int = 8000
) -> None:

"""
This function takes an input ``estimator`` and creates a POST API for
inference. It only creates the API and doesn't run it automatically.
Expand Down Expand Up @@ -3226,7 +3196,6 @@ def create_api(
def create_docker(
api_name: str, base_image: str = "python:3.8-slim", expose_port: int = 8000
) -> None:

"""
This function creates a ``Dockerfile`` and ``requirements.txt`` for
productionalizing API end-point.
Expand Down Expand Up @@ -3265,7 +3234,6 @@ def create_docker(

@check_if_global_is_not_none(globals(), _CURRENT_EXPERIMENT_DECORATOR_DICT)
def create_app(estimator, app_kwargs: Optional[dict] = None) -> None:

"""
This function creates a basic gradio app for inference.
It will later be expanded for other app types such as
Expand Down

0 comments on commit 7f57794

Please sign in to comment.