MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / procentual_proximity

Function procentual_proximity

other/scoring_algorithm.py:97–119  ·  view source on GitHub ↗

| `weights` - ``int`` list | possible values - ``0`` / ``1`` * ``0`` if lower values have higher weight in the data set * ``1`` if higher values have higher weight in the data set >>> procentual_proximity([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]], [0, 0, 1]) [

(
    source_data: list[list[float]], weights: list[int]
)

Source from the content-addressed store, hash-verified

95
96
97def procentual_proximity(
98 source_data: list[list[float]], weights: list[int]
99) -> list[list[float]]:
100 """
101 | `weights` - ``int`` list
102 | possible values - ``0`` / ``1``
103
104 * ``0`` if lower values have higher weight in the data set
105 * ``1`` if higher values have higher weight in the data set
106
107 >>> procentual_proximity([[20, 60, 2012],[23, 90, 2015],[22, 50, 2011]], [0, 0, 1])
108 [[20, 60, 2012, 2.0], [23, 90, 2015, 1.0], [22, 50, 2011, 1.3333333333333335]]
109 """
110
111 data_lists = get_data(source_data)
112 score_lists = calculate_each_score(data_lists, weights)
113 final_scores = generate_final_scores(score_lists)
114
115 # append scores to source data
116 for i, ele in enumerate(final_scores):
117 source_data[i].append(ele)
118
119 return source_data

Callers

nothing calls this directly

Calls 4

get_dataFunction · 0.85
calculate_each_scoreFunction · 0.85
generate_final_scoresFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected