Commits

Dhananjay Nene committed 52f0bb5

Solved parts 1 & 2 of exercise 8 (anomaly detection)

  • Participants
  • Parent commits 0e0f7d1

Comments (0)

Files changed (2)

exercise-8/octave/estimateGaussian.m

 %               should contain variance of the i-th feature.
 %
 
-
-
-
-
-
-
-
-
-
+mu = sum(X)/size(X,1);
+sigma2 = sum((X - repmat(mu,size(X,1),1)) .^2) / size(X,1)
 % =============================================================
 
 

exercise-8/octave/selectThreshold.m

     %               
     % Note: You can use predictions = (pval < epsilon) to get a binary vector
     %       of 0's and 1's of the outlier predictions
-
-
-
+    pred = pval < epsilon;;
+    tp = sum((pred == 1) & (yval == 1));
+    fp = sum((pred == 1) & (yval == 0));
+    fn = sum((pred == 0) & (yval == 1));
+    prec = tp / (tp + fp);
+    rec = tp / (tp + fn);
+    f1 = 2 * prec * rec / (prec + rec);
+    if (f1 > bestF1)
+        bestF1 = f1;
+	bestEpsilon = epsilon;
+    endif