Constrain Operator for Inferential Models is a simple tool for pre and pos processing of data to eliminate redunduncy in datasets caused by dependency rules between the variables/columns.
Project description
COIM
Constrain Operator for Inferential Models is a simple tool for pre and pos processing of data to eliminate redunduncy in datasets caused by dependency rules between the variables/columns.
Status
Usage
To start using COIM, import into your code the operator class, which orquestrates the constrains, and define an instance of it.
from COIM import ConstrainOperator
operator=ConstrainOperator()
To add a new constrain, use the add_rule method from ConstrainOperator class.
from COIM import SomeConstrain
contraint_some_rule=SomeConstrain(**parameters)
operator.add_rule(contraint_some_rule)
Each constrain will require their own specific set of parameters, refer to section Available constrains to know each of them. However, all constrains receive the parameter "labels", which is a list with the new names to be used on the encoded columns, and a parameter "precision", which indicates the precision for dataset validation (default to 1e-10).
Then you can encode your dataframe to use the new corrected variables to feed your model.
encoded_df=operator.encode_dataframe(df)
After running your model, you can regenerate the data in the original format, decoding the acquired values and errors.
decoded_df, decoded_errors=operator.decode_dataframe(predicted_df, errors)
That will yield the predictions for the original variables as if they had been fed to the model themselves, but with rather more consistent results.
Also, the errors for these corrected variables will be adjusted according to their mathematical rules.
Available constrains
- "add_scalar":
- $a+K=b$
- base_variable = a
- target_variable = b
- constant = K
- "mul_scalar":
- $a*K=b$
- base_variable = a
- target_variable = b
- constant = K
- "const_sum":
- $\sum W_i\cdot a_i=K$
- variables = $[a_1, a_2, \cdots, a_n]$
- reference_variable = $a_j$
- constant_sum = K
- weights = $[W_1, W_2, \cdots, W_n]$ or $W$ if $W_1=W_2= \cdots= W_n$ or fixed value $W$ if weights do not differ between columns
- "custom_func":
- to be used when none of the above is applicable and you have to develop your own functions to operate the dataframe
- variables : list of the variables to be used
- validate_function: Function to assert if the received dataframe follows the given constrain.
- format_function: Write a string that describes the constrain equation.
- encode_dataframe: Create the new custom columns in the dataframe.
- decode_dataframe: Restore the original columns in the dataframe and calculate the propagated errors.
Future additions
In the foreseeable future, some new constrains will be implemented, those are:
- Variable sum
- Constant and variable products
- Conditionals
Theoretical foundation
All of the worked out mathematics for the developed constrains can be found at the calculations pdf
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file coim-0.0.3.tar.gz.
File metadata
- Download URL: coim-0.0.3.tar.gz
- Upload date:
- Size: 12.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42a84dbc6dfb1a9226a662ca596747a4a4eaa67c12b1bb6391e1bd5dceab48a1
|
|
| MD5 |
1344f2e96cb40cd10fb1c52c06fd7cf4
|
|
| BLAKE2b-256 |
fa37aecb8c9206fb6dc4d57257a0cd1e88b911cd8b32f89e649a1fe60a70261f
|
File details
Details for the file coim-0.0.3-py3-none-any.whl.
File metadata
- Download URL: coim-0.0.3-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcc320fc45427bbfb8b45cef9ea6e12c5bf04e7b192dabf6b8287ef1ce624250
|
|
| MD5 |
6590741ce86255ed0936240fb4ac6ef7
|
|
| BLAKE2b-256 |
4b3a080316bbff5554f9a2a4ad8a0e71c7667b615154d8c2c5762d16a94862f9
|