BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Shanmugavel_g
Calcite | Level 5

Hi All,

 

I'm trying to run KNN on set of standardized inputs and identify 20 neighbors using Euclidean distance or other similar distance. 

I would like to get top N neighbor, distance between the neighbors and my item as output. I don't have a target variable in my dataset, so I need this procedure to identify my neighbors based only on input space. I have 21K items and 145 variables in my dataset, so I'm also looking for efficiency of the procedure.

 

I tried MBR node in Enterprise miner and PROC DISCRIM in base SAS, but both requires target variable. 

Can anyone kindly point me to the right procedure that would be helpful to implement my problem. Let me know if any other details are needed.

 

Thanks in advance

 

Regards,

Shan

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try using proc modeclus with options neighbor and dk=

 

ods _all_ close;
proc modeclus data=myData dk=21 neighbor;
var var1-var145;
id Item;
ods output Neighbor=myNeighbors;
run;
ods listing;

test with a subset first!

PG

View solution in original post

5 REPLIES 5
Shanmugavel_g
Calcite | Level 5

Thanks for quick reply. I will take a look into these procedure, run it on my data and will let you know the results.

PGStats
Opal | Level 21

Try using proc modeclus with options neighbor and dk=

 

ods _all_ close;
proc modeclus data=myData dk=21 neighbor;
var var1-var145;
id Item;
ods output Neighbor=myNeighbors;
run;
ods listing;

test with a subset first!

PG
Shanmugavel_g
Calcite | Level 5
Thanks for quick reply.
I'll try your code on my dataset and let you know the results. Thanks for the help.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 2285 views
  • 4 likes
  • 4 in conversation