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.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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