MCPcopy Create free account
hub / github.com/EdwardRaff/JSAT / getM_Bar_for_w0

Method getM_Bar_for_w0

JSAT/src/jsat/classifiers/linear/NewGLMNET.java:839–882  ·  view source on GitHub ↗

When we perform a warm start, we want to train to the same point that we would have if we had not done a warm start. But our stopping point is based on the initial relative error. To get around that, this method computes what the error would have been for the zero weight vector @param n @param l @pa

(int n, int l, List<Vec> columnsOfX, double[] col_neg_class_sum, double col_neg_class_sum_bias)

Source from the content-addressed store, hash-verified

837 * @return the error for M_bar that would have been computed if we were using the zero weight vector
838 */
839 private double getM_Bar_for_w0(int n, int l, List<Vec> columnsOfX, double[] col_neg_class_sum, double col_neg_class_sum_bias)
840 {
841 /**
842 * if w=0, then D_part[i] = 0.5 for all i
843 */
844 final double D_part_i = 0.5;
845
846
847 //algo 3, Step 1.
848 double M_bar = 0;
849 //algo 3, Step 2.
850 for(int j = 0; j < n; j++)
851 {
852 final double w_j = 0;
853
854 //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k)
855 double delta_j_L = -columnsOfX.get(j).sum()*0.5;
856
857 delta_j_L = /* (l2w * w_j) not needed b/c w_j=0*/ + C * (delta_j_L + col_neg_class_sum[j]);
858
859 double deltaS_j_fw;
860 //only the w_j = 0 case applies, b/c that is what this method is for!
861 //w_j = 0
862 deltaS_j_fw = signum(delta_j_L) * max(abs(delta_j_L) - alpha, 0);
863 //done with step 2, we have all the info
864 M_bar += abs(deltaS_j_fw);
865
866 }
867
868 if (useBias)
869 {
870 //2.1. Calculate H^k_{jj}, ∇_j L(w^k) and ∇^S_j f(w^k)
871 double delta_j_L = 0;
872
873 for (int i = 0; i < l; i++)//all have an implicit bias term
874 delta_j_L += -D_part_i;
875 delta_j_L = C * (delta_j_L + col_neg_class_sum_bias);
876
877 double deltaS_j_fw = delta_j_L;
878
879 M_bar += abs(deltaS_j_fw);
880 }
881 return M_bar;
882 }
883
884
885

Callers 1

trainMethod · 0.95

Calls 3

sumMethod · 0.45
getMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected