We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents b461123 + 394b431 commit d120937Copy full SHA for d120937
setup.py
@@ -25,7 +25,7 @@
25
'Programming Language :: Python :: 3',
26
],
27
keywords='python data science machine learning pandas sklearn',
28
- packages=find_packages(exclude=['tests*']),
+ packages=find_packages(include=['category_encoders']),
29
include_package_data=True,
30
author='Will McGinnis',
31
install_requires=[
tests/test_leave_one_out.py
@@ -116,3 +116,23 @@ def test_HandleUnknownValue_HaveUnknownInTest_ExpectMean(self):
116
obtained = ce_leave.transform(test, test_target)
117
118
self.assertEqual([1.0, .6], list(obtained['color']))
119
+
120
+ def test_leave_one_out_categorical(self):
121
+ """
122
+ test that if the input is a pd.Categorical the output is the same as for string columns
123
+ :return:
124
125
+ df = pd.DataFrame({
126
+ 'color_str': ["a", "a", "a", "b", "b", "b"],
127
+ 'color_num_cat': pd.Categorical([1.0, 1.0, 1.0, 2.0, 2.0, 2.0]),
128
+ 'color_str_cat': pd.Categorical(["a", "a", "a", "b", "b", "b"]),
129
+ 'outcome': [1, 0, 0, 1, 0, 1]})
130
131
+ X = df.drop('outcome', axis=1)
132
+ y = df["outcome"]
133
134
+ ce_leave = encoders.LeaveOneOutEncoder()
135
+ obtained = ce_leave.fit_transform(X, y)
136
137
+ for col in obtained.columns:
138
+ self.assertEqual([0.0, 0.5, 0.5, 0.5, 1.0, 0.5], list(obtained[col]))
0 commit comments