Skip to content
Advertisement

I can’t get my additive weighting algorithm to work properly

I have a data structure that look like this

JavaScript

I’m trying to get the normalized values but it wasn’t giving me the expected result with my current algorithm.

JavaScript

I have been stuck with this problem for about 4 days, the problem is in the min(...) and max(...) function inside the get_matrix_r method. It was supposed to take the number from top to bottom for each column instead of taking the highest/lowest number directly from the key given by $matrix_x but I don’t know how to do that.

I also asked a question related to this issue, but when I loop inside the $reducer using the given solutions, it produce extra items in the result. Please help!

functions.php

JavaScript

Advertisement

Answer

Well, the first problem, is that in the dataset you are providing there is not user_c, but in the output matrix there are references to that, so that’s weird.

The second problem, is that in the reducer, you are considering the ROWs, and not the COLUMNs… to consider those, you should do something like this:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement