estimateGaussian.m
mu = 1/m * sum(X); sigma2 = 1/m * sum((X - repmat(mu, m, 1)).^2);
selectThreshold.m
predictions = (pval < epsilon); fp = sum((predictions == 1) & (yval == 0)); fn = sum((predictions == 0) & (yval == 1)); tp = sum((predictions == 1) & (yval == 1)); prec = tp/(tp+fp); rec = tp/(tp+fn); F1 = 2 * prec * rec / (prec + rec);
cofiCostFunc.m
temp = (X*Theta‘).*R; J = sum( sum( (temp - Y.*R).^2) )/2.0 + (lambda/2) * ( sum(sum( X.^2 )) + sum(sum( Theta.^2 )) ); % J = sum( sum( (temp - Y.*R).^2) )/2.0 + (lambda/2) * ( sum(sum( X.^2 )) + sum(sum( Theta.^2 )) ) ; X_grad = (temp - Y.*R) * Theta + lambda * X; Theta_grad = (temp - Y.*R)‘ * X + lambda * Theta;
原文地址:https://www.cnblogs.com/xingkongyihao/p/8438367.html
时间: 2024-10-14 01:23:43