New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use inequality constraints with datetime? #1115
Comments
Hi @montasIET, it will be helpful if you could provide more information to us to help us replicate the issue.
|
@npatki sure!
|
Hi @montasIET, thanks for your reply and details! I might know what the issue is. Right now, you cannot provide both metadata and constraints in the model. (We’re working on adding better documentation & usage for this feature.) For now, you can directly add the constraint inside the metadata and then you only need to supply the metadata. Below is an example of how to do this, {
"fields": {
...
},
"constraints": [{
"constraint": "sdv.constraints.tabular.Inequality",
"low_column_name": "DATA_INIZIO_ATTIVITA",
"high_column_name": "DATA_FINE_ATTIVITA"
}]
} Let me know if that helps! |
Hi @npatki, thanks for answering! |
Hi @montasIET, we call the However you can at any point create your own custom constraint. That is: You can write code to implement your own logic for what is allowed and how to achieve it in the synthetic data. This User Guide should help you get started. |
Hi @npatki, yes I know, but I mean that if I create a custom constraint, how can I insert it into metadata since it has not a predefined path? but for a custom contraint, how can I do that? |
@montasIET oh got it. To use a custom constraint inside the metadata, you'd need to write the logic in a separate file. For example, you can write in a file called from sdv.constraints import create_custom_constraint
<your logic>
MyCustomConstraint = create_custom_constraint(<your parameters>) Then you should be able to reference the file and class in the metadata just like a predefined constraint: {
"fields": {
...
},
"constraints": [{
"constraint": "my_file.MyCustomConstraint",
"custom_parameter": <custom_value>,
"custom_parameter": <custom_value>
}]
} If you have any questions or feedback about this, please feel free to file a new issue. Since this original issue is about the |
@npatki sorry for reopening the thread, but I followed each step and got into this error: (sorry I cannot share full data but it shows me values instead of ....) |
@montasIET can you start a new issue for this? It would be good to keep the current issue focused on the initial topic (using |
Environment details
If you are already running SDV, please indicate the following details about the environment in
which you are running it:
Problem description
I'm using an inequality constraint with two columns of type 'datetime64[ns]' and I want that date1 is before date2, but I get the error:
Traceback (most recent call last): File "minisogei_generation.py", line 41, in <module> model = GaussianCopula(constraints = c, table_metadata=metadata.get_table_meta('minisogei'), File "C:\Users\luimon\miniconda3\envs\minisogei\lib\site-packages\sdv\tabular\copulas.py", line 171, in __init__ super().__init__( File "C:\Users\luimon\miniconda3\envs\minisogei\lib\site-packages\sdv\tabular\base.py", line 110, in __init__ 'If table_metadata is given {} must be None'.format(arg.__name__)) AttributeError: 'list' object has no attribute '__name__'
How can I fix? Thanks
The text was updated successfully, but these errors were encountered: