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

143 serialization deserialization bug #178

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions cobra/model_building/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from .univariate_selection import compute_univariate_preselection
from .univariate_selection import get_preselected_predictors
from .univariate_selection import compute_correlations
from .models import LogisticRegressionModel, LinearRegressionModel
from .forward_selection import ForwardFeatureSelection
__all__ = ['compute_univariate_preselection',
'get_preselected_predictors',
'compute_correlations',
'LogisticRegressionModel',
'LinearRegressionModel',
'ForwardFeatureSelection']
from .univariate_selection import compute_univariate_preselection
from .univariate_selection import get_preselected_predictors
from .univariate_selection import compute_correlations

from .models import LogisticRegressionModel, LinearRegressionModel
from .forward_selection import ForwardFeatureSelection

__all__ = ['compute_univariate_preselection',
'get_preselected_predictors',
'compute_correlations',
'LogisticRegressionModel',
'LinearRegressionModel',
'ForwardFeatureSelection']
3 changes: 2 additions & 1 deletion cobra/preprocessing/target_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tqdm.auto import tqdm
from sklearn.base import BaseEstimator
from sklearn.exceptions import NotFittedError
import numpy as np

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -123,7 +124,7 @@ def set_attributes_from_dict(self, params: dict):
params["imputation_strategy"] in self.valid_imputation_strategies):
self.imputation_strategy = params["imputation_strategy"]

if "_global_mean" in params and type(params["_global_mean"]) == float:
if "_global_mean" in params and isinstance(params["_global_mean"], (np.floating, float)):
self._global_mean = params["_global_mean"]

_mapping = {}
Expand Down
48 changes: 24 additions & 24 deletions cobra/utils.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import logging
# logger = logging.getLogger(__name__)
# logger.setLevel(logging.INFO)
# logger.addHandler(logging.Handler())
def clean_predictor_name(predictor_name: str) -> str:
"""Strip the redundant suffix (e.g. "_enc" or "_bin") off from the end
of the predictor name to return a clean version of the predictor
"""
return (
predictor_name.replace("_enc", "").replace("_bin", "").replace("_processed", "")
)
def log_tutorial() -> None:
logging.info(
"""
Hi, welcome to Cobra!
You can find some tutorials that explain the functioning of cobra on the PythonPredictions GitHub:
https://github.com/PythonPredictions/cobra/tree/master/tutorials
"""
)
import logging

# logger = logging.getLogger(__name__)
# logger.setLevel(logging.INFO)
# logger.addHandler(logging.Handler())


def clean_predictor_name(predictor_name: str) -> str:
"""Strip the redundant suffix (e.g. "_enc" or "_bin") off from the end
of the predictor name to return a clean version of the predictor
"""
return (
predictor_name.replace("_enc", "").replace("_bin", "").replace("_processed", "")
)


def log_tutorial() -> None:
logging.info(
"""
Hi, welcome to Cobra!
You can find some tutorials that explain the functioning of cobra on the PythonPredictions GitHub:
https://github.com/PythonPredictions/cobra/tree/master/tutorials
"""
)
70 changes: 35 additions & 35 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
Loading