This release is a pre-release and may not be stable for production use.
Multiobjective-Counterfactuals-for-Design
MCD is a framework to identify tractable "counterfactual" modifications to a design that achieve a set of desired properties. MCD searches for these counterfactuals by iteratively querying a set of property predictors provided by the user. MCD is capable of recommending design modifications that meet multiple, customizable objectives in both the feature and performance spaces.
About The Project
Multiobjective Counterfactuals for Design (MCD) is a framework primarily intended for the generation of design alternatives that meet user-specified performance criteria while remaining within a certain region of the design space. To use MCD, you need a dataset of designs that are reasonably representative of the desired region of the design space, including performance metrics, as well as a model capable of predicting the performance metrics of a given design. MCD is model agnostic - this means that the model need not be a differentiable machine learning model, or, in fact, a machine learning model in the first place. MCD also offers high flexibility in terms of the number and 'type' of performance targets that can be specified. Performance targets can be any combination of:
- 'Continuous Targets': (e.g. I want suggested bike designs to weigh between 2 and 4 kilograms)
- 'Classification Targets': (e.g. I want suggested bike designs to be classified as dirt bikes)
- 'Probability Targets': (e.g. I want each suggested design to have a higher probability of belonging to classes A or B than of belonging to C or D)
Built With
Quick-Start Guide
Installation
- Install MCD with:
pip install decode-mcd - Run:
import random
from pymoo.core.variable import Real
import numpy as np
from decode_mcd import DesignTargets, McdDataset, \
McdProblem, McdGenerator, ContinuousTarget
x = np.random.random(100)
x = x.reshape(100, 1)
y = x * 100
def predict(_x):
return _x * 100 + random.random()
data_package = McdDataset(x=x,
y=y,
x_datatypes=[Real(bounds=(0, 1))])
problem = McdProblem(mcd_dataset=data_package,
prediction_function=lambda design: predict(design),
x_query=x[0].reshape(1, 1),
y_targets=DesignTargets([ContinuousTarget(label=0,
lower_bound=25,
upper_bound=75)]))
generator = McdGenerator(mcd_problem=problem,
pop_size=10,
initialize_from_dataset=False)
generator.generate(n_generations=10)
counterfactuals = generator.sample_with_dtai(num_samples=10, proximity_weight=1,
manifold_proximity_weight=1, sparsity_weight=1,
diversity_weight=50)
print(counterfactuals)
Roadmap
- We are currently working on support for gradient-based optimization
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE for more information.
Citation
If you use MCD for research, please consider citing our paper:
Regenwetter, L., Abu Obaideh, Y., and Ahmed, F. (July 16, 2024). "MCD: A Model-Agnostic Counterfactual Search Method For Multi-modal Design Modifications." ASME. J. Mech. Des. doi: https://doi.org/10.1115/1.4065998
Metadata
Release files for decode-mcd 1.0.0rc1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| decode_mcd-1.0.0rc1.tar.gz | 35.6 kB | With provenance | Details for decode_mcd-1.0.0rc1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| decode_mcd-1.0.0rc1-py3-none-any.whl | Python 3 | none | any | Details for decode_mcd-1.0.0rc1-py3-none-any.whl |
Total release size: 61.9 kB
Release files / decode_mcd-1.0.0rc1.tar.gz
| Download URL | decode_mcd-1.0.0rc1.tar.gz |
|---|---|
| Size | 35.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a4e1c8400d94887fb969b76918decba941e9e34918a6ee862874fc56db3d45c
|
|
BLAKE2b-256 checksum How to use checksums |
d345a0ceea9335a68e1545c937ac5f589ddbe7c37ae80798540d989136758a75
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.
Transparency logRelease files / decode_mcd-1.0.0rc1-py3-none-any.whl
| Download URL | decode_mcd-1.0.0rc1-py3-none-any.whl |
|---|---|
| Size | 26.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1b9ae8a53879df04411dfa0f39940a6f9458b33d855ee459f9086ecdc2565517
|
|
BLAKE2b-256 checksum How to use checksums |
8e391b9c31d8b8650b022cb39f99109e37d32521f9014fd01e27083ae9ec3ac6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.
Transparency logSecurity for decode-mcd 1.0.0rc1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for decode_mcd-1.0.0rc1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 25, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.