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

Method testB

test/com/winvector/logistic/TestLogM.java:61–81  ·  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

59 *
60 */
61 public void testB() {
62 final double[][] dat = {
63 /// x1 x2 y
64 { 1, 0, 1 },
65 { 1, 1, 1 },
66 { 0, 1, 0 }
67 };
68 final RExample ex = new RExample(dat);
69 final Newton nwt = new Newton();
70 final double reg = 0.1;
71 final SigmoidLossMultinomial sigmoidLoss = new SigmoidLossMultinomial(ex.dim,2);
72 final VectorFn sl = NormPenalty.addPenalty(new DataFn<ExampleRow>(new SigmoidLossMultinomial(ex.dim,2),ex),reg,null);
73 final double[] x0 = new double[sl.dim()];
74 final VEval opt = nwt.maximize(sl,x0,10);
75 //System.out.println("x(" + reg + "): " + opt.x);
76 final double accuracy = HelperFns.accuracy(sigmoidLoss,ex,opt.x);
77 assertTrue(accuracy>=1.0);
78 for(int i=0;i<opt.x.length;++i) {
79 assertTrue(Math.abs(opt.x[i])<5.0);
80 }
81 }
82
83}

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