I'm hitting an error when fitting privbayes on a dataset containing both numerical fields and categorical text fields. I do not seem to hit the same error for a datset soley comprised of numerical data.
The code:
X = pd.read_csv("...") # Read a csv file containing both numerical fields and categorical text fields.
loader = GenericDataLoader(X, target_column="some_column", sensitive_features=["some_sensitive_columns],)
syn_model = Plugins().get("privbayes")
syn_model.fit(loader)
Here's the traceback:
"""
Traceback (most recent call last):
File "tutorials/privbayes_error.py", line 29, in
syn_model.fit(loader)
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
from contextlib import _GeneratorContextManager
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/core/plugin.py", line 183, in fit
return self._fit(X, *args, **kwargs)
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/generic/plugin_privbayes.py", line 576, in _fit
self.model.fit(X.dataframe())
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
from contextlib import _GeneratorContextManager
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/generic/plugin_privbayes.py", line 109, in fit
self.dag = self._greedy_bayes(data)
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
from contextlib import _GeneratorContextManager
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/generic/plugin_privbayes.py", line 212, in _greedy_bayes
) = self._evaluate_parent_mutual_information(
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
from contextlib import _GeneratorContextManager
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/generic/plugin_privbayes.py", line 430, in _evaluate_parent_mutual_information
score = self.mutual_info_score(data, parents, candidate)
File "pydantic/decorator.py", line 40, in pydantic.decorator.validate_arguments.validate.wrapper_function
from contextlib import _GeneratorContextManager
File "pydantic/decorator.py", line 134, in pydantic.decorator.ValidatedFunction.call
File "pydantic/decorator.py", line 206, in pydantic.decorator.ValidatedFunction.execute
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/synthcity/plugins/generic/plugin_privbayes.py", line 451, in mutual_info_score
target_bins, _ = pd.cut(target, bins=self.n_bins, retbins=True)
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/pandas/core/reshape/tile.py", line 259, in cut
mn, mx = (mi + 0.0 for mi in rng)
File "/home/rob/miniconda3/envs/synthcity/lib/python3.8/site-packages/pandas/core/reshape/tile.py", line 259, in
mn, mx = (mi + 0.0 for mi in rng)
TypeError: can only concatenate str (not "float") to str
"""