MCPcopy Index your code
hub / github.com/WinVector/Logistic / testB

Method testB

test/com/winvector/logistic/TestLog1.java:142–162  ·  view source on GitHub ↗

chosen to run to infinity > dat <- read.table('exB.txt',header=T,sep='\t') > model <- glm(y~x1+x2,family=binomial(link='logit'),data=dat) > predict(model,type='response') R soln: 23.56607 23.56607 -23.56607 reg(0.1) soln: x(0.1): 1 x 3 matrix -0.337079 2.215088 -0.642055

()

Source from the content-addressed store, hash-verified

140 *
141 */
142 public void testB() {
143 final double[][] dat = {
144 /// x1 x2 y
145 { 1, 0, 1 },
146 { 1, 1, 1 },
147 { 0, 1, 0 }
148 };
149 final RExample ex = new RExample(dat);
150 final Newton nwt = new Newton();
151 final double reg = 0.1;
152 final SigmoidLossMultinomial sigmoidLoss = new SigmoidLossMultinomial(ex.dim,2);
153 final VectorFn sl = NormPenalty.addPenalty(new DataFn<ExampleRow>(new SigmoidLossMultinomial(ex.dim,2),ex),reg,null);
154 final double[] x0 = new double[sl.dim()];
155 final VEval opt = nwt.maximize(sl,x0,10);
156 final double accuracy = HelperFns.accuracy(sigmoidLoss,ex,opt.x);
157 assertTrue(accuracy>=1.0);
158 for(int i=0;i<opt.x.length;++i) {
159 assertTrue(Math.abs(opt.x[i])<5.0);
160 }
161 //System.out.println("x(" + reg + "): " + opt.x);
162 }
163
164}

Callers

nothing calls this directly

Calls 4

addPenaltyMethod · 0.95
dimMethod · 0.95
maximizeMethod · 0.95
accuracyMethod · 0.95

Tested by

no test coverage detected