Skip to content

Commit

Permalink
codespell
Browse files Browse the repository at this point in the history
  • Loading branch information
fraimondo committed Jul 30, 2024
1 parent 00d30e2 commit 1979058
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
21 changes: 14 additions & 7 deletions examples/03_complex_models/run_generate_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# Authors: Federico Raimondo <[email protected]>
# License: AGPL

# %%
from seaborn import load_dataset
from julearn import run_cross_validation
from julearn.pipeline import PipelineCreator
Expand All @@ -35,27 +34,37 @@
y = "__generated__" # to indicate to julearn that the target will be generated



# Define our feature types
X_types = {
"sepal": ["sepal_length", "sepal_width"],
"petal": ["petal_length", "petal_width"],
}

# %% reate the pipeline that will generate the features
###############################################################################
# We now use a Pipeline Creator to create the pipeline that will generate the
# features. This special pipeline should be configured to be a "transformer"
# and apply to the "petal" feature types.

target_creator = PipelineCreator(problem_type="transformer", apply_to="petal")
target_creator.add("pca", n_components=2)
# Select only the first component
target_creator.add("pick_columns", keep="pca__pca0")


# %% Create the final pipeline
###############################################################################
# We now create the pipeline that will be used to predict the target. This
# pipeline will be a regression pipeline. The step previous to the model should
# be the the `generate_target`, applying to the "petal" features and using the
# target_creator pipeline as the transformer.
creator = PipelineCreator(problem_type="regression")
creator.add("zscore")
creator.add("generate_target", apply_to="petal", transformer=target_creator)
creator.add(
"linreg", apply_to="sepal",
)

# %%
###############################################################################
# We finally evaluate the model within the cross validation.
scores, model = run_cross_validation(
X=X,
y=y,
Expand All @@ -68,5 +77,3 @@

print(scores["test_score"]) # type: ignore

# %%
print(model)
2 changes: 1 addition & 1 deletion julearn/pipeline/tests/test_pipeline_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def test_PipelineCreator_generated_target(
) -> None:
"""Test the pipeline creator with a generated target."""

# Create a transfomer that will apply to the petal features
# Create a transformer that will apply to the petal features
tranformer_creator = PipelineCreator(
problem_type="transformer", apply_to="petal"
)
Expand Down

0 comments on commit 1979058

Please sign in to comment.