algorithm - How to add weights to dataset variables using kNN in Octave? -


i implementing this knn algorithm in octave.

the function declared this

    function [classified, k, dist, idx] = fastknn(trained, unknown, k, distance) 

my dataset this:

%lat, lng, area, buildyear, price 54.6, 24.7, 23.6, 1965, 100000.00 54.6, 24.7, 13.6, 1964, 50000.00 ... 

i have 2 questions.

question 1: how add weights dataset variables. example area has bigger weight coordinates.

question 2: if set k=3, algorithm return me avg price of closest 3 neighbors or picks 1 3? - guess more related algorithm learning.

thank you!

to put more weight on 1 feature, can multiply given feature value.

this equivalent stretching space along respective dimension, putting more emphasis on changes in respective feature when distances calculated.


the fastknn function mentioned uses "mode" of nearest k neighbors (i.e. frequent value). appropriate classification (where have few classes want predict), not useful situation.

for regression, taking average of values of nearest neighbors choice.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -