Skip to content
Merged
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
28 changes: 23 additions & 5 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: ['1.10', '1.11']
os: [ubuntu-latest, windows-latest, macOS-latest]
julia-version: ['1']
os: ['ubuntu-latest']
steps:
- uses: actions/checkout@v4

Expand All @@ -30,6 +30,22 @@ jobs:

- uses: julia-actions/cache@v2

# 1. Install uv and enable caching for faster runs
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

# 2. Install your target Python version
- name: Set up Python
run: uv python install 3.12

# 3. Auto-setup the virtual environment for the tests
- name: Create Python virtual environment
run: |
uv venv test/test_python/.venv
uv pip install --python=test/test_python/.venv numpy pandas doubleml xgboost scikit-learn

- name: Install dependencies
run: julia --project=. -e 'using Pkg; Pkg.instantiate()'

Expand All @@ -43,7 +59,7 @@ jobs:

- uses: julia-actions/setup-julia@v2
with:
version: '1.10'
version: '1'

- uses: julia-actions/cache@v2

Expand All @@ -64,12 +80,14 @@ jobs:

- uses: julia-actions/setup-julia@v2
with:
version: '1.10'
version: '1'

- uses: julia-actions/cache@v2

- name: Install dependencies
run: julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
run: |
julia --project=docs -e 'using Pkg; Pkg.develop(Pkg.PackageSpec(path=pwd())); Pkg.instantiate()'
julia --project=examples -e 'using Pkg; Pkg.instantiate()' # Add this line

- name: Build and Deploy
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.planning
*/.ignore
.theme
/bin
22 changes: 11 additions & 11 deletions Manifest.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"

[compat]
CategoricalArrays = "1.0.2"
MLJBase = "1.12.1"
CategoricalArrays = "1.0"
MLJBase = "1.12"
PrettyTables = "3.2.3"
Roots = "2.2.12"
ScientificTypes = "3.2.0"
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,8 @@ There are many features and models still not yet implemented in this package. Th

Currently, a variety of tests against the Python package are implemented to ensure similar functionality of the DoubleMLPLR, DoubleMLIRM, and DoubleMLLPLR models.

In early benchmarks, the Julia implementation performs well
In early benchmarks, the Julia implementation performs well and up to 10x faster than the Python package (see the [benchmark](test/test_python/benchmarks/benchmarks.md))

## Other packages

