📄 yababoosttest.java
字号:
package jboost.booster;import jboost.examples.Label;/** * @author Aaron Arvey * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */public class YabaBoostTest extends AbstractBoosterTest { YabaBoost m_yabaBoost; /** * Constructor for YabaBoostTest. * @param arg0 */ public YabaBoostTest(String arg0) { super(arg0); } /** * Tests the YabaBoost constructor and sets up boosters for * other tests. * @see TestCase#setUp() */ protected void setUp() throws Exception { //TODO Implement addExample(). } final public void testAddExample() { //TODO Implement addExample(). } final public void testFinalizeData() { //TODO Implement finalizeData(). } final public void testClear() { //TODO Implement clear(). } /* * Test for Bag newBag(int[]) */ final public void testNewBagintArray() { //TODO Implement newBag(). } /* * Test for Bag newBag() */ final public void testNewBag() { //TODO Implement newBag(). } /* * Test for Bag newBag(Bag) */ final public void testNewBagBag() { //TODO Implement newBag(). } /** * This test indicates whether or not the update algorithm in * YabaBoost is producing the correct weights. This is the core * of the YabaBoost algorithm and is thus the most important to test. */ public final void testUpdate() { //TODO Implement update(). // fill in booster int[] indices= new int[COUNT]; int[] ones= new int[COUNT/2]; int[] zeroes= new int[COUNT/2]; for (int i=0; i < COUNT/2; i++) { m_yabaBoost.addExample(i, new Label(0)); indices[i]= i; zeroes[i]= i; } for (int i=COUNT/2, j=0; i < COUNT; i++, j++) { m_yabaBoost.addExample(i, new Label(1)); indices[i]= i; ones[j]= i; } /* m_yabaBoost.finalizeData(); Prediction p1= m_yabaBoost.getPrediction(m_yabaBoost.newBag(zeroes)); m_yabaBoost.update(new Prediction[] {p1}, new int[][] {zeroes}); for (int i=0; i < zeroes.length; i++) { zeroes[i]= indices[COUNT/2 + i]; for (int j=0; j < zeroes.length; j++) { int index= zeroes[j]; double weight= m_yabaBoost.m_weights[index]; double margin= m_yabaBoost.m_oldMargins[index]; double s = m_yabaBoost.m_oldS; double c = m_yabaBoost.m_c; if(Double.isNaN(weight)){ System.err.println("Warning: weight is NaN!"); assertEquals(-1,1,0.0001); continue; } assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.00001); } } for (int i=0; i < ones.length; i++) { ones[i]= indices[COUNT/2 + i]; Prediction p1= m_yabaBoost.getPrediction(m_yabaBoost.newBag(ones)); m_yabaBoost.update(new Prediction[] {p1}, new int[][] {ones}); for (int j=0; j < ones.length; j++) { int index= ones[j]; double weight= m_yabaBoost.m_weights[index]; double margin= m_yabaBoost.m_oldMargins[index]; double s = m_yabaBoost.m_oldS; double c = m_yabaBoost.m_c; if(Double.isNaN(weight)){ System.err.println("Warning: weight is NaN!"); continue; } assertEquals(weight, Math.exp(-Math.pow(margin+s,2)/c), 0.00001); } } */ } final public void testGetPredictions() { //TODO Implement getPredictions(). } final public void testGetTheoryBound() { //TODO Implement getTheoryBound(). } final public void testGetMargins() { //TODO Implement getMargins(). } /* * Test for void YabaBoost() * Not yet implemented. */ final public void testYabaBoost() { //TODO Implement YabaBoost(). } /* * Test for void YabaBoost(double) * Not yet implemented. */ final public void testYabaBoostdouble() { //TODO Implement YabaBoost(). } final public void testGetPrediction() { //TODO Implement getPrediction(). }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -