From 958f7332f071aa0a3ba5a252ce979beaaab787f2 Mon Sep 17 00:00:00 2001 From: Deepyaman Datta Date: Fri, 10 May 2024 20:55:39 -0600 Subject: [PATCH] refactor(steps): start every step name with a verb --- docs/tutorial/index.ipynb | 2 +- ibis_ml/steps/__init__.py | 8 ++++---- ibis_ml/steps/_feature_engineering.py | 6 +++--- ibis_ml/steps/_feature_selection.py | 8 ++++---- tests/test_feature_engineering.py | 4 ++-- tests/test_feature_selection.py | 4 ++-- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/docs/tutorial/index.ipynb b/docs/tutorial/index.ipynb index c1a3330..c561e12 100644 --- a/docs/tutorial/index.ipynb +++ b/docs/tutorial/index.ipynb @@ -538,7 +538,7 @@ " ml.ExpandDate(\"date\", components=[\"dow\", \"month\"]),\n", " ml.Drop(\"date\"),\n", " ml.TargetEncode(ml.nominal()),\n", - " ml.ZeroVariance(ml.everything()),\n", + " ml.DropZeroVariance(ml.everything()),\n", " ml.MutateAt(\"dep_time\", ibis._.hour() * 60 + ibis._.minute()),\n", " ml.MutateAt(ml.timestamp(), ibis._.epoch_seconds()),\n", " # By default, PyTorch requires that the type of `X` is `np.float32`.\n", diff --git a/ibis_ml/steps/__init__.py b/ibis_ml/steps/__init__.py index 9412620..c2e9383 100644 --- a/ibis_ml/steps/__init__.py +++ b/ibis_ml/steps/__init__.py @@ -6,8 +6,8 @@ OneHotEncode, TargetEncode, ) -from ibis_ml.steps._feature_engineering import PolynomialFeatures -from ibis_ml.steps._feature_selection import ZeroVariance +from ibis_ml.steps._feature_engineering import CreatePolynomialFeatures +from ibis_ml.steps._feature_selection import DropZeroVariance from ibis_ml.steps._impute import FillNA, ImputeMean, ImputeMedian, ImputeMode from ibis_ml.steps._standardize import ScaleMinMax, ScaleStandard from ibis_ml.steps._temporal import ExpandDate, ExpandDateTime, ExpandTime @@ -16,8 +16,10 @@ "Cast", "CategoricalEncode", "CountEncode", + "CreatePolynomialFeatures", "DiscretizeKBins", "Drop", + "DropZeroVariance", "ExpandDate", "ExpandDateTime", "ExpandTime", @@ -28,9 +30,7 @@ "Mutate", "MutateAt", "OneHotEncode", - "PolynomialFeatures", "ScaleMinMax", "ScaleStandard", "TargetEncode", - "ZeroVariance", ) diff --git a/ibis_ml/steps/_feature_engineering.py b/ibis_ml/steps/_feature_engineering.py index 2ffc9c1..207366b 100644 --- a/ibis_ml/steps/_feature_engineering.py +++ b/ibis_ml/steps/_feature_engineering.py @@ -12,7 +12,7 @@ from ibis_ml.select import SelectionType, selector -class PolynomialFeatures(Step): +class CreatePolynomialFeatures(Step): """A step for generating polynomial features. Parameters @@ -29,11 +29,11 @@ class PolynomialFeatures(Step): Generate polynomial features for all numeric columns with a degree is 2. - >>> step = ml.PolynomialFeatures(ml.numeric(), degree=2) + >>> step = ml.CreatePolynomialFeatures(ml.numeric(), degree=2) Generate polynomial features a specific set of columns. - >>> step = ml.PolynomialFeatures(["x", "y"], degree=2) + >>> step = ml.CreatePolynomialFeatures(["x", "y"], degree=2) """ def __init__(self, inputs: SelectionType, *, degree: int = 2): diff --git a/ibis_ml/steps/_feature_selection.py b/ibis_ml/steps/_feature_selection.py index 851af04..28013f0 100644 --- a/ibis_ml/steps/_feature_selection.py +++ b/ibis_ml/steps/_feature_selection.py @@ -8,7 +8,7 @@ from ibis_ml.select import SelectionType, selector -class ZeroVariance(Step): +class DropZeroVariance(Step): """A step for removing columns with zero variance. Parameters @@ -25,13 +25,13 @@ class ZeroVariance(Step): >>> import ibis_ml as ml To remove columns with zero variance: - >>> step = ml.ZeroVariance(ml.everything()) + >>> step = ml.DropZeroVariance(ml.everything()) To remove all numeric columns with zero variance: - >>> step = ml.ZeroVariance(ml.numeric()) + >>> step = ml.DropZeroVariance(ml.numeric()) To remove all string or categorical columns with only one unique value: - >>> step = ml.ZeroVariance(ml.nominal()) + >>> step = ml.DropZeroVariance(ml.nominal()) """ def __init__(self, inputs: SelectionType, *, tolerance: int | float = 1e-4): diff --git a/tests/test_feature_engineering.py b/tests/test_feature_engineering.py index 9faf48e..376ec60 100644 --- a/tests/test_feature_engineering.py +++ b/tests/test_feature_engineering.py @@ -11,8 +11,8 @@ def train_table(): return ibis.memtable({"x": list(range(N)), "y": [10] * N, "z": ["s"] * N}) -def test_PolynomialFeatures(train_table): - step = ml.PolynomialFeatures(ml.numeric(), degree=2) +def test_create_polynomial_features(train_table): + step = ml.CreatePolynomialFeatures(ml.numeric(), degree=2) step.fit_table(train_table, ml.core.Metadata()) result = step.transform_table(train_table) expected = train_table.mutate( diff --git a/tests/test_feature_selection.py b/tests/test_feature_selection.py index cd5e5a1..1cc79f5 100644 --- a/tests/test_feature_selection.py +++ b/tests/test_feature_selection.py @@ -4,7 +4,7 @@ import ibis_ml as ml -def test_zero_variance(): +def test_drop_zero_variance(): zv_numeric_col = [1.0] * 10 non_zv_numeric_col = list(range(10)) zv_string_col = ["String"] * 10 @@ -42,7 +42,7 @@ def test_zero_variance(): } ) - step = ml.ZeroVariance(ml.everything()) + step = ml.DropZeroVariance(ml.everything()) step.fit_table(t_train, ml.core.Metadata()) res = step.transform_table(t_test) sol = t_test.drop(zv_cols)