MCPcopy Index your code
hub / github.com/geekcomputers/Python / score_columns

Function score_columns

scalg.py:106–131  ·  view source on GitHub ↗

Analyse data file using a range based percentual proximity algorithm and calculate the linear maximum likelihood estimation. Args: source_data (list): Data set to process. columns (list): Indexes of the source_data columns to be scored. weights (list): Weights corresp

(source_data: list, columns: list, weights: list)

Source from the content-addressed store, hash-verified

104
105
106def score_columns(source_data: list, columns: list, weights: list) -> list:
107 """Analyse data file using a range based percentual proximity
108 algorithm and calculate the linear maximum likelihood estimation.
109 Args:
110 source_data (list): Data set to process.
111 columns (list): Indexes of the source_data columns to be scored.
112 weights (list): Weights corresponding to each column from the data set.
113 0 if lower values have higher weight in the data set,
114 1 if higher values have higher weight in the data set
115 Raises:
116 ValueError: Weights can only be either 0 or 1 (int)
117 Returns:
118 list: Source data with the score of the set appended at as the last element.
119 """
120
121 temp_data = []
122 for item in source_data:
123 temp_data.append([item[c] for c in columns])
124
125 if len(weights) > len(columns):
126 weights = [weights[item] for item in columns]
127
128 for i, sc in enumerate(score(temp_data, weights, "scores")):
129 source_data[i].append(sc)
130
131 return source_data

Callers

nothing calls this directly

Calls 2

scoreFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected