python - Varying n_neighbors in scikit-learn KNN regression -
i using scikit-learn's knn regressor fit model large dataset n_neighbors = 100-500. given nature of data, parts (think: sharp delta-function peaks) better fit fewer neighbors (n_neighbors ~ 20-50) peaks not smoothed out. location of these peaks known (or can measured).
is there way vary n_neighbors parameter?
i fit 2 models , stitch them together, inefficient. preferable either prescribe 2-3 values n_neighbors or, worse, send in list of n_neighbors.
i'm afraid not. in part, due algebraic assumptions relationship symmetric: neighbour b iff b neighbour a. if give different k values, you're guaranteed break symmetry.
i think major reason algorithm simpler fixed quantity of neighbors, yielding better results in general. have specific case knn doesn't fit well.
i suggest stitch 2 models, switching dependent on imputed second derivative.
Comments
Post a Comment