How to find out weights of attributes in K-nearest neighbors algorithm?

Viewed 5648

I have such code in python with dataset of house prices:

from sklearn.datasets import load_boston
from sklearn.neighbors import KNeighborsRegressor
from sklearn.preprocessing import scale

boston = load_boston()
y = boston.target
X = scale(boston.data)
knn = KNeighborsRegressor(n_neighbors=5, weights='distance', metric='minkowski', p=1)
knn.fit(X, y)

And now I can predict target attribute, in this case it's price:

knn.predict([-0.41771335,  0.28482986, -1.2879095 , ..., -1.45900038,
     0.44105193, -1.0755623 ])

As I understand this algorithm should find weights for each attribute to make a distance function. Where can I find computed weights of each attribute? I wonder what attribute has strongest correlation with house price.

1 Answers
Related