Other similar Julia packages include [CausalELM](https://github.com/dscolby/CausalELM.jl), which offers a very lightweight approach to causal machine learning, where all the machine learners take the form of extreme learning machines. In comparison, this package aims to offer more similar features to those of the DoubleML Python package and allow flexibility of the model choice.

## Index

```@index
Pages = ["api.md"]
```
26 changes: 13 additions & 13 deletions docs/Manifest.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DocumenterTools = "35a29f4d-8980-5a13-9543-d66fff28ecb8"
DoubleML = "77251493-8087-46d5-be33-49d84ce818f6"
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
MLJ = "add582a8-e3ab-11e8-2d5e-e98b27df1bc7"
Pluto = "c3e4b0f8-55cb-11ea-2926-15256bba5781"
PlutoStaticHTML = "359b1769-a58e-495b-9770-312e911026ad"
StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c"
Expand Down
17 changes: 9 additions & 8 deletions docs/src/notebooks/irm_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
<!--
# This information is used for caching.
[PlutoStaticHTML.State]
input_sha = "7bd830a3473d17a6cf11e7e59a67a38ef8bc07443c8e514b1512939325a84087"
input_sha = "28053b176c99ae50ce44d8973ba9ab3301e74bdddd0bfdde0d45df0bc5a2af05"
julia_version = "1.12.4"
-->
<pre class='language-julia'><code class='language-julia'>begin
using Pkg
Pkg.activate("..")
Pkg.instantiate()
import Pkg; Pkg.develop(path=joinpath(@__DIR__, "../.."))
end</code></pre>


<pre class='language-julia'><code class='language-julia'>Pkg.activate(joinpath(@__DIR__, "../../examples"))</code></pre>


<pre class='language-julia'><code class='language-julia'>begin
using DoubleML
using StableRNGs
Expand Down Expand Up @@ -108,7 +109,7 @@ end</code></pre>
<pre class="code-output documenter-example-output" id="var-dml_irm_simple">────────────────────────────────────────────────────────────────────
Estimate Std. Error z value Pr(&gt;|z|) Lower 95.0% Upper 95.0%
────────────────────────────────────────────────────────────────────
d 0.67957 0.0189615 35.84 &lt;1e-99 0.642406 0.716733
d 0.674031 0.0183706 36.69 &lt;1e-99 0.638025 0.710037
────────────────────────────────────────────────────────────────────</pre>

<pre class='language-julia'><code class='language-julia'>begin
Expand All @@ -117,7 +118,7 @@ d 0.67957 0.0189615 35.84 &lt;1e-99 0.642406 0.716733
space = Dict(
:max_depth =&gt; HP.QuantUniform(:max_depth, 2.0, 12.0, 1.0)
)

tuned_ml_g = TunedModel(
model = EvoTreeRegressor(),
tuning = MLJTreeParzenTuning(random_trials = 75, draws = 50),
Expand All @@ -144,13 +145,13 @@ d 0.67957 0.0189615 35.84 &lt;1e-99 0.642406 0.716733
end</code></pre>
<pre class="code-output documenter-example-output" id="var-tuned_ml_m">DoubleMLIRM{Float32, MLJTuning.DeterministicTunedModel{MLJTreeParzenTuning, EvoTrees.EvoTreeRegressor, Nothing}, MLJTuning.ProbabilisticTunedModel{MLJTreeParzenTuning, EvoTrees.EvoTreeClassifier, Nothing}}
==========================
StatsBase.CoefTable(Any[[0.5067636370658875], [0.020287886261940002], [24.9786319732666], [1.0436473597475374e-137], [0.46700011067004005], [0.5465271634617349]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>
StatsBase.CoefTable(Any[[0.5573905110359192], [0.04278203845024109], [13.028610229492188], [8.412598772482777e-39], [0.4735392564882387], [0.6412417655835997]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>

<pre class='language-julia'><code class='language-julia'>coeftable(dml_irm)</code></pre>
<pre class="code-output documenter-example-output" id="var-hash997185">────────────────────────────────────────────────────────────────────
Estimate Std. Error z value Pr(&gt;|z|) Lower 95.0% Upper 95.0%
────────────────────────────────────────────────────────────────────
d 0.506764 0.0202879 24.98 &lt;1e-99 0.467 0.546527
d 0.557391 0.042782 13.03 &lt;1e-38 0.473539 0.641242
────────────────────────────────────────────────────────────────────</pre>

<!-- PlutoStaticHTML.End -->
Expand Down
30 changes: 14 additions & 16 deletions docs/src/notebooks/lplr_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
<!--
# This information is used for caching.
[PlutoStaticHTML.State]
input_sha = "131c5e789bd07e513a5b6235045baf6c603c1ffeae0f97f9675c26111fa2be71"
input_sha = "608f5ab3ff7f9c3c1e0165b0fe879290984a7cff3fbc7bccfa761a3811b5dbb4"
julia_version = "1.12.4"
-->
<pre class='language-julia'><code class='language-julia'>begin
using Pkg
Pkg.activate("..")
Pkg.resolve()
Pkg.instantiate()
end</code></pre>
<pre class='language-julia'><code class='language-julia'>import Pkg; Pkg.develop(path=joinpath(@__DIR__, "../.."))</code></pre>


<pre class='language-julia'><code class='language-julia'>Pkg.activate(joinpath(@__DIR__, "../../examples"))</code></pre>


<pre class='language-julia'><code class='language-julia'>begin
Expand All @@ -57,7 +55,7 @@ end</code></pre>
<div class="markdown"><h2 id="Generate-LPLR-data">Generate LPLR data</h2></div>

<pre class='language-julia'><code class='language-julia'>
data_lplr = make_lplr_LZZ2020(1000, alpha=0.5, rng=StableRNG(42))</code></pre>
data_lplr = make_lplr_LZZ2020(1000, alpha = 0.5, rng = StableRNG(42))</code></pre>
<pre class="code-output documenter-example-output" id="var-data_lplr">DoubleMLData{Float32, Vector{Float32}}(Float32[1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0 … 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0], Float32[1.137392, -1.0203186, -1.2559067, 0.35913706, -0.98865694, 2.5477915, 1.6435643, -0.2593958, 2.7788334, 0.5610351 … 1.3883054, 1.6827291, 1.2748861, 1.5950062, 0.8413675, 0.1603024, 0.6246069, 0.86354524, 1.0373387, -1.603643], Float32[-0.67025167 0.3040378 … 0.9723363 -0.6289253; 2.0 -1.3471706 … -0.49255872 1.9596015; … ; -0.5976384 0.034506414 … 0.3402903 -0.70474565; 0.32168102 0.52544063 … 0.5724332 0.40678954], 1000, 20, :y, :d, [:X1, :X2, :X3, :X4, :X5, :X6, :X7, :X8, :X9, :X10, :X11, :X12, :X13, :X14, :X15, :X16, :X17, :X18, :X19, :X20])</pre>


Expand Down Expand Up @@ -117,13 +115,13 @@ end</code></pre>
end</code></pre>
<pre class="code-output documenter-example-output" id="var-ml_t">DoubleMLLPLR{Float32, MLJDecisionTreeInterface.RandomForestClassifier, MLJDecisionTreeInterface.RandomForestRegressor, MLJDecisionTreeInterface.RandomForestRegressor, MLJDecisionTreeInterface.RandomForestRegressor}
==========================
StatsBase.CoefTable(Any[[0.5981336832046509], [0.07487558573484421], [7.988367557525635], [1.3673725833843347e-15], [0.4513802318430149], [0.7448871345662869]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>
StatsBase.CoefTable(Any[[0.5567321181297302], [0.0747859850525856], [7.444337368011475], [9.743221856517205e-14], [0.41015428087831135], [0.703309955381149]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>

<pre class='language-julia'><code class='language-julia'>coeftable(dml_lplr_simple)</code></pre>
<pre class="code-output documenter-example-output" id="var-hash360715">────────────────────────────────────────────────────────────────────
Estimate Std. Error z value Pr(&gt;|z|) Lower 95.0% Upper 95.0%
────────────────────────────────────────────────────────────────────
d 0.598134 0.0748756 7.99 &lt;1e-14 0.45138 0.744887
d 0.556732 0.074786 7.44 &lt;1e-13 0.410154 0.70331
────────────────────────────────────────────────────────────────────</pre>


Expand All @@ -134,11 +132,11 @@ d 0.598134 0.0748756 7.99 &lt;1e-14 0.45138 0.744887
controls = [
Step(1),
Patience(10),
NumberLimit(20)
NumberLimit(20),
]

ml_M_iterated = IteratedModel(
EvoTreeClassifier(max_depth = 4, eta = 0.05),
EvoTreeClassifier(max_depth = 4, eta = 0.05),
resampling = Holdout(),
measure = cross_entropy,
iteration_parameter = :nrounds,
Expand All @@ -154,7 +152,7 @@ d 0.598134 0.0748756 7.99 &lt;1e-14 0.45138 0.744887
)

ml_m_iterated = IteratedModel(
EvoTreeRegressor(max_depth = 4, eta = 0.05),
EvoTreeRegressor(max_depth = 4, eta = 0.05),
resampling = Holdout(),
measure = mae,
iteration_parameter = :nrounds,
Expand All @@ -171,13 +169,13 @@ d 0.598134 0.0748756 7.99 &lt;1e-14 0.45138 0.744887
end</code></pre>
<pre class="code-output documenter-example-output" id="var-controls">DoubleMLLPLR{Float32, MLJIteration.ProbabilisticIteratedModel{EvoTrees.EvoTreeClassifier}, MLJIteration.DeterministicIteratedModel{EvoTrees.EvoTreeRegressor}, MLJIteration.DeterministicIteratedModel{EvoTrees.EvoTreeRegressor}, MLJIteration.DeterministicIteratedModel{EvoTrees.EvoTreeRegressor}}
==========================
StatsBase.CoefTable(Any[[0.5652134418487549], [0.07496540993452072], [7.539656639099121], [4.712104968941949e-14], [0.41828393829081284], [0.712142945406697]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>
StatsBase.CoefTable(Any[[0.5537656545639038], [0.07333461195230484], [7.551218032836914], [4.3120625571213347e-14], [0.41003245631716545], [0.6974988528106422]], ["Estimate", "Std. Error", "z value", "Pr(&gt;|z|)", "Lower 95.0%", "Upper 95.0%"], ["d"], 4, 3)</pre>

<pre class='language-julia'><code class='language-julia'>coeftable(dml_lplr_iterated)</code></pre>
<pre class="code-output documenter-example-output" id="var-hash950978">────────────────────────────────────────────────────────────────────
Estimate Std. Error z value Pr(&gt;|z|) Lower 95.0% Upper 95.0%
────────────────────────────────────────────────────────────────────
d 0.565213 0.0749654 7.54 &lt;1e-13 0.418284 0.712143
d 0.553766 0.0733346 7.55 &lt;1e-13 0.410032 0.697499
────────────────────────────────────────────────────────────────────</pre>

<!-- PlutoStaticHTML.End -->
Expand Down
Loading
Loading