Skip to content

Commit 49e4280

Browse files
authored
Merge pull request #76 from ilabcode/dev
Shared Parameters feature
2 parents ba60ee5 + 0c6f652 commit 49e4280

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2530
-572
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# GitHub action to automerge compathelper PRs. Only merges if tests pass due to branch protections in the repo.
2+
3+
name: automerge-CompatHelper-prs
4+
5+
on: pull_request
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
dependabot-automerge:
13+
runs-on: ubuntu-latest
14+
if: ${{ github.actor == 'CompatHelper Julia'}}
15+
16+
steps:
17+
# Checkout action is required for token to persist
18+
- name: Enable auto-merge for CompatHelper PRs
19+
run: gh pr merge --auto --merge "$PR_URL" # Use Github CLI to merge automatically the PR
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
24+
- name: Auto approve CompatHelper PRs
25+
if: github.actor == 'CompatHelper Julia'
26+
uses: hmarr/auto-approve-action@v3
27+
with:
28+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/automerge_dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ jobs:
2323

2424
- name: Auto approve dependabot PRs
2525
if: github.actor == 'dependabot[bot]'
26-
uses: hmarr/auto-approve-action@v2
26+
uses: hmarr/auto-approve-action@v3
2727
with:
2828
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*.jl.mem
44
/docs/build/
55
.DS_Store
6-
testing_script.jl
6+
testing_script*.jl
77
settings.json
88
Manifest.toml
99
docs/Manifest.toml
10-
test/Manifest.toml
10+
test/Manifest.toml
11+
/docs/src/generated_markdowns/*.md

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HierarchicalGaussianFiltering"
22
uuid = "63d42c3e-681c-42be-892f-a47f35336a79"
3-
authors = ["Peter Thestrup Waade [email protected]", "Jacopo Comoglio [email protected]", "Christoph Mathys [email protected]\n and contributors"]
4-
version = "0.3.0"
3+
authors = ["Peter Thestrup Waade [email protected]", "Anna Hedvig Møller [email protected]", "Jacopo Comoglio [email protected]", "Christoph Mathys [email protected]\n and contributors"]
4+
version = "0.3.1"
55

66
[deps]
77
ActionModels = "320cf53b-cc3b-4b34-9a10-0ecb113566a3"

README.md

Lines changed: 117 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,122 @@
11
# HGF
2-
32
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://ilabcode.github.io/HierarchicalGaussianFiltering.jl)
43
[![Build Status](https://github.com/ilabcode/HierarchicalGaussianFiltering.jl/actions/workflows/CI_full.yml/badge.svg?branch=main)](https://github.com/ilabcode/HierarchicalGaussianFiltering.jl/actions/workflows/CI_full.yml?query=branch%3Amain)
54
[![Coverage](https://codecov.io/gh/ilabcode/HierarchicalGaussianFiltering.jl/branch/main/graph/badge.svg?token=NVFiiPydFA)](https://codecov.io/gh/ilabcode/HierarchicalGaussianFiltering.jl)
65
[![License: GNU](https://img.shields.io/badge/License-GNU-yellow)](<https://www.gnu.org/licenses/>)
6+
7+
8+
# Welcome to The Hierarchical Gaussian Filtering Package!
9+
10+
Hierarchical Gaussian Filtering (HGF) is a novel and adaptive package for doing cognitive and behavioral modelling. With the HGF you can fit time series data fit participant-level individual parameters, measure group differences based on model-specific parameters or use the model for any time series with underlying change in uncertainty.
11+
12+
The HGF consists of a network of probabilistic nodes hierarchically structured. The hierarchy is determined by the coupling between nodes. A node (child node) in the network can inheret either its value or volatility sufficient statistics from a node higher in the hierarchy (a parent node).
13+
14+
The presentation of a new observation at the lower level of the hierarchy (i.e. the input node) trigger a recursuve update of the nodes belief throught the bottom-up propagation of precision-weigthed prediction error.
15+
16+
The HGF will be explained in more detail in the theory section of the documentation
17+
18+
It is also recommended to check out the ActionModels.jl pacakge for stronger intuition behind the use of agents and action models.
19+
20+
## Getting started
21+
22+
The last official release can be downloaded from Julia with
23+
24+
````@example index
25+
"] add Luxor"
26+
````
27+
28+
We provide a script for getting started with commonly used functions and use cases
29+
30+
Load packages
31+
32+
````@example index
33+
using HierarchicalGaussianFiltering
34+
using ActionModels
35+
````
36+
37+
### Get premade agent
38+
39+
````@example index
40+
premade_agent("help")
41+
````
42+
43+
### Create agent
44+
45+
````@example index
46+
agent = premade_agent("hgf_binary_softmax_action")
47+
````
48+
49+
### Get states and parameters
50+
51+
````@example index
52+
get_states(agent)
53+
````
54+
55+
![Image1](docs/src/images/readme/get_states.png)
56+
57+
````@example index
58+
get_parameters(agent)
59+
````
60+
61+
![Image1](docs/src/images/readme/get_parameters.png)
62+
63+
Set a new parameter for initial precision of x2 and define some inputs
64+
65+
````@example index
66+
set_parameters!(agent, ("x2", "initial_precision"), 0.9)
67+
inputs = [1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0];
68+
nothing #hide
69+
````
70+
71+
### Give inputs to the agent
72+
73+
````@example index
74+
actions = give_inputs!(agent, inputs)
75+
````
76+
![Image1](docs/src/images/readme/actions.png)
77+
### Plot state trajectories of input and prediction
78+
79+
````@example index
80+
using StatsPlots
81+
using Plots
82+
plot_trajectory(agent, ("u", "input_value"))
83+
plot_trajectory!(agent, ("x1", "prediction"))
84+
````
85+
![Image1](docs/src/images/readme/plot_trajectory.png)
86+
87+
Plot state trajectory of input value, action and prediction of x1
88+
89+
````@example index
90+
plot_trajectory(agent, ("u", "input_value"))
91+
plot_trajectory!(agent, "action")
92+
plot_trajectory!(agent, ("x1", "prediction"))
93+
````
94+
![Image1](docs/src/images/readme/plot_trajectory_2.png)
95+
### Fitting parameters
96+
97+
````@example index
98+
using Distributions
99+
prior = Dict(("x2", "evolution_rate") => Normal(1, 0.5))
100+
101+
model = fit_model(agent, prior, inputs, actions, n_iterations = 20)
102+
````
103+
![Image1](docs/src/images/readme/fit_model.png)
104+
### Plot chains
105+
106+
````@example index
107+
plot(model)
108+
````
109+
![Image1](docs/src/images/readme/chains.png)
110+
### Plot prior angainst posterior
111+
112+
````@example index
113+
plot_parameter_distribution(model, prior)
114+
````
115+
![Image1](docs/src/images/readme/prior_posterior.png)
116+
### Get posterior
117+
118+
````@example index
119+
get_posteriors(model)
120+
````
121+
122+
---

docs/make.jl

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,42 @@ using HierarchicalGaussianFiltering
22
using Documenter
33
using Literate
44

5-
# #Remove old tutorial markdown files
6-
# for filename in readdir("src/tutorials")
7-
# rm("src/tutorials/" * filename)
8-
# end
9-
# #Generate new tutorial markdown files
10-
# for filename in readdir("tutorials")
11-
# if endswith(filename, ".jl")
12-
# Literate.markdown("tutorials/" * filename, "src/tutorials", documenter = true)
13-
# end
14-
# end
5+
#Remove old tutorial markdown files
6+
for filename in readdir("docs/src/generated_markdowns")
7+
rm("docs/src/generated_markdowns/" * filename)
8+
end
9+
rm("docs/src/index.md")
10+
#Generate new markdown files from the documentation source files
11+
for filename in readdir("docs/src/Julia_src_files")
12+
if endswith(filename, ".jl")
13+
14+
#Place the index file in another folder than the rest of the documentation
15+
if startswith(filename, "index")
16+
Literate.markdown(
17+
"docs/src/Julia_src_files/" * filename,
18+
"docs/src",
19+
documenter = true,
20+
)
21+
else
22+
Literate.markdown(
23+
"docs/src/Julia_src_files/" * filename,
24+
"docs/src/generated_markdowns",
25+
documenter = true,
26+
)
27+
end
28+
end
29+
end
30+
31+
#Generate new tutorial markdown files from the tutorials
32+
for filename in readdir("docs/src/tutorials")
33+
if endswith(filename, ".jl")
34+
Literate.markdown(
35+
"docs/src/tutorials/" * filename,
36+
"docs/src/generated_markdowns",
37+
documenter = true,
38+
)
39+
end
40+
end
1541

1642
#Set documenter metadata
1743
DocMeta.setdocmeta!(
@@ -33,10 +59,32 @@ makedocs(;
3359
canonical = "https://ilabcode.github.io/HierarchicalGaussianFiltering.jl",
3460
assets = String[],
3561
),
36-
pages = ["Home" => "index.md"],
62+
pages = [
63+
"Introduction to Hierarchical Gaussian Filtering" => "./index.md",
64+
"Theory" => [
65+
"./theory/genmodel.md",
66+
"./theory/node.md",
67+
"./theory/vape.md",
68+
"./theory/vope.md",
69+
],
70+
"Using the package" => [
71+
"The HGF Nodes" => "./generated_markdowns/the_HGF_nodes.md",
72+
"Building an HGF" => "./generated_markdowns/building_an_HGF.md",
73+
"Updating the HGF" => "./generated_markdowns/updating_the_HGF.md",
74+
"List Of Premade Agent Models" => "./generated_markdowns/premade_models.md",
75+
"List Of Premade HGF's" => "./generated_markdowns/premade_HGF.md",
76+
"Fitting an HGF-agent model to data" => "./generated_markdowns/fitting_hgf_models.md",
77+
"Utility Functions" => "./generated_markdowns/utility_functions.md",
78+
],
79+
"Tutorials" => [
80+
"classic binary" => "./generated_markdowns/classic_binary.md",
81+
"classic continouous" => "./generated_markdowns/classic_usdchf.md",
82+
],
83+
"All Functions" => "./generated_markdowns/all_functions.md",
84+
],
3785
)
38-
3986
deploydocs(;
4087
repo = "github.com/ilabcode/HierarchicalGaussianFiltering.jl",
41-
devbranch = "dev",
88+
devbranch = "main",
89+
push_preview = false,
4290
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# # Overview of all functions in the Hierarchical Gaussian Filtering package
2+
3+
# ```@autodocs
4+
# Modules = [HierarchicalGaussianFiltering]
5+
# ```

0 commit comments

Comments
 (0)