Skip to main content

Common Framework for Inference

Project description

CoFI (Common Framework for Inference)

PyPI version Conda Version Documentation Status codecov Slack

Related repositories by InLab:

Introduction

CoFI (Common Framework for Inference) is an open source initiative for interfacing between generic inference algorithms and specific geoscience problems.

With a mission to bridge the gap between the domain expertise and the inference expertise, CoFI provides an interface across a wide range of inference algorithms from different sources, underpinned by a rich set of domain relevant examples.

Read the documentation, and let us know your feedback or any issues!

Installation

From PyPI:

$ pip install cofi

Or alternatively, from conda-forge:

$ conda install -c conda-forge cofi

Check CoFI documentation - installation page for details on dependencies and setting up with virtual environments.

Basic Usage

graph TD;
    base_problem_details(inv_problem = BaseProblem#40;#41;\ninv_problem.set_objective#40;DEFINE ME#41;\ninv_problem.set_jacobian#40;DEFINE ME#41;\ninv_problem.set_initial_model#40;DEFINE ME#41;):::cls_code_block
    inversion_options_details(inv_options = InversionOptions#40;#41;\ninv_options.set_tool#40;#34;scipy.linalg.lstsq#34;#41;):::cls_code_block
    inversion_details(inv=Inversion#40;inv_problem, inv_options#41;\nresult = inv.run#40;#41;):::cls_code_block

    subgraph base_problem ["Base Problem"]
        base_problem_details
    end

    subgraph inversion_options ["Inversion Options"]
        inversion_options_details
    end

    subgraph inversion ["Inversion"]
        inversion_details
    end

    base_problem --> inversion;
    inversion_options --> inversion;

    classDef cls_base_problem fill: oldlace, stroke-width: 0, color: black;
    classDef cls_inversion_options fill: oldlace, stroke-width: 0, color: black;
    classDef cls_inversion fill: lavender, stroke-width: 0, color: black;
    classDef cls_code_block fill: lightgrey, stroke-width: 0, text-align: left, color: black;

    class base_problem cls_base_problem;
    class inversion_options cls_inversion_options;
    class inversion cls_inversion;

CoFI API has flexible ways of defining an inversion problem. For instance:

import cofi

inv_problem = cofi.BaseProblem()
inv_problem.set_objective(my_objective_func)
inv_problem.set_initial_model(my_starting_point)

Once a problem is defined, cofi can tell you what inference tools you can use based on what level of information you've provided:

inv_problem.suggest_tools()   # a tree will be printed

Run an inversion with these lines:

inv_options = cofi.InversionOptions()
inv_options.set_tool("torch.optim")
inv_options.set_params(options={"num_iterations": 50, "algorithm": "Adam"})

inv = cofi.Inversion(inv_problem, inv_options)
result = inv.run()
print(result.success)
print(result.model)

And now an inversion is completed! Check out our example gallery and tutorial pages for more real-world or advanced use cases.

Contributing

Interested in contributing? Please check out our contributor's guide.

Licence

This project is distributed under a 2-clause BSD licence. A copy of this licence is provided with distributions of the software.

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

cofi-0.2.12.tar.gz (76.0 kB view details)

Uploaded Source

Built Distribution

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

cofi-0.2.12-py3-none-any.whl (84.9 kB view details)

Uploaded Python 3

File details

Details for the file cofi-0.2.12.tar.gz.

File metadata

  • Download URL: cofi-0.2.12.tar.gz
  • Upload date:
  • Size: 76.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for cofi-0.2.12.tar.gz
Algorithm Hash digest
SHA256 f9f73f1d75773e6ac8a1666d17e1d2c9ab48149a6ef1b03fb4a678791e06b488
MD5 d477a20a29fe385a5fdafdacd854de23
BLAKE2b-256 607f07aa05e73b037e72a5eb886d45c43b330fbc99aabe079fd2ebb35d5aa393

See more details on using hashes here.

File details

Details for the file cofi-0.2.12-py3-none-any.whl.

File metadata

  • Download URL: cofi-0.2.12-py3-none-any.whl
  • Upload date:
  • Size: 84.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.20

File hashes

Hashes for cofi-0.2.12-py3-none-any.whl
Algorithm Hash digest
SHA256 7e1e13ee09d629cfbe0f828a9442a6335f083b6cd95e4dc4e45bcb520d234213
MD5 5d7f96989f6914e2e1e6d1ae7fe12adc
BLAKE2b-256 6adf49872d7f78d0352f301a072a0500921235bf1a31122bd726e277201a7987

See more details on using hashes here.

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