Active Subspaces is a method for discovering low-dimensional subspaces of input parameters that accurately characterize the output of high-dimensional models. This dimension reduction can make otherwise infeasible parameter studies possible. This library contains python utilities for constructing and exploiting active subspaces.
WARNING: Development is very active right now, so the interfaces are far from stable. It should settle down soon. Feel free to follow development.
- numpy
- scipy, >= 0.15.0
- matplotlib
- Gurobi is an optional dependency of the active subspaces library; if you don't have it, the exact same functionality will be accomplished using SciPy.
To install the active subspaces package, open the terminal/command line and clone the repository with the command
git clone https://github.com/paulcon/active_subspaces.git
Navigate into the active_subspaces
folder (where the setup.py
file is located) and run the command
python setup.py install
You should now be able to import the active subspaces library in Python scripts and interpreters with the command import active_subspaces
.
This method was tested on Windows 7 Professional 64-bit and Ubuntu 14.04 LTS
64-bit with the Enthought Python distrubution (Python 2.7.11, NumPy 1.10.4, SciPy 0.17.0, and matplotlib 1.5.1), available with their Canopy development environment.
If you wish to use Gurobi, you will need to install it separately by following the instructions contained in their quick-start
guides for Windows or Linux. To test your installation of Gurobi, start a python
interpreter and execute the command import gurobipy
. If there is no import exception, the active subspaces library will be able to use Gurobi.
For detailed examples of usage and results, see the Jupyter notebooks contained in the [active subspaces website]
(http://activesubspaces.org/applications/), the tutorials/test_functions
and tutorials/AS_tutorial
folders in this repo, and the as-data-sets repo.
The core class used in this library is the Subspaces class contained in the subspaces.py
file. An instance of this class can compute
the active subspace with a variety of methods that take either an array of gradients or input/output pairs. It contains the estimated
eigenvalues (and bootstrap ranges), subspace errors (and bootstrap ranges), eigenvectors, and an array of the eigenvectors defining the
active subspace. The utils/plotters.py
file contains functions to make plots of these quantities and summary plots that show model
output against the first 1 or 2 active variables. The utils/response_surfaces.py
file contains classes for polynomial and radial-basis
approximations that can be trained with input/output pairs. Both classes can predict the value and gradient at input points and have an
Rsqr value that measures goodness-of-fit. The integrals.py
and optimizers.py
files contain functions for integrating and optimizing
functions of the active variables, and rely on classes from the domains.py
file.
Documentation can be found on ReadTheDocs.
We are using Travis CI for continusous intergration testing. You can check out the current status here.
To run tests locally:
> python test.py
We are following the guidelines here for packaging and distributing our code. Our steps:
pip install twine
- Bump version in
setup.py
- From root directory,
python setup.py sdist
twine upload dist/active_subspaces-<version>.tar.gz
- This requires pypi username and password
We are using Gurobi; you can see the qp_solver.py that solves the problems I need. To get Gurobi's Python interface working with Enthought/Canopy, take a look at this thread: https://groups.google.com/forum/#!searchin/gurobi/canopy/gurobi/ArCkf4a40uU/R9U1XFuMJEkJ
Right now I'm using Enthought's Python Distribution and Canopy for development. You'll need numpy and scipy for these tools.
If you have contributions, questions, or feedback, use the Github repo or contact Paul Constantine at Colorado School of Mines.