You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When calling X_train_brl_df = disc.fit_transform(pd.DataFrame(X_train[:, :3], columns=feat_names[:3])) I get:
[/usr/lib64/python3.13/site-packages/sklearn/preprocessing/_discretization.py:248](http://localhost:8888/usr/lib64/python3.13/site-packages/sklearn/preprocessing/_discretization.py#line=247): FutureWarning: In version 1.5 onwards, subsample=200_000 will be used by default. Set subsample explicitly to silence this warning in the mean time. Set subsample=None to disable subsampling explicitly.warnings.warn(
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
CellIn[17], line1---->1X_train_brl_df=disc.fit_transform(pd.DataFrame(X_train[:, :3], columns=feat_names[:3]))
File [/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py:295](http://localhost:8888/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py#line=294), in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)293 @wraps(f)
294defwrapped(self, X, *args, **kwargs):
-->295data_to_wrap=f(self, X, *args, **kwargs)
296ifisinstance(data_to_wrap, tuple):
297# only wrap the first output for cross decomposition298return_tuple= (
299_wrap_data_with_container(method, data_to_wrap[0], X, self),
300*data_to_wrap[1:],
301 )
File [/usr/lib64/python3.13/site-packages/sklearn/base.py:1098](http://localhost:8888/usr/lib64/python3.13/site-packages/sklearn/base.py#line=1097), in TransformerMixin.fit_transform(self, X, y, **fit_params)1083warnings.warn(
1084 (
1085f"This object ({self.__class__.__name__}) has a `transform`"
(...)
1093UserWarning,
1094 )
1096ifyisNone:
1097# fit method of arity 1 (unsupervised transformation)->1098returnself.fit(X, **fit_params).transform(X)
1099else:
1100# fit method of arity 2 (supervised transformation)1101returnself.fit(X, y, **fit_params).transform(X)
File [/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py:295](http://localhost:8888/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py#line=294), in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)293 @wraps(f)
294defwrapped(self, X, *args, **kwargs):
-->295data_to_wrap=f(self, X, *args, **kwargs)
296ifisinstance(data_to_wrap, tuple):
297# only wrap the first output for cross decomposition298return_tuple= (
299_wrap_data_with_container(method, data_to_wrap[0], X, self),
300*data_to_wrap[1:],
301 )
File [/usr/lib/python3.13/site-packages/imodels/discretization/discretizer.py:391](http://localhost:8888/usr/lib/python3.13/site-packages/imodels/discretization/discretizer.py#line=390), in ExtraBasicDiscretizer.transform(self, X)389# One-hot encode the ordinal DF390disc_onehot_np=self.encoder_.transform(disc_ordinal_df_str)
-->391disc_onehot=pd.DataFrame(
392disc_onehot_np, columns=self.encoder_.get_feature_names_out())
394# Name columns after the interval they represent (e.g. 0.1_to_0.5)395forcol, bin_edgesinzip(self.dcols, self.discretizer_.bin_edges_):
File [/usr/lib64/python3.13/site-packages/pandas/core/frame.py:856](http://localhost:8888/usr/lib64/python3.13/site-packages/pandas/core/frame.py#line=855), in DataFrame.__init__(self, data, index, columns, dtype, copy)848mgr=arrays_to_mgr(
849arrays,
850columns,
(...)
853typ=manager,
854 )
855else:
-->856mgr=ndarray_to_mgr(
857data,
858index,
859columns,
860dtype=dtype,
861copy=copy,
862typ=manager,
863 )
864else:
865mgr=dict_to_mgr(
866 {},
867index,
(...)
870typ=manager,
871 )
File [/usr/lib64/python3.13/site-packages/pandas/core/internals/construction.py:336](http://localhost:8888/usr/lib64/python3.13/site-packages/pandas/core/internals/construction.py#line=335), in ndarray_to_mgr(values, index, columns, dtype, copy, typ)331# _prep_ndarraylike ensures that values.ndim == 2 at this point332index, columns=_get_axes(
333values.shape[0], values.shape[1], index=index, columns=columns334 )
-->336_check_values_indices_shape_match(values, index, columns)
338iftyp=="array":
339ifissubclass(values.dtype.type, str):
File [/usr/lib64/python3.13/site-packages/pandas/core/internals/construction.py:420](http://localhost:8888/usr/lib64/python3.13/site-packages/pandas/core/internals/construction.py#line=419), in _check_values_indices_shape_match(values, index, columns)418passed=values.shape419implied= (len(index), len(columns))
-->420raiseValueError(f"Shape of passed values is {passed}, indices imply {implied}")
ValueError: Shapeofpassedvaluesis (192, 1), indicesimply (192, 9)
If I run the third line before the second, X_test_brl_df = disc.transform(pd.DataFrame(X_test[:, :3], columns=feat_names[:3])), I get:
---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
CellIn[16], line21disc=ExtraBasicDiscretizer(feat_names[:3], n_bins=3, strategy='uniform')
---->2X_test_brl_df=disc.transform(pd.DataFrame(X_test[:, :3], columns=feat_names[:3]))
File [/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py:295](http://localhost:8888/usr/lib64/python3.13/site-packages/sklearn/utils/_set_output.py#line=294), in _wrap_method_output.<locals>.wrapped(self, X, *args, **kwargs)293 @wraps(f)
294defwrapped(self, X, *args, **kwargs):
-->295data_to_wrap=f(self, X, *args, **kwargs)
296ifisinstance(data_to_wrap, tuple):
297# only wrap the first output for cross decomposition298return_tuple= (
299_wrap_data_with_container(method, data_to_wrap[0], X, self),
300*data_to_wrap[1:],
301 )
File [/usr/lib/python3.13/site-packages/imodels/discretization/discretizer.py:385](http://localhost:8888/usr/lib/python3.13/site-packages/imodels/discretization/discretizer.py#line=384), in ExtraBasicDiscretizer.transform(self, X)369""" 370 Discretize the data. 371 (...) 381 binned space. All other features remain unchanged. 382 """384# Apply discretizer transform to get ordinally coded DF-->385disc_ordinal_np=self.discretizer_.transform(X[self.dcols])
386disc_ordinal_df=pd.DataFrame(disc_ordinal_np, columns=self.dcols)
387disc_ordinal_df_str=disc_ordinal_df.astype(int).astype(str)
AttributeError: 'ExtraBasicDiscretizer'objecthasnoattribute'discretizer_'
OK, on hindsight I understand why this fails, because we have not trained (no fit before).
Running after the second line the error is similar to the one that we get in the second line.
The text was updated successfully, but these errors were encountered:
First thank you for work. I appreciate it. :-)
I run the tutorial and there is a single example that does not work, the example that uses the
ExtraBasicDiscretizer
:The problem occurs in the second and third lines:
When calling
X_train_brl_df = disc.fit_transform(pd.DataFrame(X_train[:, :3], columns=feat_names[:3]))
I get:If I run the third line before the second,
X_test_brl_df = disc.transform(pd.DataFrame(X_test[:, :3], columns=feat_names[:3]))
, I get:OK, on hindsight I understand why this fails, because we have not trained (no fit before).
Running after the second line the error is similar to the one that we get in the second line.
The text was updated successfully, but these errors were encountered: