Skip to content

Commit

Permalink
refactor(steps): start every step name with a verb
Browse files Browse the repository at this point in the history
  • Loading branch information
deepyaman authored and jitingxu1 committed May 13, 2024
1 parent ec8ddd5 commit 958f733
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/tutorial/index.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions ibis_ml/steps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,8 +16,10 @@
"Cast",
"CategoricalEncode",
"CountEncode",
"CreatePolynomialFeatures",
"DiscretizeKBins",
"Drop",
"DropZeroVariance",
"ExpandDate",
"ExpandDateTime",
"ExpandTime",
Expand All @@ -28,9 +30,7 @@
"Mutate",
"MutateAt",
"OneHotEncode",
"PolynomialFeatures",
"ScaleMinMax",
"ScaleStandard",
"TargetEncode",
"ZeroVariance",
)
6 changes: 3 additions & 3 deletions ibis_ml/steps/_feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ibis_ml.select import SelectionType, selector


class PolynomialFeatures(Step):
class CreatePolynomialFeatures(Step):
"""A step for generating polynomial features.
Parameters
Expand All @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions ibis_ml/steps/_feature_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_feature_engineering.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_feature_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 958f733

Please sign in to comment.