Attachment 'sheet12.m'

Download

   1 function sheet12
   2 % ROC-curves
   3 
   4 sheet12_data % loads X, Y, Y1 and Y2
   5 
   6 % plot the data
   7 figure(1)
   8 plot(X(Y == 1, 1), X(Y == 1, 2), 'r+', ...
   9      X(Y == -1, 1), X(Y == -1, 2), 'bo');
  10 legend('positive', 'negative');
  11 
  12 % plot the first Ys
  13 figure(2)
  14 scatter(X(:, 1), X(:, 2), 20, Y1, 'filled');
  15 title('predicitons 1')
  16 
  17 figure(3)
  18 scatter(X(:, 1), X(:, 2), 20, Y2, 'filled');
  19 title('predicitons 2')
  20 
  21 figure(4)
  22 [FPR1, TPR1] = roc_curve(Y, Y1);
  23 [FPR2, TPR2] = roc_curve(Y, Y2);
  24 title('ROC')
  25 plot(FPR1, TPR1, 'r-', FPR2, TPR2, 'b-')
  26 legend('1', '2');
  27 xlabel('false positive rate')
  28 ylabel('true positive rate')
  29 
  30 figure(5)
  31 [P1, R1] = pr_curve(Y, Y1);
  32 [P2, R2] = pr_curve(Y, Y2);
  33 title('ROC')
  34 plot(P1, R1, 'r-', P2, R2, 'b-')
  35 legend('1', '2');
  36 xlabel('precision');
  37 ylabel('recall');
  38 
  39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40 %
  41 % Your solutions below
  42 
  43 % 1a. count the number of false positives. Yt are the true labels, Yp are the
  44 % predicted ones.
  45 function N = fp(Yt, Yp)
  46 % ...
  47 
  48 % 1b. count the number of true positives.
  49 function N = tp(Yt, Yp)
  50 % ...
  51 
  52 % 1c. count the number of false negatives.
  53 function N = fn(Yt, Yp)
  54 % ...
  55 
  56 % 1d. count the number of true negatives.
  57 function N = tn(Yt, Yp)
  58 % ...
  59 
  60 % 2a. compute the false positive rate between Yt and Yp, where Yt are the
  61 % true labels and Yp are the predicted labels.
  62 function R = fpr(Yt, Yp)
  63 % ...
  64 
  65 % 2b. compute the true positive rate
  66 function R = tpr(Yt, Yp)
  67 % ...
  68 
  69 % 2c. compute the precision
  70 function R = precision(Yt, Yp)
  71 % ...
  72 
  73 % 2d. compute the recall
  74 function R = recall(Yt, Yp)
  75 % ...
  76 
  77 % 3a. Compute the values for the roc-curve
  78 function [FPR, TPR] = roc_curve(Yt, Yp)
  79 % ...
  80 
  81 % 3b. compute the values for the precision-recall curve
  82 function [P, R] = pr_curve(Yt, Yp)
  83 % ...

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2009-03-12 14:03:18, 318.2 KB) [[attachment:BayesianDecisionTheory.pdf]]
  • [get | view] (2009-03-12 14:03:18, 247.3 KB) [[attachment:crossvalidation.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1740.8 KB) [[attachment:mlintro.pdf]]
  • [get | view] (2009-03-12 14:03:18, 665.3 KB) [[attachment:probtheo.pdf]]
  • [get | view] (2009-03-12 14:03:18, 52.7 KB) [[attachment:sheet01.pdf]]
  • [get | view] (2009-03-12 14:03:18, 61.7 KB) [[attachment:sheet02.pdf]]
  • [get | view] (2009-03-12 14:03:18, 65.8 KB) [[attachment:sheet03.pdf]]
  • [get | view] (2009-03-12 14:03:18, 2.1 KB) [[attachment:sheet04.m]]
  • [get | view] (2009-03-12 14:03:18, 80.3 KB) [[attachment:sheet04.pdf]]
  • [get | view] (2009-03-12 14:03:18, 106.7 KB) [[attachment:sheet05.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1.6 KB) [[attachment:sheet05_01.m]]
  • [get | view] (2009-03-12 14:03:18, 1.6 KB) [[attachment:sheet05_02.m]]
  • [get | view] (2009-03-12 14:03:18, 0.8 KB) [[attachment:sheet06.m]]
  • [get | view] (2009-03-12 14:03:18, 93.2 KB) [[attachment:sheet06.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1.4 KB) [[attachment:sheet07.m]]
  • [get | view] (2009-03-12 14:03:18, 100.6 KB) [[attachment:sheet07.pdf]]
  • [get | view] (2009-03-12 14:03:18, 2.7 KB) [[attachment:sheet08.m]]
  • [get | view] (2009-03-12 14:03:18, 85.4 KB) [[attachment:sheet08.pdf]]
  • [get | view] (2009-03-12 14:03:18, 45.2 KB) [[attachment:sheet09.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1.5 KB) [[attachment:sheet10.m]]
  • [get | view] (2009-03-12 14:03:18, 59.4 KB) [[attachment:sheet10.pdf]]
  • [get | view] (2009-03-12 14:03:18, 3.0 KB) [[attachment:sheet11.m]]
  • [get | view] (2009-03-12 14:03:18, 68.6 KB) [[attachment:sheet11.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1.7 KB) [[attachment:sheet12.m]]
  • [get | view] (2009-03-12 14:03:18, 62.6 KB) [[attachment:sheet12.pdf]]
  • [get | view] (2009-03-12 14:03:18, 2.4 KB) [[attachment:sheet12_data.m]]
  • [get | view] (2009-03-12 14:03:18, 63.1 KB) [[attachment:sheet13.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1.6 KB) [[attachment:sheet14.m]]
  • [get | view] (2009-03-12 14:03:18, 73.7 KB) [[attachment:sheet14.pdf]]
  • [get | view] (2009-03-12 14:03:18, 4.8 KB) [[attachment:sheet14_data.m]]
  • [get | view] (2009-03-12 14:03:18, 120.2 KB) [[attachment:summary.pdf]]
  • [get | view] (2009-03-12 14:03:18, 1505.5 KB) [[attachment:vl_ica_tub-08.pdf]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.