Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/bump_n_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will bump the version of the package and publish it to PyPI

name: Bump and publish

on:
workflow_dispatch:
# push:
# branches:
# - master

jobs:
bump_version:
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
strategy:
matrix:
python-version: ["3.11"]
poetry-version: ["1.5.1"]
runs-on: "ubuntu-latest"
name: "Bump version and create changelog with commitizen"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: "${{ secrets.GITHUB_TOKEN }}"
- name: Create bump and changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
- name: Release
uses: softprops/action-gh-release@v1
with:
body_path: "body.md"
tag_name: v${{ env.REVISION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# deploy step
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Python Poetry Action
uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}
- name: Publish to PyPI
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_API_KEY }}"
poetry publish --build



8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ jobs:
- name: Test pycmtensor import
run: |
python -c "import pycmtensor as cmt; print(cmt.__version__)"
cat ~/.aesararc
cat ~/.pytensorrc

- name: Show Aesara config
- name: Show pytensor config
run: |
python -c "import aesara; print(aesara.config.blas__ldflags)"
python -c "import aesara; print(aesara.config.gcc__cxxflags)"
python -c "import pytensor; print(pytensor.config.blas__ldflags)"
python -c "import pytensor; print(pytensor.config.gcc__cxxflags)"

- name: Main test
run: pytest
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ While these advanced Python deep learning libraries can be used to evaluate choi

### What can PyCMTensor do?

PyCMTensor can be used for specifying, estimating, and conducting statistical tests on hybrid discrete choice models. It uses optimized tensor operations through [Aesara](https://aesara.readthedocs.io/en/latest/).
PyCMTensor can be used for specifying, estimating, and conducting statistical tests on hybrid discrete choice models. It uses optimized tensor operations through [pytensor](https://pytensor.readthedocs.io/en/latest/).

The library is built for estimating hybrid neural networks, Logit models, and Mixed Logit models. The models in PyCMTensor are built on computational graphs and are estimated using backpropagation algorithms.

## Project goals

PyCMTensor aims to combine the interpretability of choice modelling syntaxes and expressions with the computational efficiency of Aesara tensor libraries. It specializes in defining 'hybrid' utility expressions and simplifies the process of integrating a deep neural network into choice models such as TasteNet or ResLogit. Unlike other deep learning libraries, PyCMTensor focuses on econometric modelling and statistical testing over purely predictive or classification models.
PyCMTensor aims to combine the interpretability of choice modelling syntaxes and expressions with the computational efficiency of pytensor tensor libraries. It specializes in defining 'hybrid' utility expressions and simplifies the process of integrating a deep neural network into choice models such as TasteNet or ResLogit. Unlike other deep learning libraries, PyCMTensor focuses on econometric modelling and statistical testing over purely predictive or classification models.

The objectives of this project include:

Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ The `Beta(name=, value=, lb=, ub=, status=)` object takes the following argument
```

!!! info
`pycmtensor.expressions.Beta` follows the same syntax as in [Biogeme]() `biogeme.expressions.Beta` for familiarity sake. However, `pycmtensor.expressions.Beta` uses `aesara.tensor` variables to define the mathematical ops. Currently they are not interchangable.
`pycmtensor.expressions.Beta` follows the same syntax as in [Biogeme]() `biogeme.expressions.Beta` for familiarity sake. However, `pycmtensor.expressions.Beta` uses `pytensor.tensor` variables to define the mathematical ops. Currently they are not interchangable.


## Specifying utility equations
Expand Down
12 changes: 6 additions & 6 deletions docs/user_guide/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ pycmtensor.config.add('seed', 100)

Default: `True`

## Aesara config
## pytensor config

PyCMTensor uses the `aesara` library, which has its own set of configurations. We use the following by default:
PyCMTensor uses the `pytensor` library, which has its own set of configurations. We use the following by default:

`aesara.config.on_unused_input = "ignore"`
`pytensor.config.on_unused_input = "ignore"`

`aesara.config.mode = "Mode"`
`pytensor.config.mode = "Mode"`

`aesara.config.allow_gc = False`
`pytensor.config.allow_gc = False`

Refer to https://aesara.readthedocs.io/en/latest/config.html for other options.
Refer to https://pytensor.readthedocs.io/en/latest/config.html for other options.
8 changes: 4 additions & 4 deletions docs/user_guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ The entire model is build as a computational graph with nodes representing inter
The graph is then manipulated internally and optimized during compilation.
When an input is provided to certain tensors, the graph computes the values for other symbols in the graph.

The core API library, Aesara, gives us a set of tools that takes the defined symbolic tensors, constructs a computational graph and optimizes the mathematical operations around it.
The core API library, pytensor, gives us a set of tools that takes the defined symbolic tensors, constructs a computational graph and optimizes the mathematical operations around it.

As a developer, you define or extend a new model by creating new tensor variable objects from primitive tensors. For instance, take a basic linear equation, $y = bx +c$. The variables $y$, $x$, and $c$ are symbolic tensors making up a computational graph, and $b$ is a shared variable consisting of a mutable defined value. When we call `train(y)`, an Aesara function is executed on the equation and an update value is passed to $b$.
As a developer, you define or extend a new model by creating new tensor variable objects from primitive tensors. For instance, take a basic linear equation, $y = bx +c$. The variables $y$, $x$, and $c$ are symbolic tensors making up a computational graph, and $b$ is a shared variable consisting of a mutable defined value. When we call `train(y)`, an pytensor function is executed on the equation and an update value is passed to $b$.

A PyCMTensor model is composed of

Expand All @@ -28,7 +28,7 @@ This symbolic approach does add complexity, however, the tradeoffs are that a. m

### `Beta`

A `Beta` variable is the main data object when estimate a PyCMTensor model. `Beta` inherits the `TensorExpression` class which adds Aesara tensor operations to the data object. A `Beta` is defined as such:
A `Beta` variable is the main data object when estimate a PyCMTensor model. `Beta` inherits the `TensorExpression` class which adds pytensor tensor operations to the data object. A `Beta` is defined as such:

```python
Beta(name, value, lb, ub, status)
Expand All @@ -40,7 +40,7 @@ In mathematical operations, for instance:

```python
from pycmtensor.expressions import Beta
import aesara.tensor as aet
import pytensor.tensor as aet
import numpy as np
beta_cost = Beta("beta_cost", 2.)
train_cost = aet.vector("train_cost")
Expand Down
15 changes: 7 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
name: pycmtensor-dev
name: pytensor-dev
channels:
- conda-forge
- defaults
dependencies:
# core dependencies
- python>=3.9,<3.13
- aesara=2.9.3
- numpy<1.26.0
- scipy<1.12.0
- pandas<2.1.0
- pytensor<2.27.0
- scipy<1.15.0
- pandas<2.3.0
- seaborn<0.14.0
- scikit-learn<1.6.0

Expand All @@ -17,10 +16,10 @@ dependencies:


# remove any old environment
# conda env remove -n pycmtensor-dev
# conda env remove -n pytensor-dev -y

# install the environment
# conda env create -f environment.yml && conda activate pycmtensor-dev
# navigate to this directory and install the environment
# conda env create -n pytensor-dev && conda activate pytensor-dev

# development
# conda install git ipykernel poetry
Expand Down
Loading