64710c051f26a2778c03fc15ef29c4bcae01df32,official/recommendation/ncf_main.py,,evaluate_model,#Any#Any#Any#,57

Before Change



  // NumPy has an np.argparition() method, however log(1000) is so small that
  // sorting the whole array is simpler and fast enough.
  top_indicies = np.argsort(predicted_scores_by_user, axis=1)[:, -_TOP_K:]
  top_indicies = np.flip(top_indicies, axis=1)

  // Both HR and NDCG vectorized computation takes advantage of the fact that if
  // the positive example for a user is not in the top k, that index does not
  // appear. That is to say:   hit_ind.shape[0] <= num_users
  hit_ind = np.argwhere(np.equal(top_indicies, 0))
  hr = hit_ind.shape[0] / ncf_dataset.num_users
  ndcg = np.sum(np.log(2) / np.log(hit_ind[:, 1] + 2)) / ncf_dataset.num_users

  global_step = estimator.get_variable_value(tf.GraphKeys.GLOBAL_STEP)
  eval_results = {
      _HR_KEY: hr,

After Change


  // Get predictions
  predictions = estimator.predict(input_fn=pred_input_fn,
                                  yield_single_examples=False)
  predictions = list(predictions)

  prediction_batches = [p[movielens.RATING_COLUMN] for p in predictions]
  item_batches = [p[movielens.ITEM_COLUMN] for p in predictions]

  // Reshape the predicted scores and items. Each user takes one row.
  prediction_with_padding = np.concatenate(prediction_batches, axis=0)
  predicted_scores_by_user = prediction_with_padding[
      :ncf_dataset.num_users * (1 + rconst.NUM_EVAL_NEGATIVES)]\
      .reshape(ncf_dataset.num_users, -1)
  item_with_padding = np.concatenate(item_batches, axis=0)
  items_by_user = item_with_padding[
      :ncf_dataset.num_users * (1 + rconst.NUM_EVAL_NEGATIVES)]\
      .reshape(ncf_dataset.num_users, -1)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 8

Instances


Project Name: tensorflow/models
Commit Name: 64710c051f26a2778c03fc15ef29c4bcae01df32
Time: 2018-08-22
Author: reedwm@google.com
File Name: official/recommendation/ncf_main.py
Class Name:
Method Name: evaluate_model


Project Name: Qiskit/qiskit-aqua
Commit Name: 790ff93e20cc36e15dfd039924e782cc559a67d7
Time: 2019-08-01
Author: chenrich@us.ibm.com
File Name: qiskit/aqua/operators/op_converter.py
Class Name:
Method Name: to_weighted_pauli_operator


Project Name: nipy/dipy
Commit Name: 39dc6942a69a280cb6935c48c0d524d2dd2d9385
Time: 2010-11-10
Author: iannimmosmith@gmail.com
File Name: dipy/core/generalized_q_sampling.py
Class Name:
Method Name: triple_odf_maxima