Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

KNN Classification with K values in a Loop

absherzadabsherzad Member Posts: 1 Learner III
edited August 2019 in Help

Greetings everyone,

Is there a way to use KNN with a loop in order to assign the index of the loop as a value for K, and then compare the results?

 

Regards,

Sherzad

Comments

  • btibertbtibert Member, University Professor Posts: 146 Guru
    Yes, please see the screenshots below.  Hope this helps.

    1)  The setup where I am setting a role , train/test split, and passing in both for access into the loop.  The output is a single row table with 1 performance metric, accuracy.  I use the append operator to put these together into 1 dataset.



    2)  Inside the loop.  I am taking the top port (training set) to fid the KNN model.  I am applying it for the given K, getting the performance stat accuracy, making that a dataset, and then setting the value of K with the advanced function using the param function.



    3)  Below is the screen where you can see I am setting the value of K.  This is what is used during each iteration of the loop.  As shown previously, we append used Performance to data to get a 1-row dataset, and then appended them all together for further analysis.

      

    4)  We can use the dataset to plot our accuracy over the K values to get a sense of what we might set using visualizations inside the results


Sign In or Register to comment.