[MAINT]: bump and update julearn example #242

Merged
synchon merged 5 commits from fix/julearn-example into main 2023-07-20 11:34:45 +00:00
5 changed files with 19 additions and 9 deletions

View file

@ -17,6 +17,7 @@ help:
clean: clean:
rm -rf $(BUILDDIR)/* rm -rf $(BUILDDIR)/*
rm -rf auto_examples/ rm -rf auto_examples/
rm -rf api/generated/
# For local build # For local build
local: news local: news

View file

@ -0,0 +1 @@
Update ``julearn`` example under ``examples`` by `Synchon Mandal`_

View file

@ -81,6 +81,7 @@ nitpick_ignore_regex = [
("py:class", "typing.Any"), # python 3.11 error ("py:class", "typing.Any"), # python 3.11 error
# ('py:class', 'numpy.typing.ArrayLike') # ('py:class', 'numpy.typing.ArrayLike')
("py:obj", "sqlalchemy.engine.Engine"), # ignore sqlalchemy ("py:obj", "sqlalchemy.engine.Engine"), # ignore sqlalchemy
("py:class", "pipeline.Pipeline"), # nilearn
] ]
# -- Options for HTML output ------------------------------------------------- # -- Options for HTML output -------------------------------------------------

View file

@ -16,9 +16,9 @@ import tempfile
import nilearn import nilearn
import pandas as pd import pandas as pd
from julearn import run_cross_validation from julearn import run_cross_validation, PipelineCreator
import junifer.testing.registry # noqa import junifer.testing.registry # noqa: F401
from junifer.api import collect, run from junifer.api import collect, run
from junifer.storage.sqlite import SQLiteFeatureStorage from junifer.storage.sqlite import SQLiteFeatureStorage
from junifer.utils import configure_logging from junifer.utils import configure_logging
@ -70,7 +70,6 @@ sex = (
############################################################################### ###############################################################################
# Create a temporary directory for junifer feature extraction: # Create a temporary directory for junifer feature extraction:
with tempfile.TemporaryDirectory() as tmpdir: with tempfile.TemporaryDirectory() as tmpdir:
storage = {"kind": "SQLiteFeatureStorage", "uri": f"{tmpdir}/test.sqlite"} storage = {"kind": "SQLiteFeatureStorage", "uri": f"{tmpdir}/test.sqlite"}
# run the defined junifer feature extraction pipeline # run the defined junifer feature extraction pipeline
run( run(
@ -97,15 +96,23 @@ X = list(df_vbm.columns)
df_vbm[y] = age df_vbm[y] = age
df_vbm[confound] = sex df_vbm[confound] = sex
X_types = {
"features": X,
"confound": confound,
}
creator = PipelineCreator(problem_type="regression", apply_to="features")
creator.add("zscore", apply_to=["features", "confound"])
creator.add("confound_removal", apply_to="features", confounds="confound")
creator.add("ridge")
scores = run_cross_validation( scores = run_cross_validation(
X=X, X=X + [confound],
confounds=confound,
y=y, y=y,
X_types=X_types,
data=df_vbm, data=df_vbm,
problem_type="regression", model=creator,
model="ridge",
cv=3, cv=3,
preprocess_X=["zscore", "remove_confound"],
) )
print(scores) print(scores)

View file

@ -68,7 +68,7 @@ docs = [
"sphinx-gallery>=0.11.0,<0.12", "sphinx-gallery>=0.11.0,<0.12",
"furo>=2022.9.29,<2023.0.0", "furo>=2022.9.29,<2023.0.0",
"numpydoc>=1.5.0,<1.6", "numpydoc>=1.5.0,<1.6",
"julearn==0.2.5", "julearn==0.3.0",
"sphinx-copybutton==0.5.1", "sphinx-copybutton==0.5.1",
"towncrier==22.12.0", "towncrier==22.12.0",
"sphinxcontrib-mermaid==0.8.1", "sphinxcontrib-mermaid==0.8.1",