reset password
Author Message
nshatok
Posts: 19
Posted 14:28 Aug 25, 2009 |

since there is no value specified for k in the assignment,  I did   for k = 1,2,3

Attachments:
p0941
Posts: 95
Posted 19:45 Aug 27, 2009 |

Maybe using dsim(x,y) for distance?

HelloWorld
Posts: 88
Posted 18:20 Aug 29, 2009 |
p0941 wrote:

Maybe using dsim(x,y) for distance?

No, K is suppose to be an input..

HelloWorld
Posts: 88
Posted 19:45 Aug 29, 2009 |

Check out my solution

I'm using Excel to calculate the distance, since it's a lot of calculation..

Attachments:
Last edited by HelloWorld at 19:46 Aug 29, 2009.
xieguahu
Posts: 50
Posted 15:18 Aug 30, 2009 |
I think nshatok's way of caculation for Euclidean Distance makes more sense to me

HelloWorld wrote:

Check out my solution

I'm using Excel to calculate the distance, since it's a lot of calculation..

 

HelloWorld
Posts: 88
Posted 17:17 Aug 30, 2009 |
xieguahu wrote:
I think nshatok's way of caculation for Euclidean Distance makes more sense to me

HelloWorld wrote:

Check out my solution

I'm using Excel to calculate the distance, since it's a lot of calculation..

 

lol, I agree myself..

p0941
Posts: 95
Posted 13:20 Aug 31, 2009 |

Assum K = 3

For categorical attributes, the distance(x,y)= (p-m)/p
m: number of attribute matches
p: total number of attributes

1) dis(porc,humn) = 2/7
   dis(porc,pyth) = 5/7
   dis(porc,salm) = 6/7
   dis(porc,whal) = 4/7
   dis(porc,frog) = 4/7
   dis(porc,KD) = 4/7
   dis(porc,bat) = 2/7
   dis(porc,pige) = 4/7
   dis(porc,cat) = 2/7
   dis(porc,LS) = 5/7
   dis(porc,turt) = 5/7
   dis(porc,peng) = 4/7
  
The nearest 3 are: humn, bat, cat
Mammal is the majority class, so assign mammal to Porcupine. 

2) dis(eel,humn) = 5/7
   dis(eel,pyth) = 2/7
   dis(eel,salm) = 0/7
   dis(eel,whal) = 3/7
   dis(eel,frog) = 3/7
   dis(eel,kD) = 2/7
   dis(eel,bat) = 1
   dis(eel,pige) = 5/7
   dis(eel,cat) = 5/7
   dis(eel,LP) = 1/7
   dis(eel,turt) = 2/7
   dis(eel,peng) = 4/7

The nearest 3 are: salm, LP, pyth
fish is the majority class, so assign fish to eel

3) dis(sala,humn) = 5/7
   dis(sala,pyth) = 3/7
   dis(sala,salm) = 4/7
   dis(sala,whal) = 6/7
   dis(sala,frog) = 0
   dis(sala,KD) = 3/7
   dis(sala,bat) = 5/7
   dis(sala,pige) = 5/7
   dis(sala,cat) = 5/7
   dis(sala,LS) = 5/7
   dis(sala,turt) = 2/7
   dis(sala,peng) = 3/7

The nearest 3 are: frog, turt, pyth/KD/peng
Reptile or Amphibian or Mammal is the majority class, so assign Reptile or Amphibian or Mammal to Salamander

cysun
Posts: 2935
Posted 16:19 Aug 31, 2009 |

nshatok's solution is corret.