estimateGaussian.m
mu = mean(X); sigma2 = var(X,opt=1);
selectThreshold
predictions = (pval < epsilon); truePositives = sum((predictions == 1) & (yval == 1)); falsePositives = sum((predictions == 1) & (yval == 0)); falseNegatives = sum((predictions == 0) & (yval == 1)); precision = truePositives / (truePositives + falsePositives); recall = truePositives / (truePositives + falseNegatives); F1 = (2 * precision * recall) / (precision + recall);
cofiCostFunc.m
errors = (X*Theta' - Y) .* R; regularizationTheta = lambda/2 * sum(sum(Theta.^2)); regularizationX = lambda/2 * sum(sum(X.^2)); J = 1/2 * sum(sum(errors .^2)) + regularizationTheta + regularizationX; X_grad = errors * Theta + lambda * X; Theta_grad = errors' * X + lambda * Theta;