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
Please indicate the following details about the environment in which you found the bug:
SDV version: 0.9.1
Python version: 3.8
Operating System: OSX
Error Description
I'm trying to define a greaterThan constraint with CopulaGAN using the handling_strategy="transform" between dates. This causes the following error:
"TypeError: ufunc 'exp' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"
Steps to reproduce
The error can be reproduced with the following code:
from sdv.tabular import CopulaGAN
from sdv.constraints import GreaterThan
from sdv.demo import load_tabular_demo
data = load_tabular_demo('student_placements')
data.head()
date_constraint = GreaterThan(
low='start_date',
high='end_date',
handling_strategy='transform'
)
constraints = [
date_constraint,
]
model = CopulaGAN(epochs=50, constraints=constraints)
model.fit(data)
model.sample(100)
Reason for error
The problem occurs because np.exp() is computed on a DateType64[ns] as the column is reversed_transformed:
def reverse_transform(self, table_data):
"""Reverse transform the table data.
The transformation is reversed by computing an exponential of the given
value, converting it to the original dtype, subtracting 1 and finally
clipping the value to 0 on the low end to ensure the value is positive.
Finally, the obtained value is added to the ``low`` column to get the final
``high`` value.
Args:
table_data (pandas.DataFrame):
Table data.
Returns:
pandas.DataFrame:
Transformed data.
"""
table_data = table_data.copy()
diff = (np.exp(table_data[self._high]).round() - 1).clip(0)
low_column = table_data[self._low]
if pd.api.types.is_datetime64_ns_dtype(low_column):
diff = pd.to_timedelta(diff)
table_data[self._high] = (low_column + diff).astype(self._dtype)
return table_data
The text was updated successfully, but these errors were encountered:
Environment Details
Please indicate the following details about the environment in which you found the bug:
Error Description
I'm trying to define a greaterThan constraint with CopulaGAN using the handling_strategy="transform" between dates. This causes the following error:
"TypeError: ufunc 'exp' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''"
Steps to reproduce
The error can be reproduced with the following code:
Reason for error
The problem occurs because np.exp() is computed on a DateType64[ns] as the column is reversed_transformed:
The text was updated successfully, but these errors were encountered: