当有几个预测因子时,KNN回归算法

发布于 2025-02-07 06:03:30 字数 333 浏览 1 评论 0原文

您能帮助我了解KNN回归器的工作原理:

  1. 当有几个预测变量时,KNN如何看待5个最近的邻居? 它是否分别寻找每个预测变量的K最近的邻居,然后以某种方式将结果结合在一起?如果是这样,那么为什么不可能在预测器P1上查找K1邻居,而是在预测变量P2等上的K2预测变量...为什么它是“ K”而不是“ ks”阵列,其中长度为长度阵列等于预测变量的数量?

  2. knn对预测变量的比例很敏感,因此建议使用Minmaxscaler(Python)。这是否意味着,从本质上讲,我可以利用这一财产来利益,例如,通过增加我希望KNN优先考虑的某些预测变量的规模。

谢谢

Can you please help me understanding how KNN regressor works:

  1. How does KNN look for 5 nearest neighbours, when there are several predictors?
    Does it look for K nearest neighbours for each predictor separately and then somehow combines the results together? If so, then why wouldn't it be possible for example to look for K1 neighbours on predictor P1, but K2 predictors on predictor P2 etc...Why is it "K" rather than an "array of Ks", where the length of the array equals the number of predictors?

  2. KNN is sensitive to the scale of the predictors, therefore MinMaxScaler is recommended (Python) to be used. Does it mean, that essentially I can leverage this property to my benefit, for example by increasing the scale of certain predictor that I want KNN to give a priority to.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绮筵 2025-02-14 06:03:30
  1. 在多个预测因素的情况下,

    knn会查看预测空间中向量之间的欧几里得距离。例如,如果您有三个预测因子X1,X2和X3,则所有数据点将是3维空间中的一个点。要测量距离,您只需计算$ d = \ sqrt {(p_1-x_1)^2+(p_2-x_2)^2+(p_3-x_3)^2} $,并使用它来找到邻居。

  2. 您绝对可以通过不同的缩放来影响距离测量。但是,这可能应该通过一些小心来完成,我会使用交叉验证之类的东西来确保假设按预期工作。

希望这有帮助!

  1. kNN would in the case of multiple predictors look at the Euclidian distance between vectors in the predictor space. E.g., if you have three predictors x1, x2, and x3, all data points will be a point in the 3-dimensional space. To measure the distance you simply compute $d=\sqrt{(p_1-x_1)^2+(p_2-x_2)^2+(p_3-x_3)^2}$, and use that to find the neighbors.

  2. You can definitely influence the distance measurements by scaling differently. However, this should probably be done with some care and I would use something like cross-validation to make sure the assumptions work as expected.

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文