Skip to content

Commit

Permalink
modified lower_case.py
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoli committed Mar 5, 2024
1 parent a931432 commit 6345b1a
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 1,064 deletions.
2 changes: 1 addition & 1 deletion gators/encoders/count_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CountEncoder(_BaseEncoder):

def __init__(self, columns=None, inplace=True):
_BaseEncoder.__init__(self, columns=columns, inplace=inplace)
self.suffix = "frequency"
self.suffix = "count"

def generate_mapping(
self, X: DataFrame, y: Series = None
Expand Down
12 changes: 6 additions & 6 deletions gators/encoders/tests/test_count_encoder_pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def data_not_inplace():
"B": ["Q", "W", "W"],
"C": ["W", "Q", "W"],
"D": [1.0, 2.0, 3.0],
"A__frequency": [2.0, 2.0, 1.0],
"B__frequency": [1.0, 2.0, 2.0],
"C__frequency": [2.0, 1.0, 2.0],
"A__count": [2.0, 2.0, 1.0],
"B__count": [1.0, 2.0, 2.0],
"C__count": [2.0, 1.0, 2.0],
}
)
X_expected_numpy = pd.DataFrame(
Expand All @@ -66,9 +66,9 @@ def data_not_inplace():
"B": ["Q", "W", "W"],
"C": ["W", "Q", "W"],
"D": [1.0, 2.0, 3.0],
"A__frequency": [2.0, 2.0, 1.0],
"B__frequency": [1.0, 2.0, 2.0],
"C__frequency": [2.0, 1.0, 2.0],
"A__count": [2.0, 2.0, 1.0],
"B__count": [1.0, 2.0, 2.0],
"C__count": [2.0, 1.0, 2.0],
}
).astype(object)
obj = CountEncoder(inplace=False).fit(X)
Expand Down
8 changes: 4 additions & 4 deletions gators/feature_generation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from .is_null import IsNull
from .one_hot import OneHot
from .plan_rotation import PlanRotation
from .larger_than_bool import LargerThanBool
from .smaller_than_bool import SmallerThanBool
from .is_larger_than import IsLargerThan
from .is_smaller_than import IsSmallerThan
from .negation_bool import NegationBool
from .polynomial_features import PolynomialFeatures
from .polynomial_object_features import PolynomialObjectFeatures
Expand All @@ -20,8 +20,8 @@
"ClusterStatistics",
"PlanRotation",
"PolynomialFeatures",
"LargerThanBool",
"SmallerThanBool",
"IsLargerThan",
"IsSmallerThan",
"NegationBool",
"PolynomialObjectFeatures",
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from gators import DataFrame, Series


class LargerThanBool(_BaseFeatureGeneration):
class IsLargerThan(_BaseFeatureGeneration):
"""Create new columns based on the following definition: X[binarized_col] = X[col] >= bound.
Parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from ..util import util

from .larger_than_bool import LargerThanBool
from .is_larger_than import IsLargerThan

from gators import DataFrame


class SmallerThanBool(LargerThanBool):
class IsSmallerThan(IsLargerThan):
"""Create new columns based on the following definition: X[binarized_col] = X[col] >= bound.
Parameters
Expand Down Expand Up @@ -64,9 +64,7 @@ class SmallerThanBool(LargerThanBool):
def __init__(
self, bounds_dict: Dict[str, List[float]], column_names: List[str] = None
):
LargerThanBool.__init__(
self, bounds_dict=bounds_dict, column_names=column_names
)
IsLargerThan.__init__(self, bounds_dict=bounds_dict, column_names=column_names)
if not column_names:
self.column_names = [
f"{col}__-inf_{bound}"
Expand Down
2 changes: 1 addition & 1 deletion gators/feature_generation_str/split_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def transform(self, X: DataFrame) -> DataFrame:
for col, idx, str_split, name in zip(
self.columns, self.idx_split_vec, self.str_split_vec, self.column_names
):
X[name] = X[col].str.split(pad=str_split).str.get(idx).fillna("")
X[name] = X[col].str.split(str_split).str.get(idx).fillna("")

return X

Expand Down
12 changes: 6 additions & 6 deletions tests.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ gators/feature_generation_str/tests/test_string_contains_ks.py: 12 warnings
gators/feature_selection/tests/test_select_from_model_dd.py::test_dd_np
/Users/cpoli/gators311/lib/python3.11/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 53864 instead
Hosting the HTTP server on port 57890 instead
warnings.warn(

gators/feature_selection/tests/test_select_from_model_ks.py::test_ks
Expand All @@ -640,25 +640,25 @@ gators/feature_selection/tests/test_select_from_models_ks.py::test_ks_np
gators/feature_selection/tests/test_select_from_models_dd.py::test_dd
/Users/cpoli/gators311/lib/python3.11/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 53912 instead
Hosting the HTTP server on port 57937 instead
warnings.warn(

gators/feature_selection/tests/test_select_from_models_dd.py::test_dd
/Users/cpoli/gators311/lib/python3.11/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 53939 instead
Hosting the HTTP server on port 57964 instead
warnings.warn(

gators/feature_selection/tests/test_select_from_models_dd.py::test_dd_np
/Users/cpoli/gators311/lib/python3.11/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 53983 instead
Hosting the HTTP server on port 58005 instead
warnings.warn(

gators/feature_selection/tests/test_select_from_models_dd.py::test_dd_np
/Users/cpoli/gators311/lib/python3.11/site-packages/distributed/node.py:182: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 54010 instead
Hosting the HTTP server on port 58032 instead
warnings.warn(

gators/sampling/tests/test_supervised_sampling_dd.py::test_dd
Expand Down Expand Up @@ -699,4 +699,4 @@ gators/scalers/tests/test_yeo_johnson_pd.py::test_not_inplace_pd
result = getattr(ufunc, method)(*inputs, **kwargs)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=============== 830 passed, 215040 warnings in 434.00s (0:07:14) ===============
=============== 830 passed, 215040 warnings in 437.66s (0:07:17) ===============
3 changes: 0 additions & 3 deletions tests.txt

This file was deleted.

Loading

0 comments on commit 6345b1a

Please sign in to comment.