Skip to main content

MCD generates counterfactuals that meet multiple, customizable objectives in both the feature and performance spaces.

Project description

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.

Overview

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

  • Python
  • Pymoo
  • Pandas
  • Numpy

Quick-Start Guide

Installation

  1. Install MCD with: pip install decode-mcd
  2. 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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

decode_mcd-1.0.0rc1.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

decode_mcd-1.0.0rc1-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file decode_mcd-1.0.0rc1.tar.gz.

File metadata

  • Download URL: decode_mcd-1.0.0rc1.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for decode_mcd-1.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 6a4e1c8400d94887fb969b76918decba941e9e34918a6ee862874fc56db3d45c
MD5 fd8588d944e253822eeecf01ccaf6764
BLAKE2b-256 d345a0ceea9335a68e1545c937ac5f589ddbe7c37ae80798540d989136758a75

See more details on using hashes here.

Provenance

The following attestation bundles were made for decode_mcd-1.0.0rc1.tar.gz:

Publisher: build.yaml on Lyleregenwetter/Multiobjective-Counterfactuals-for-Design

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file decode_mcd-1.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: decode_mcd-1.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for decode_mcd-1.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b9ae8a53879df04411dfa0f39940a6f9458b33d855ee459f9086ecdc2565517
MD5 c099b5c93c88297fb65c6d37706a8f7a
BLAKE2b-256 8e391b9c31d8b8650b022cb39f99109e37d32521f9014fd01e27083ae9ec3ac6

See more details on using hashes here.

Provenance

The following attestation bundles were made for decode_mcd-1.0.0rc1-py3-none-any.whl:

Publisher: build.yaml on Lyleregenwetter/Multiobjective-Counterfactuals-for-Design

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page