Skip to content

Commit 42957ea

Browse files
Merge pull request #344 from KhiopsML/342-eliminate-pandas-warning-in-samples
Avoid pandas warning in samples when reading Accidents/Places table
2 parents aa4f95c + b7b5f54 commit 42957ea

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

doc/samples/samples_sklearn.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ Samples
218218
accidents_df = pd.read_csv(os.path.join(accidents_data_dir, "Accidents.txt"), sep="\t")
219219
users_df = pd.read_csv(os.path.join(accidents_data_dir, "Users.txt"), sep="\t")
220220
vehicles_df = pd.read_csv(os.path.join(accidents_data_dir, "Vehicles.txt"), sep="\t")
221-
places_df = pd.read_csv(os.path.join(accidents_data_dir, "Places.txt"), sep="\t")
221+
places_df = pd.read_csv(
222+
os.path.join(accidents_data_dir, "Places.txt"), sep="\t", low_memory=False
223+
)
222224
223225
# Build the multi-table dataset spec (drop the target column "Gravity")
224226
X = {
@@ -588,7 +590,9 @@ Samples
588590
accidents_df = pd.read_csv(os.path.join(accidents_data_dir, "Accidents.txt"), sep="\t")
589591
users_df = pd.read_csv(os.path.join(accidents_data_dir, "Users.txt"), sep="\t")
590592
vehicles_df = pd.read_csv(os.path.join(accidents_data_dir, "Vehicles.txt"), sep="\t")
591-
places_df = pd.read_csv(os.path.join(accidents_data_dir, "Places.txt"), sep="\t")
593+
places_df = pd.read_csv(
594+
os.path.join(accidents_data_dir, "Places.txt"), sep="\t", low_memory=False
595+
)
592596
593597
# Build the multi-table dataset spec (drop the target column "Gravity")
594598
X = {

khiops/samples/samples_sklearn.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,9 @@
243243
"accidents_df = pd.read_csv(os.path.join(accidents_data_dir, \"Accidents.txt\"), sep=\"\\t\")\n",
244244
"users_df = pd.read_csv(os.path.join(accidents_data_dir, \"Users.txt\"), sep=\"\\t\")\n",
245245
"vehicles_df = pd.read_csv(os.path.join(accidents_data_dir, \"Vehicles.txt\"), sep=\"\\t\")\n",
246-
"places_df = pd.read_csv(os.path.join(accidents_data_dir, \"Places.txt\"), sep=\"\\t\")\n",
246+
"places_df = pd.read_csv(\n",
247+
" os.path.join(accidents_data_dir, \"Places.txt\"), sep=\"\\t\", low_memory=False\n",
248+
")\n",
247249
"\n",
248250
"# Build the multi-table dataset spec (drop the target column \"Gravity\")\n",
249251
"X = {\n",
@@ -704,7 +706,9 @@
704706
"accidents_df = pd.read_csv(os.path.join(accidents_data_dir, \"Accidents.txt\"), sep=\"\\t\")\n",
705707
"users_df = pd.read_csv(os.path.join(accidents_data_dir, \"Users.txt\"), sep=\"\\t\")\n",
706708
"vehicles_df = pd.read_csv(os.path.join(accidents_data_dir, \"Vehicles.txt\"), sep=\"\\t\")\n",
707-
"places_df = pd.read_csv(os.path.join(accidents_data_dir, \"Places.txt\"), sep=\"\\t\")\n",
709+
"places_df = pd.read_csv(\n",
710+
" os.path.join(accidents_data_dir, \"Places.txt\"), sep=\"\\t\", low_memory=False\n",
711+
")\n",
708712
"\n",
709713
"# Build the multi-table dataset spec (drop the target column \"Gravity\")\n",
710714
"X = {\n",

khiops/samples/samples_sklearn.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,9 @@ def khiops_classifier_multitable_snowflake():
218218
vehicles_df = pd.read_csv(
219219
os.path.join(accidents_data_dir, "Vehicles.txt"), sep="\t"
220220
)
221-
places_df = pd.read_csv(os.path.join(accidents_data_dir, "Places.txt"), sep="\t")
221+
places_df = pd.read_csv(
222+
os.path.join(accidents_data_dir, "Places.txt"), sep="\t", low_memory=False
223+
)
222224

223225
# Build the multi-table dataset spec (drop the target column "Gravity")
224226
X = {
@@ -614,7 +616,9 @@ def khiops_encoder_multitable_snowflake():
614616
vehicles_df = pd.read_csv(
615617
os.path.join(accidents_data_dir, "Vehicles.txt"), sep="\t"
616618
)
617-
places_df = pd.read_csv(os.path.join(accidents_data_dir, "Places.txt"), sep="\t")
619+
places_df = pd.read_csv(
620+
os.path.join(accidents_data_dir, "Places.txt"), sep="\t", low_memory=False
621+
)
618622

619623
# Build the multi-table dataset spec (drop the target column "Gravity")
620624
X = {

khiops/sklearn/estimators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,8 @@ def _create_computation_dir(self, method_name):
677677
def _assert_is_fitted(self):
678678
try:
679679
check_is_fitted(self)
680-
except NotFittedError:
681-
raise AssertionError("Model not fitted")
680+
except NotFittedError as exc:
681+
raise AssertionError("Model not fitted") from exc
682682

683683

684684
# Note: scikit-learn **requires** inherit first the mixins and then other classes

tests/test_remote_access.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ def is_in_a_conda_env():
129129
if not isinstance(kh.get_runner(), KhiopsLocalRunner):
130130
return False
131131

132-
# Get path to the Khiops executable
132+
# Get path to the Khiops executable (temporarily disable pylint warning)
133+
# pylint: disable=protected-access
133134
khiops_path = kh.get_runner()._khiops_path
135+
# pylint: enable=protected-access
134136

135137
# If $(dirname khiops_path) is identical to $CONDA_PREFIX/bin,
136138
# then return True

tests/test_sklearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import numpy as np
1717
from sklearn.exceptions import NotFittedError
1818
from sklearn.utils.estimator_checks import check_estimator
19-
from sklearn.utils.validation import NotFittedError, check_is_fitted
19+
from sklearn.utils.validation import check_is_fitted
2020

2121
import khiops.core as kh
2222
from khiops.sklearn.estimators import (

0 commit comments

Comments
 (0)