# How to nest parameter optimization loop and feature selection loop

**URL:** <https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557>\
**Category:** KNIME Analytics Platform\
**Tags:** machine-learning, workflow, node\
**Created:** [June 16, 2025, 2:16pm UTC](https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557 "2025-06-16T14:16:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaeruo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@gaeruo](https://forum.knime.com/u/gaeruo)\
**Post date:** [June 16, 2025, 2:16pm UTC](https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557/1 "2025-06-16T14:16:52Z")

</div>

I have created the following workflow where i try to find the best subset of features to analyze using the feature selection loop. I use a K-NN node as my classifier and wanted to add a phase of hyperparameter tuning by trying out different possible values for k. I know how to do this 2 steps separately but when i try to connect all the nodes the second loop end doesn’t seem to see the Accuracy metric so i can’t maximize it

 ![Schermata 2025-06-16 alle 16.16.01](https://forum-cdn.knime.com/uploads/default/original/3X/a/c/ac6cfa085847d9e01e3a018ed366ca95a8384557.png)  
 ![Schermata 2025-06-16 alle 16.16.19](https://forum-cdn.knime.com/uploads/default/original/3X/1/c/1c4d6b5b1a692b93e84e68bc82c4360c036c6db7.png)  
 ![Schermata 2025-06-16 alle 16.16.27](https://forum-cdn.knime.com/uploads/default/original/3X/e/c/ece122d285ddb386bfb006a90fc00d697db7a8c7.png)

---

<div class="post-metadata">

**Author:** ![gaeruo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/g/d26b3c/32.png) [@gaeruo](https://forum.knime.com/u/gaeruo)\
**Post date:** [June 17, 2025, 7:25pm UTC](https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557/2 "2025-06-17T19:25:27Z")

</div>

Can someone tell me how to set the accuracy as a flow variable so the parameter optimization loop end node can see it ?

---

<div class="post-metadata">

**Author:** ![ScottF](https://forum-cdn.knime.com/user_avatar/forum.knime.com/scottf/32/61316_2.png) [@ScottF](https://forum.knime.com/u/ScottF)\
**Post date:** [June 24, 2025, 9:38pm UTC](https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557/3 "2025-06-24T21:38:09Z")

</div>

Hi @gaeruo and welcome to the forum.

At first glance, I can see a type mismatch in your last screenshot - _scoreVariable_ is looking for a string a you are providing a double, _Accuracy_.

Are you able to upload your workflow with an example dataset so someone can take a closer look? Screenshots only get us so far 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [September 22, 2025, 9:38pm UTC](https://forum.knime.com/t/how-to-nest-parameter-optimization-loop-and-feature-selection-loop/88557/4 "2025-09-22T21:38:36Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
