Skip to content

Commit

Permalink
Merge pull request pycaret#2052 from pycaret/master
Browse files Browse the repository at this point in the history
update create_app
  • Loading branch information
Yard1 authored Jan 11, 2022
2 parents 79494dd + ee7d76f commit 1ef716a
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 18 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
All notable changes to this project will be documented in this file.
<br/><br/>

#### Release: PyCaret 2.3.6 | Release Date: January 11th, 2022 (NEW FEATURES, BUG FIXES)
- Added new function `create_docker` (https://github.com/pycaret/pycaret/pull/2005)
- Added new function `create_api` (https://github.com/pycaret/pycaret/pull/2000)
- Added new function `check_fairness` (https://github.com/pycaret/pycaret/pull/1997)
- Added new function `eda` (https://github.com/pycaret/pycaret/pull/1983)
- Added new function `convert_model` (https://github.com/pycaret/pycaret/pull/1959)
- Added an ability to pass kwargs to plots in `plot_model` (https://github.com/pycaret/pycaret/pull/19400)
- Added `drift_report` functionality to `predict_model` (https://github.com/pycaret/pycaret/pull/1935)
- Added new function `create_dashboard` (https://github.com/pycaret/pycaret/pull/1925)
- Added `grid_interval` parameter to `optimize_threshold` - thanks to @wolfryu (https://github.com/pycaret/pycaret/pull/1938)
- Made logging level configurable by environment variable (https://github.com/pycaret/pycaret/pull/2026)
- Made the optional path in AWS configurable (https://github.com/pycaret/pycaret/pull/2045)
- Fixed TSNE plot with PCA (https://github.com/pycaret/pycaret/pull/2032)
- Fixed rendering of streamlit plots (https://github.com/pycaret/pycaret/pull/2008)
- Fixed class names in `tree` plot - thanks to @yamasakih (https://github.com/pycaret/pycaret/pull/1982)
- Fixed NearZeroVariance preprocessor not being configurable - thanks to @Flyfoxs (https://github.com/pycaret/pycaret/pull/1952)
- Removed duplicated code - thanks to @Flyfoxs (https://github.com/pycaret/pycaret/pull/1882)
- Documentation improvements - thanks to @harsh204016, @khrapovs (https://github.com/pycaret/pycaret/pull/1931/files, https://github.com/pycaret/pycaret/pull/1956, https://github.com/pycaret/pycaret/pull/1946, https://github.com/pycaret/pycaret/pull/1949)
- Pinned `pyyaml<6.0.0` to fix issues with Google Colab
<br/><br/><br/>

#### Release: PyCaret 2.3.5 | Release Date: November 19th, 2021 (NEW FEATURES, BUG FIXES)
- Fixed an issue where `Fix_multicollinearity` would fail if the target was a float (https://github.com/pycaret/pycaret/pull/1640)
- MLFlow runs are now nested - thanks to @jfagn (https://github.com/pycaret/pycaret/pull/1660)
Expand Down
2 changes: 1 addition & 1 deletion pycaret/anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ def load_model(
dictionary of applicable authentication tokens.
when platform = 'aws':
{'bucket' : 'S3-bucket-name'}
{'bucket' : 'Name of Bucket on S3', 'path': (optional) folder name under the bucket}
when platform = 'gcp':
{'project': 'gcp-project-name', 'bucket' : 'gcp-bucket-name'}
Expand Down
4 changes: 2 additions & 2 deletions pycaret/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ def optimize_threshold(
optimize: str = "Accuracy",
grid_interval: float = 0.1,
return_data: bool = False,
plot_kwargs: dict = {},
plot_kwargs: Optional[dict] = None,
):

"""
Expand Down Expand Up @@ -2265,7 +2265,7 @@ def load_model(
dictionary of applicable authentication tokens.
when platform = 'aws':
{'bucket' : 'S3-bucket-name'}
{'bucket' : 'Name of Bucket on S3', 'path': (optional) folder name under the bucket}
when platform = 'gcp':
{'project': 'gcp-project-name', 'bucket' : 'gcp-bucket-name'}
Expand Down
2 changes: 1 addition & 1 deletion pycaret/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ def load_model(
dictionary of applicable authentication tokens.
when platform = 'aws':
{'bucket' : 'S3-bucket-name'}
{'bucket' : 'Name of Bucket on S3', 'path': (optional) folder name under the bucket}
when platform = 'gcp':
{'project': 'gcp-project-name', 'bucket' : 'gcp-bucket-name'}
Expand Down
10 changes: 8 additions & 2 deletions pycaret/internal/persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def load_model(
dictionary of applicable authentication tokens.
When platform = 'aws':
{'bucket' : 'Name of Bucket on S3'}
{'bucket' : 'Name of Bucket on S3', 'path': (optional) folder name under the bucket}
When platform = 'gcp':
{'project': 'gcp_pycaret', 'bucket' : 'pycaret-test'}
Expand Down Expand Up @@ -415,11 +415,17 @@ def load_model(
raise ValueError('S3 bucket name missing. Provide `bucket` name as part of authentication parameter')

filename = f"{model_name}.pkl"

if "path" in authentication:
key = os.path.join(authentication.get("path"), filename)
else:
key = filename

index = filename.rfind("/")
s3 = boto3.resource("s3")

if index == -1:
s3.Bucket(bucketname).download_file(filename, filename)
s3.Bucket(bucketname).download_file(key, filename)
else:
path, key = filename[: index + 1], filename[index + 1:]
if not os.path.exists(path):
Expand Down
10 changes: 6 additions & 4 deletions pycaret/internal/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -8305,7 +8305,7 @@ def optimize_threshold(
optimize: str = "Accuracy",
grid_interval: float = 0.1,
return_data: bool = False,
plot_kwargs: dict = {},
plot_kwargs: Optional[dict] = None,
):

"""
Expand Down Expand Up @@ -8396,11 +8396,12 @@ def optimize_threshold(

if isinstance(optimize, str):
# checking optimize parameter
optimize = _get_metric(optimize).display_name
optimize = _get_metric(optimize)
if optimize is None:
raise ValueError(
"Optimize method not supported. See docstring for list of available parameters."
)
optimize = optimize.display_name

"""
ERROR HANDLING ENDS HERE
Expand Down Expand Up @@ -8436,11 +8437,12 @@ def optimize_threshold(
optimized_metric_index = np.array(results_concat_melted[results_concat_melted['variable'] == optimize]['value']).argmax()
best_model_by_metric = models_by_threshold[optimized_metric_index]

logger.info("plotting optimizartion threshold using plotly")
logger.info("plotting optimization threshold using plotly")

# plotting threshold
import plotly.express as px
title = str(model_name) + " Probability Threshold Optimization (default = 0.5) "
title = f"{model_name} Probability Threshold Optimization (default = 0.5)"
plot_kwargs = plot_kwargs or {}
fig = px.line(results_concat_melted, x="probability_threshold", y="value", title = title,\
color='variable', **plot_kwargs)
logger.info("Figure ready for render")
Expand Down
2 changes: 1 addition & 1 deletion pycaret/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ def load_model(
dictionary of applicable authentication tokens.
when platform = 'aws':
{'bucket' : 'S3-bucket-name'}
{'bucket' : 'Name of Bucket on S3', 'path': (optional) folder name under the bucket}
when platform = 'gcp':
{'project': 'gcp-project-name', 'bucket' : 'gcp-bucket-name'}
Expand Down
5 changes: 4 additions & 1 deletion pycaret/tests/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import boto3
from moto import mock_s3
from pycaret.internal.persistence import deploy_model
from pycaret.internal.persistence import deploy_model, load_model


@pytest.fixture(scope='function')
Expand All @@ -29,5 +29,8 @@ def test_deploy_model(s3):
model_name = 'test'

deploy_model(model, model_name=model_name, platform='aws', authentication=authentication)

s3.head_object(Bucket=authentication.get("bucket"),
Key=os.path.join(authentication.get("path"), f"{model_name}.pkl"))

_ = load_model(model_name=model_name, platform='aws', authentication=authentication, verbose=True)
4 changes: 2 additions & 2 deletions pycaret/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import pandas as pd
import functools

version_ = "2.3.5"
nightly_version_ = "2.3.5"
version_ = "2.3.6"
nightly_version_ = "2.3.6"

__version__ = version_

Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pandas
scipy<=1.5.4
numpy==1.19.5
seaborn
matplotlib
IPython
Expand All @@ -27,4 +26,4 @@ imbalanced-learn==0.7.0
scikit-plot #for lift and gain charts
Boruta
pyyaml<6.0.0
#numba<0.54
#numba<0.54
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def readme():

setup(
name="pycaret",
version="2.3.5",
version="2.3.6",
description="PyCaret - An open source, low-code machine learning library in Python.",
long_description=readme(),
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion setup_nightly.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from setuptools import setup, find_packages
import time

nightly_version = "2.3.5"
nightly_version = "2.3.6"

nightly_readme = f"This is a nightly version of the [PyCaret](https://pypi.org/project/pycaret/) library, intended as a preview of the upcoming {nightly_version} version. It may contain unstable and untested code.\n"

Expand Down

0 comments on commit 1ef716a

Please sign in to comment.