Advertisement
lamiastella

worst code ever

Dec 2nd, 2018
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.43 KB | None | 0 0
  1. sum_predicted0 = 0.0
  2. sum_groundtruth0 = 0.0
  3. for i in range(df0.shape[0]):
  4.     probs = array([float(df0.iloc[i]['p(T1)'])*100,
  5.                    float(df0.iloc[i]['p(T2)'])*100,
  6.                    float(df0.iloc[i]['p(T3)'])*100,
  7.                    float(df0.iloc[i]['p(T4)'])*100,
  8.                    float(df0.iloc[i]['p(T5)'])*100,
  9.                    float(df0.iloc[i]['p(T6)'])*100,
  10.                    float(df0.iloc[i]['p(T7)'])*100,
  11.                    float(df0.iloc[i]['p(T8)'])*100,
  12.                    float(df0.iloc[i]['p(T9)'])*100])
  13.  
  14.     sum_predicted0 += math.log(np.max(probs))
  15.  
  16.     if fold0.iloc[i]['Q3 Theme'] == 1:
  17.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T1)'])
  18.     elif fold0.iloc[i]['Q3 Theme'] == 2:
  19.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T2)'])
  20.     elif fold0.iloc[i]['Q3 Theme'] == 3:
  21.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T3)'])
  22.     elif fold0.iloc[i]['Q3 Theme'] == 4:
  23.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T4)'])
  24.     elif fold0.iloc[i]['Q3 Theme'] == 5:
  25.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T5)'])
  26.     elif fold0.iloc[i]['Q3 Theme'] == 6:
  27.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T6)'])
  28.     elif fold0.iloc[i]['Q3 Theme'] == 7:
  29.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T7)'])
  30.     elif fold0.iloc[i]['Q3 Theme'] == 8:
  31.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T8)'])
  32.     elif fold0.iloc[i]['Q3 Theme'] == 9:
  33.         sum_groundtruth0 += math.log(df0.iloc[i]['p(T9)'])
  34.  
  35.  
  36.  
  37.  
  38. avg_predicted = (-sum_predicted0/df0.shape[0] +
  39.                  -sum_predicted1/df1.shape[0] +
  40.                  -sum_predicted2/df2.shape[0] +
  41.                  -sum_predicted3/df3.shape[0] +
  42.                  -sum_predicted4/df4.shape[0] +
  43.                  -sum_predicted5/df5.shape[0] +
  44.                  -sum_predicted6/df6.shape[0] +
  45.                  -sum_predicted7/df7.shape[0] +
  46.                  -sum_predicted8/df8.shape[0] +
  47.                  -sum_predicted9/df9.shape[0]
  48.                  ) / 10
  49.  
  50. avg_gt = (-sum_groundtruth0/df0.shape[0] +
  51.           -sum_groundtruth1/df1.shape[0] +
  52.           -sum_groundtruth2/df2.shape[0] +
  53.           -sum_groundtruth3/df3.shape[0] +
  54.           -sum_groundtruth4/df4.shape[0] +
  55.           -sum_groundtruth5/df5.shape[0] +
  56.           -sum_groundtruth6/df6.shape[0] +
  57.           -sum_groundtruth7/df7.shape[0] +
  58.           -sum_groundtruth8/df8.shape[0] +
  59.           -sum_groundtruth9/df9.shape[0]) /10
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement