MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / calc_auc

Function calc_auc

modelzoo/features/embedding_variable/dien/script/utils.py:181–217  ·  view source on GitHub ↗

Summary Args: raw_arr (TYPE): Description Returns: TYPE: Description

(raw_arr)

Source from the content-addressed store, hash-verified

179 return tf.maximum(_zero, _x) + _alpha * tf.minimum(_zero, _x)
180
181def calc_auc(raw_arr):
182 """Summary
183
184 Args:
185 raw_arr (TYPE): Description
186
187 Returns:
188 TYPE: Description
189 """
190
191 arr = sorted(raw_arr, key=lambda d:d[0], reverse=True)
192 pos, neg = 0., 0.
193 for record in arr:
194 if record[1] == 1.:
195 pos += 1
196 else:
197 neg += 1
198
199 fp, tp = 0., 0.
200 xy_arr = []
201 for record in arr:
202 if record[1] == 1.:
203 tp += 1
204 else:
205 fp += 1
206 xy_arr.append([fp/neg, tp/pos])
207
208 auc = 0.
209 prev_x = 0.
210 prev_y = 0.
211 for x, y in xy_arr:
212 if x != prev_x:
213 auc += ((x - prev_x) * (y + prev_y) / 2.)
214 prev_x = x
215 prev_y = y
216
217 return auc
218
219def attention(query, facts, attention_size, mask, stag='null', mode='LIST', softmax_stag=1, time_major=False, return_alphas=False):
220 if isinstance(facts, tuple):

Callers 1

evalFunction · 0.50

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected