Package ivory.regression.cikm2010

Source Code of ivory.regression.cikm2010.Gov2_Desc_Indep

package ivory.regression.cikm2010;

import ivory.core.eval.Qrels;
import ivory.regression.GroundTruth;
import ivory.regression.GroundTruth.Metric;
import ivory.smrf.retrieval.Accumulator;
import ivory.smrf.retrieval.BatchQueryRunner;

import java.util.HashMap;
import java.util.Map;

import junit.framework.JUnit4TestAdapter;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.log4j.Logger;
import org.junit.Test;


import edu.umd.cloud9.collection.DocnoMapping;

/* Note: different metrics are optimized separately */

public class Gov2_Desc_Indep {

  private static final Logger sLogger = Logger.getLogger(Gov2_Desc_Indep.class);

  private static String[] x10_rawAP = new String[] {
          "776", "0.0770", "777", "0.2158", "778", "0.0656", "779", "0.3234", "780", "0.0111",
          "781", "0.2217", "782", "0.3502", "783", "0.0994", "784", "0.4714", "785", "0.4545",
          "786", "0.0826", "787", "0.5253", "788", "0.4860", "789", "0.2285", "790", "0.1103",
          "791", "0.4690", "792", "0.0244", "793", "0.3483", "794", "0.1283", "795", "0.0268",
          "796", "0.5149", "797", "0.3709", "798", "0.1858", "799", "0.1438", "800", "0.0540",
          "801", "0.6059", "802", "0.0343", "803", "0.0000", "804", "0.4803", "805", "0.2597",
          "806", "0.0251", "807", "0.6142", "808", "0.4899", "809", "0.2572", "810", "0.0580",
          "811", "0.0241", "812", "0.2241", "813", "0.2084", "814", "0.1889", "815", "0.1963",
          "816", "0.7846", "817", "0.2342", "818", "0.4420", "819", "0.3462", "820", "0.7693",
          "821", "0.0885", "822", "0.1109", "823", "0.4628", "824", "0.2718", "825", "0.0640",
          "826", "0.1732", "827", "0.4823", "828", "0.4307", "829", "0.0008", "830", "0.0395",
          "831", "0.0053", "832", "0.0146", "833", "0.1649", "834", "0.5392", "835", "0.5025",
          "836", "0.2190", "837", "0.0223", "838", "0.3427", "839", "0.6069", "840", "0.1740",
          "841", "0.2755", "842", "0.2587", "843", "0.3614", "844", "0.0251", "845", "0.3093",
          "846", "0.1984", "847", "0.2500", "848", "0.0193", "849", "0.0092", "850", "0.1336" };

  private static String[] x15_rawAP = new String[] {
          "776", "0.2287", "777", "0.2798", "778", "0.0859", "779", "0.3188", "780", "0.0133",
          "781", "0.1892", "782", "0.4154", "783", "0.0818", "784", "0.4762", "785", "0.4853",
          "786", "0.1413", "787", "0.5756", "788", "0.5469", "789", "0.3024", "790", "0.1366",
          "791", "0.4927", "792", "0.0056", "793", "0.3521", "794", "0.1166", "795", "0.0261",
          "796", "0.5268", "797", "0.3846", "798", "0.2269", "799", "0.2241", "800", "0.1646",
          "801", "0.6171", "802", "0.3204", "803", "0.0001", "804", "0.4749", "805", "0.1852",
          "806", "0.0512", "807", "0.5732", "808", "0.5464", "809", "0.2113", "810", "0.2923",
          "811", "0.0512", "812", "0.2306", "813", "0.2191", "814", "0.5576", "815", "0.1311",
          "816", "0.8073", "817", "0.2288", "818", "0.4945", "819", "0.5783", "820", "0.7422",
          "821", "0.1904", "822", "0.1248", "823", "0.5087", "824", "0.2685", "825", "0.0750",
          "826", "0.2731", "827", "0.4476", "828", "0.3805", "829", "0.0234", "830", "0.1503",
          "831", "0.0131", "832", "0.0177", "833", "0.3385", "834", "0.5362", "835", "0.5097",
          "836", "0.2240", "837", "0.0381", "838", "0.3918", "839", "0.4813", "840", "0.1494",
          "841", "0.3425", "842", "0.2470", "843", "0.5051", "844", "0.3644", "845", "0.2231",
          "846", "0.1195", "847", "0.3929", "848", "0.0406", "849", "0.0180", "850", "0.1631" };

  private static String[] x20_rawAP = new String[] {
          "776", "0.2223", "777", "0.2582", "778", "0.0938", "779", "0.3453", "780", "0.0158",
          "781", "0.2302", "782", "0.6642", "783", "0.0818", "784", "0.4762", "785", "0.5184",
          "786", "0.3148", "787", "0.5673", "788", "0.4990", "789", "0.2252", "790", "0.1382",
          "791", "0.4900", "792", "0.2086", "793", "0.3354", "794", "0.1383", "795", "0.0254",
          "796", "0.5277", "797", "0.4789", "798", "0.2297", "799", "0.2631", "800", "0.2177",
          "801", "0.6036", "802", "0.3267", "803", "0.0001", "804", "0.4768", "805", "0.1871",
          "806", "0.0723", "807", "0.5689", "808", "0.5822", "809", "0.1173", "810", "0.3341",
          "811", "0.0429", "812", "0.2162", "813", "0.3098", "814", "0.6503", "815", "0.1194",
          "816", "0.8456", "817", "0.2864", "818", "0.5401", "819", "0.3889", "820", "0.7353",
          "821", "0.2344", "822", "0.1218", "823", "0.5330", "824", "0.2254", "825", "0.0920",
          "826", "0.3385", "827", "0.4588", "828", "0.3662", "829", "0.0477", "830", "0.1235",
          "831", "0.0443", "832", "0.0217", "833", "0.4207", "834", "0.5607", "835", "0.5499",
          "836", "0.1538", "837", "0.0555", "838", "0.2642", "839", "0.3925", "840", "0.1357",
          "841", "0.3473", "842", "0.2628", "843", "0.5485", "844", "0.2341", "845", "0.2717",
          "846", "0.1163", "847", "0.4510", "848", "0.0375", "849", "0.1750", "850", "0.1545" };

  private static String[] x25_rawAP = new String[] {
          "776", "0.2479", "777", "0.2773", "778", "0.1479", "779", "0.3406", "780", "0.0119",
          "781", "0.2444", "782", "0.6401", "783", "0.0807", "784", "0.4762", "785", "0.5897",
          "786", "0.3196", "787", "0.5754", "788", "0.5406", "789", "0.2249", "790", "0.1254",
          "791", "0.4848", "792", "0.2173", "793", "0.3284", "794", "0.1452", "795", "0.0255",
          "796", "0.5341", "797", "0.4906", "798", "0.2324", "799", "0.2738", "800", "0.2331",
          "801", "0.6179", "802", "0.2897", "803", "0.0010", "804", "0.4607", "805", "0.1880",
          "806", "0.0707", "807", "0.5482", "808", "0.6576", "809", "0.1203", "810", "0.3341",
          "811", "0.0406", "812", "0.3036", "813", "0.3194", "814", "0.4832", "815", "0.1214",
          "816", "0.8338", "817", "0.2923", "818", "0.5166", "819", "0.3608", "820", "0.7428",
          "821", "0.2019", "822", "0.1127", "823", "0.5573", "824", "0.2574", "825", "0.0968",
          "826", "0.3380", "827", "0.4711", "828", "0.3964", "829", "0.0677", "830", "0.1715",
          "831", "0.0438", "832", "0.0331", "833", "0.4207", "834", "0.5397", "835", "0.5553",
          "836", "0.1685", "837", "0.0530", "838", "0.2639", "839", "0.3989", "840", "0.1412",
          "841", "0.3637", "842", "0.3500", "843", "0.5917", "844", "0.2095", "845", "0.3168",
          "846", "0.1163", "847", "0.4633", "848", "0.0447", "849", "0.2566", "850", "0.1678" };

  private static String[] x30_rawAP = new String[] {
          "776", "0.2389", "777", "0.2761", "778", "0.1854", "779", "0.3401", "780", "0.0114",
          "781", "0.2437", "782", "0.6401", "783", "0.0810", "784", "0.4679", "785", "0.6227",
          "786", "0.3202", "787", "0.5751", "788", "0.5406", "789", "0.2361", "790", "0.1305",
          "791", "0.4765", "792", "0.2259", "793", "0.3263", "794", "0.1461", "795", "0.0256",
          "796", "0.5333", "797", "0.5048", "798", "0.2371", "799", "0.2738", "800", "0.2263",
          "801", "0.6152", "802", "0.2806", "803", "0.0009", "804", "0.4659", "805", "0.1928",
          "806", "0.0744", "807", "0.5579", "808", "0.6552", "809", "0.1253", "810", "0.3878",
          "811", "0.0529", "812", "0.3229", "813", "0.3194", "814", "0.4832", "815", "0.1240",
          "816", "0.8133", "817", "0.2759", "818", "0.4916", "819", "0.3608", "820", "0.7615",
          "821", "0.2167", "822", "0.1213", "823", "0.5639", "824", "0.2830", "825", "0.1159",
          "826", "0.3323", "827", "0.4613", "828", "0.4141", "829", "0.1229", "830", "0.1766",
          "831", "0.0490", "832", "0.0331", "833", "0.3851", "834", "0.5218", "835", "0.5518",
          "836", "0.1929", "837", "0.0526", "838", "0.2969", "839", "0.4224", "840", "0.1421",
          "841", "0.3892", "842", "0.3394", "843", "0.6061", "844", "0.2195", "845", "0.3602",
          "846", "0.1254", "847", "0.4483", "848", "0.0571", "849", "0.2760", "850", "0.1848" };

  private static String[] x35_rawAP = new String[] {
          "776", "0.2251", "777", "0.2608", "778", "0.1886", "779", "0.3401", "780", "0.0108",
          "781", "0.2376", "782", "0.6298", "783", "0.0767", "784", "0.5298", "785", "0.6454",
          "786", "0.3255", "787", "0.5751", "788", "0.5599", "789", "0.2398", "790", "0.1305",
          "791", "0.4795", "792", "0.2039", "793", "0.3514", "794", "0.1558", "795", "0.0258",
          "796", "0.5256", "797", "0.5057", "798", "0.2272", "799", "0.2423", "800", "0.2231",
          "801", "0.6078", "802", "0.2878", "803", "0.0008", "804", "0.4693", "805", "0.1915",
          "806", "0.0825", "807", "0.5597", "808", "0.6362", "809", "0.1117", "810", "0.3878",
          "811", "0.0654", "812", "0.3746", "813", "0.3180", "814", "0.5046", "815", "0.1435",
          "816", "0.8090", "817", "0.2617", "818", "0.4652", "819", "0.3382", "820", "0.7738",
          "821", "0.2406", "822", "0.1190", "823", "0.5664", "824", "0.2797", "825", "0.1411",
          "826", "0.3773", "827", "0.4534", "828", "0.4138", "829", "0.1295", "830", "0.1848",
          "831", "0.0480", "832", "0.0307", "833", "0.3851", "834", "0.5191", "835", "0.5573",
          "836", "0.2128", "837", "0.0470", "838", "0.3172", "839", "0.4243", "840", "0.1482",
          "841", "0.3872", "842", "0.3707", "843", "0.6061", "844", "0.2910", "845", "0.3617",
          "846", "0.1288", "847", "0.4392", "848", "0.0592", "849", "0.3325", "850", "0.2035" };

  private static String[] x40_rawAP = new String[] {
          "776", "0.2214", "777", "0.2632", "778", "0.1884", "779", "0.3395", "780", "0.0112",
          "781", "0.2342", "782", "0.6345", "783", "0.0741", "784", "0.5298", "785", "0.6358",
          "786", "0.3262", "787", "0.5744", "788", "0.5504", "789", "0.2408", "790", "0.1305",
          "791", "0.4766", "792", "0.1656", "793", "0.3513", "794", "0.1494", "795", "0.0258",
          "796", "0.5263", "797", "0.5051", "798", "0.2203", "799", "0.2585", "800", "0.2193",
          "801", "0.6080", "802", "0.3387", "803", "0.0018", "804", "0.4818", "805", "0.1898",
          "806", "0.0911", "807", "0.5840", "808", "0.6418", "809", "0.1221", "810", "0.4070",
          "811", "0.0683", "812", "0.3833", "813", "0.3292", "814", "0.5149", "815", "0.1498",
          "816", "0.7998", "817", "0.2476", "818", "0.4620", "819", "0.4434", "820", "0.7648",
          "821", "0.2829", "822", "0.1194", "823", "0.5713", "824", "0.2827", "825", "0.1389",
          "826", "0.3839", "827", "0.4516", "828", "0.4125", "829", "0.1312", "830", "0.1834",
          "831", "0.0480", "832", "0.0343", "833", "0.3566", "834", "0.5298", "835", "0.5471",
          "836", "0.2018", "837", "0.0471", "838", "0.2864", "839", "0.3975", "840", "0.1490",
          "841", "0.3851", "842", "0.3726", "843", "0.6111", "844", "0.3437", "845", "0.3365",
          "846", "0.1429", "847", "0.4291", "848", "0.0593", "849", "0.3769", "850", "0.1932" };

  private static String[] x45_rawAP = new String[] {
          "776", "0.2266", "777", "0.2642", "778", "0.1906", "779", "0.3397", "780", "0.0114",
          "781", "0.2296", "782", "0.6333", "783", "0.0679", "784", "0.5214", "785", "0.6299",
          "786", "0.3258", "787", "0.5713", "788", "0.5561", "789", "0.2515", "790", "0.1300",
          "791", "0.4771", "792", "0.1750", "793", "0.3513", "794", "0.1492", "795", "0.0258",
          "796", "0.5244", "797", "0.4953", "798", "0.2208", "799", "0.2209", "800", "0.2156",
          "801", "0.6057", "802", "0.3817", "803", "0.0018", "804", "0.4932", "805", "0.1896",
          "806", "0.0917", "807", "0.6289", "808", "0.6436", "809", "0.1406", "810", "0.4070",
          "811", "0.0604", "812", "0.3733", "813", "0.3255", "814", "0.5281", "815", "0.1506",
          "816", "0.7958", "817", "0.3159", "818", "0.4623", "819", "0.4651", "820", "0.7592",
          "821", "0.2995", "822", "0.1190", "823", "0.5739", "824", "0.2818", "825", "0.1496",
          "826", "0.3877", "827", "0.4378", "828", "0.4098", "829", "0.1369", "830", "0.1848",
          "831", "0.0479", "832", "0.0339", "833", "0.3566", "834", "0.5337", "835", "0.5647",
          "836", "0.1952", "837", "0.0465", "838", "0.2463", "839", "0.3953", "840", "0.1548",
          "841", "0.3893", "842", "0.3724", "843", "0.5981", "844", "0.3825", "845", "0.3231",
          "846", "0.1398", "847", "0.4299", "848", "0.0603", "849", "0.4072", "850", "0.1899" };

  private static String[] x50_rawAP = new String[] {
          "776", "0.2280", "777", "0.2657", "778", "0.1923", "779", "0.3393", "780", "0.0117",
          "781", "0.2319", "782", "0.6333", "783", "0.0731", "784", "0.5214", "785", "0.6296",
          "786", "0.3236", "787", "0.5713", "788", "0.5561", "789", "0.2714", "790", "0.1297",
          "791", "0.4754", "792", "0.1710", "793", "0.3502", "794", "0.1497", "795", "0.0258",
          "796", "0.5245", "797", "0.4876", "798", "0.2230", "799", "0.2209", "800", "0.2191",
          "801", "0.6025", "802", "0.4074", "803", "0.0017", "804", "0.4950", "805", "0.1891",
          "806", "0.0948", "807", "0.6386", "808", "0.6520", "809", "0.1287", "810", "0.4070",
          "811", "0.0648", "812", "0.3668", "813", "0.3255", "814", "0.5330", "815", "0.1491",
          "816", "0.7955", "817", "0.3679", "818", "0.4544", "819", "0.4651", "820", "0.7647",
          "821", "0.3019", "822", "0.1208", "823", "0.5730", "824", "0.2804", "825", "0.1712",
          "826", "0.3990", "827", "0.4339", "828", "0.4087", "829", "0.1363", "830", "0.1880",
          "831", "0.0503", "832", "0.0323", "833", "0.3566", "834", "0.5296", "835", "0.5645",
          "836", "0.1966", "837", "0.0459", "838", "0.2519", "839", "0.3948", "840", "0.1600",
          "841", "0.3883", "842", "0.3741", "843", "0.5981", "844", "0.4014", "845", "0.3289",
          "846", "0.1412", "847", "0.4255", "848", "0.0621", "849", "0.4072", "850", "0.1865" };

  @Test
  public void runRegression() throws Exception {
    Map<String, GroundTruth> g = new HashMap<String, GroundTruth>();

    g.put("indep-x1.0", new GroundTruth("indep-x1.0", Metric.AP, 75, x10_rawAP, 0.2505f));
    g.put("indep-x1.5", new GroundTruth("indep-x1.5", Metric.AP, 75, x15_rawAP, 0.2889f));
    g.put("indep-x2.0", new GroundTruth("indep-x2.0", Metric.AP, 75, x20_rawAP, 0.3028f));
    g.put("indep-x2.5", new GroundTruth("indep-x2.5", Metric.AP, 75, x25_rawAP, 0.3104f));
    g.put("indep-x3.0", new GroundTruth("indep-x3.0", Metric.AP, 75, x30_rawAP, 0.3161f));
    g.put("indep-x3.5", new GroundTruth("indep-x3.5", Metric.AP, 75, x35_rawAP, 0.3211f));
    g.put("indep-x4.0", new GroundTruth("indep-x4.0", Metric.AP, 75, x40_rawAP, 0.3238f));
    g.put("indep-x4.5", new GroundTruth("indep-x4.5", Metric.AP, 75, x45_rawAP, 0.3263f));
    g.put("indep-x5.0", new GroundTruth("indep-x5.0", Metric.AP, 75, x50_rawAP, 0.3285f));

    Qrels qrels = new Qrels("data/gov2/qrels.gov2.all");

    String[] params = new String[] {
            "data/gov2/run.gov2.CIKM2010.desc.indep.xml",
            "data/gov2/gov2.desc.776-850" };

    FileSystem fs = FileSystem.getLocal(new Configuration());

    BatchQueryRunner qr = new BatchQueryRunner(params, fs);

    long start = System.currentTimeMillis();
    qr.runQueries();
    long end = System.currentTimeMillis();

    sLogger.info("Total query time: " + (end - start) + "ms");

    DocnoMapping mapping = qr.getDocnoMapping();

    for (String model : qr.getModels()) {
      sLogger.info("Verifying results of model \"" + model + "\"");

      Map<String, Accumulator[]> results = qr.getResults(model);
      g.get(model).verify(results, mapping, qrels);

      sLogger.info("Done!");
    }
  }

  public static junit.framework.Test suite() {
    return new JUnit4TestAdapter(Gov2_Desc_Indep.class);
  }
}
TOP

Related Classes of ivory.regression.cikm2010.Gov2_Desc_Indep

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.