[
https://issues.apache.org/jira/browse/MADLIB-1181?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16295807#comment-16295807
]
Frank McQuillan commented on MADLIB-1181:
-----------------------------------------
For regression:
{code}
sum(weight * value )/sum(weights)
{code}
seems correct for weighted mean.
For classification, the idea I think is to compute the weighted vote for each
categorical level:
{code}
cat level x: sum(1/d_x) where d_x is the distances to all training points
that have cat level x
cat level y: sum(1/d_y) where d_y is the distances to all training points
that have cat level y
{code}
etc
then you assign the cat level with the highest sum to the test point.
> Add an option for weighted average in k-NN
> ------------------------------------------
>
> Key: MADLIB-1181
> URL: https://issues.apache.org/jira/browse/MADLIB-1181
> Project: Apache MADlib
> Issue Type: Improvement
> Components: k-NN
> Reporter: Frank McQuillan
> Assignee: Himanshu Pandey
> Priority: Minor
> Fix For: v1.14
>
>
> Follow on from
> https://issues.apache.org/jira/browse/MADLIB-1059
> (please see this JIRA for additional comments)
> MADlib does a simple average of the k-nearest neighbors to come up with the
> final value for classification and regression. Doing a weighted average
> instead
> might be a desirable functionality. The weighting for the average can be
> based on the
> distance of the k-nearest neighbors.
> We can probably provide an optional parameter to let users choose how the
> final
> score has to be computed (avg or weighted avg).
> This JIRA applies to classification and regression.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)