| 10 | |
| 11 | |
| 12 | def sparsification_plot(cov, mse): |
| 13 | cov, mse = cov.flatten(), mse.flatten() |
| 14 | sorted_indices = np.argsort(cov)[::-1] |
| 15 | sorted_indices_mse = np.argsort(mse)[::-1] |
| 16 | est, oracle = [], [] |
| 17 | for i in range(0, len(cov), len(cov) // 100): |
| 18 | remain_indices = sorted_indices[i:] |
| 19 | remain_indices_mse = sorted_indices_mse[i:] |
| 20 | if remain_indices.shape[0] == 0: |
| 21 | est.append(0) |
| 22 | oracle.append(0) |
| 23 | break |
| 24 | est.append(np.mean(mse[remain_indices])) |
| 25 | oracle.append(np.mean(mse[remain_indices_mse])) |
| 26 | est, oracle = np.array(est), np.array(oracle) |
| 27 | oracle = (oracle - np.min(oracle)) / (np.max(oracle) - np.min(oracle)) |
| 28 | factor = oracle[0] / est[0] |
| 29 | est = est * factor |
| 30 | cc = spearmanr(est, oracle)[0] |
| 31 | auc = np.sum(est) / est.shape[0] |
| 32 | dauc = np.sum(est) / np.sum(oracle) |
| 33 | return est, oracle, cc, auc, dauc |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |