A newbie question about Rule Engine

Hi all,
I am just starting with KNIME. I have a KNN model and I am setting up rules based on the clusters, so I can label my data set for a classification tree. As I write the rules, I am getting that line error because it expects one rule in each line and it has a character limit. Is there anyway, I can indicate that the rule continues in the next line?
$Age$>=18 AND $Age$<=30
AND $AST$>=150 AND $AST$<=250
AND $3P$>=90 AND $3P$<=150
AND $PTS$ >= 800 AND $PTS$ <= 1400
AND $TOV$ >= 80 AND $TOV$ <= 180 => “G”
$Age$>=18 AND $Age$<=34 AND AST>250 => “E”
TRUE => “F”
This G,E, F will be appended on a CLASS field
Any help appreciated. I am trying to create a model to explain to high scholars, otherwise I would go with python
Thanks

Hi @alicemello,

welcome to the forum! As far as I know, with the rule engine one row = one rule and there is no way to go to another line with the same rule.
Can you show me the char limit error? I tried to replicate it with a long rule but it works as expected.

Have a nice day,
Raffaello Barri

2 Likes

Interesting, I will try that, but my solution was to simplify my rule. Will post again of I can replicate the error message
Thanks

2 Likes

@alicemello you can use a Java Snippet or a Column Expression node to have if, then, else conditions.

Your example adapted to the Column Expression node would look like this:

if (column("Age") >= 18 && column("Age") <= 30 &&
    column("AST") >= 150 && column("AST") <= 250 &&
    column("3P") >= 90 && column("3P") <= 150 &&
    column("PTS") >= 800 && column("PTS") <= 1400 &&
    column("TOV") >= 80 && column("TOV") <= 180) {
    "G";
} else if (column("Age") >= 18 && column("Age") <= 34 && column("AST") > 250) {
    "E";
} else {
    "F";
}
5 Likes

I could not find the column expression node on my KNIME platform, but it did work with rule engine. I hope it is right.

@alicemello you will have to install the extension

1 Like

Hi @alicemello ,

Column Expressions is part of the KNIME Expressions extension, but if you drag the node into a workflow from the page on the hub below, KNIME should do all the necessary installation, and then it’ll be in your node repository for future use…

3 Likes

@mlauber71 , snap!.. You’re too quick for me, lol

1 Like