风过蔷薇

导航

 

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;  

 

 

posted on 2018-02-18 16:30  风过蔷薇  阅读(135)  评论(0编辑  收藏  举报