comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: slow processing of my k-nearest neighour code
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: slow processing of my k-nearest neighour code [message #49783 is a reply to message #49776] Mon, 14 August 2006 09:01 Go to previous messageGo to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Wayne Landsman wrote:
> Karl Schultz wrote:
>> On Mon, 14 Aug 2006 10:11:30 -0400, Ben Tupper wrote:
>>
>>> humphreymurray@gmail.com wrote:
>>>
>>>> > ; Calculate the squared distance for each attribute.
>>>> > squared = make_array(num_training_elements, num_attributes)
>>>> > for attrib = 0, num_attributes-1 do begin
>>>> > squared[*,attrib] = (testing_data[i, attrib] -
>>>> > training_data[*,attrib])^2
>>>> > endfor
>>>> >
>>> Hi,
>>>
>>> You might try replacing the above for inner-loop with the following
>>>
>>> squared = (testing_data - training_data)^2
>>>
>
> I don't think this works here because you lose the dependence on the i
> index -- the value of "squared" will differ for each value of "i".
> But another one of David Fanning's pages could help, see
> http://www.dfanning.com/code_tips/asterisk.html
> and rewrite the assignment as
>
> squared[0,attrib] = (testing_data[i, attrib] -
> training_data[*,attrib])^2
>

Ah! Got it. I didn't catch that squared was measuring the distance
from each test point to every training point for the specified
attribute. Duh! I guess that's the whole point!

Sorry for the misdirect.

Cheers,
Ben
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with GRID_TPS
Next Topic: Re: SHMMAP and structures

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:31:35 PDT 2025

Total time taken to generate the page: 0.00468 seconds