Package ivory.regression.cikm2010

Source Code of ivory.regression.cikm2010.Gov2_Title_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_Title_Indep {

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

  private static String[] x10_rawAP = new String[] {
      "776", "0.1036", "777", "0.2731", "778", "0.0008", "779", "0.4906", "780", "0.3330",
      "781", "0.4149", "782", "0.3552", "783", "0.0318", "784", "0.3405", "785", "0.2441",
      "786", "0.1079", "787", "0.3409", "788", "0.0044", "789", "0.1257", "790", "0.0635",
      "791", "0.4292", "792", "0.0227", "793", "0.2347", "794", "0.0005", "795", "0.0211",
      "796", "0.1438", "797", "0.4417", "798", "0.0498", "799", "0.1351", "800", "0.0878",
      "801", "0.2672", "802", "0.0083", "803", "0.0000", "804", "0.4767", "805", "0.0208",
      "806", "0.0000", "807", "0.6258", "808", "0.3113", "809", "0.3216", "810", "0.0580",
      "811", "0.0328", "812", "0.3006", "813", "0.2116", "814", "0.1886", "815", "0.1962",
      "816", "0.7020", "817", "0.1613", "818", "0.4584", "819", "0.0003", "820", "0.6650",
      "821", "0.0654", "822", "0.1180", "823", "0.0204", "824", "0.3177", "825", "0.0579",
      "826", "0.1813", "827", "0.3377", "828", "0.0601", "829", "0.0171", "830", "0.0000",
      "831", "0.0341", "832", "0.0616", "833", "0.1649", "834", "0.0845", "835", "0.0000",
      "836", "0.1079", "837", "0.0305", "838", "0.3601", "839", "0.5208", "840", "0.1665",
      "841", "0.1426", "842", "0.0283", "843", "0.0008", "844", "0.0000", "845", "0.1973",
      "846", "0.0000", "847", "0.2599", "848", "0.0261", "849", "0.0106", "850", "0.0350" };

  private static String[] x15_rawAP = new String[] {
      "776", "0.1142", "777", "0.3325", "778", "0.1020", "779", "0.5517", "780", "0.4068",
      "781", "0.3827", "782", "0.4163", "783", "0.0206", "784", "0.4464", "785", "0.3909",
      "786", "0.3822", "787", "0.6320", "788", "0.4808", "789", "0.1239", "790", "0.5352",
      "791", "0.4631", "792", "0.0054", "793", "0.2628", "794", "0.0555", "795", "0.0278",
      "796", "0.2090", "797", "0.5745", "798", "0.0561", "799", "0.2244", "800", "0.0869",
      "801", "0.2476", "802", "0.0857", "803", "0.0000", "804", "0.4788", "805", "0.0566",
      "806", "0.0162", "807", "0.6245", "808", "0.6711", "809", "0.3362", "810", "0.3049",
      "811", "0.2248", "812", "0.4928", "813", "0.2193", "814", "0.6697", "815", "0.1914",
      "816", "0.8125", "817", "0.2897", "818", "0.4001", "819", "0.4355", "820", "0.6802",
      "821", "0.1314", "822", "0.0970", "823", "0.2605", "824", "0.3239", "825", "0.0719",
      "826", "0.1801", "827", "0.3411", "828", "0.2346", "829", "0.0734", "830", "0.0479",
      "831", "0.3265", "832", "0.0594", "833", "0.4312", "834", "0.4305", "835", "0.0001",
      "836", "0.1067", "837", "0.0806", "838", "0.2777", "839", "0.4779", "840", "0.1665",
      "841", "0.3152", "842", "0.1177", "843", "0.3495", "844", "0.0220", "845", "0.3983",
      "846", "0.1513", "847", "0.2466", "848", "0.1316", "849", "0.0183", "850", "0.0361" };

  private static String[] x20_rawAP = new String[] {
      "776", "0.2957", "777", "0.3529", "778", "0.1244", "779", "0.5503", "780", "0.4004",
      "781", "0.3906", "782", "0.6623", "783", "0.1417", "784", "0.4644", "785", "0.3731",
      "786", "0.4568", "787", "0.5767", "788", "0.5440", "789", "0.2269", "790", "0.5161",
      "791", "0.4791", "792", "0.2080", "793", "0.3899", "794", "0.0657", "795", "0.0272",
      "796", "0.2344", "797", "0.6005", "798", "0.1891", "799", "0.2563", "800", "0.2256",
      "801", "0.4382", "802", "0.3983", "803", "0.0000", "804", "0.5012", "805", "0.0519",
      "806", "0.0182", "807", "0.6360", "808", "0.7186", "809", "0.3197", "810", "0.3593",
      "811", "0.2683", "812", "0.5860", "813", "0.3071", "814", "0.7069", "815", "0.1884",
      "816", "0.8190", "817", "0.3777", "818", "0.3667", "819", "0.5849", "820", "0.7660",
      "821", "0.1745", "822", "0.0990", "823", "0.3226", "824", "0.3346", "825", "0.0265",
      "826", "0.2718", "827", "0.4100", "828", "0.2611", "829", "0.0836", "830", "0.0579",
      "831", "0.4378", "832", "0.1797", "833", "0.4926", "834", "0.4719", "835", "0.0452",
      "836", "0.2094", "837", "0.1119", "838", "0.2948", "839", "0.5515", "840", "0.1626",
      "841", "0.3737", "842", "0.1305", "843", "0.4498", "844", "0.0480", "845", "0.4118",
      "846", "0.2025", "847", "0.3925", "848", "0.1331", "849", "0.1969", "850", "0.2205" };

  private static String[] x25_rawAP = new String[] {
      "776", "0.2929", "777", "0.3523", "778", "0.1244", "779", "0.5528", "780", "0.4004",
      "781", "0.3949", "782", "0.6607", "783", "0.1316", "784", "0.4644", "785", "0.3731",
      "786", "0.4568", "787", "0.5767", "788", "0.5440", "789", "0.2269", "790", "0.5145",
      "791", "0.4760", "792", "0.2160", "793", "0.3899", "794", "0.0657", "795", "0.0273",
      "796", "0.2367", "797", "0.6005", "798", "0.1723", "799", "0.2540", "800", "0.2273",
      "801", "0.4355", "802", "0.3795", "803", "0.0000", "804", "0.5012", "805", "0.0624",
      "806", "0.0182", "807", "0.6526", "808", "0.7175", "809", "0.3327", "810", "0.3593",
      "811", "0.2683", "812", "0.6011", "813", "0.3095", "814", "0.7069", "815", "0.2007",
      "816", "0.8190", "817", "0.3724", "818", "0.3614", "819", "0.5849", "820", "0.7684",
      "821", "0.2275", "822", "0.0953", "823", "0.3618", "824", "0.3357", "825", "0.0384",
      "826", "0.3113", "827", "0.4105", "828", "0.2611", "829", "0.0873", "830", "0.0579",
      "831", "0.4168", "832", "0.1458", "833", "0.4926", "834", "0.4967", "835", "0.0452",
      "836", "0.2093", "837", "0.1119", "838", "0.2952", "839", "0.5656", "840", "0.1626",
      "841", "0.3789", "842", "0.1305", "843", "0.4498", "844", "0.0480", "845", "0.4126",
      "846", "0.2025", "847", "0.4029", "848", "0.1297", "849", "0.2533", "850", "0.2207" };

  private static String[] x30_rawAP = new String[] {
      "776", "0.2929", "777", "0.3540", "778", "0.1639", "779", "0.5549", "780", "0.4108",
      "781", "0.3844", "782", "0.6498", "783", "0.1316", "784", "0.4644", "785", "0.4033",
      "786", "0.4477", "787", "0.5769", "788", "0.5785", "789", "0.2244", "790", "0.5131",
      "791", "0.4760", "792", "0.2160", "793", "0.4003", "794", "0.1138", "795", "0.0272",
      "796", "0.2376", "797", "0.6048", "798", "0.1723", "799", "0.2540", "800", "0.2273",
      "801", "0.4355", "802", "0.3558", "803", "0.0001", "804", "0.5032", "805", "0.0504",
      "806", "0.0513", "807", "0.6622", "808", "0.7353", "809", "0.3045", "810", "0.3936",
      "811", "0.2809", "812", "0.6058", "813", "0.3095", "814", "0.7065", "815", "0.1869",
      "816", "0.8138", "817", "0.3445", "818", "0.3520", "819", "0.6222", "820", "0.7684",
      "821", "0.2544", "822", "0.0979", "823", "0.3720", "824", "0.3357", "825", "0.0415",
      "826", "0.3113", "827", "0.4109", "828", "0.3071", "829", "0.0872", "830", "0.0804",
      "831", "0.3998", "832", "0.1458", "833", "0.4466", "834", "0.5025", "835", "0.0719",
      "836", "0.2093", "837", "0.1132", "838", "0.2952", "839", "0.5530", "840", "0.1626",
      "841", "0.4250", "842", "0.1573", "843", "0.4959", "844", "0.0624", "845", "0.4291",
      "846", "0.2110", "847", "0.4019", "848", "0.1234", "849", "0.2562", "850", "0.2204" };

  private static String[] x35_rawAP = new String[] {
      "776", "0.2886", "777", "0.3587", "778", "0.1639", "779", "0.5549", "780", "0.4108",
      "781", "0.3682", "782", "0.6586", "783", "0.1249", "784", "0.4644", "785", "0.4357",
      "786", "0.4477", "787", "0.5769", "788", "0.5785", "789", "0.2239", "790", "0.4961",
      "791", "0.4760", "792", "0.2056", "793", "0.4003", "794", "0.1138", "795", "0.0272",
      "796", "0.2446", "797", "0.6064", "798", "0.1599", "799", "0.2566", "800", "0.2257",
      "801", "0.4347", "802", "0.3942", "803", "0.0001", "804", "0.5037", "805", "0.0505",
      "806", "0.0513", "807", "0.6676", "808", "0.7408", "809", "0.2929", "810", "0.3936",
      "811", "0.2809", "812", "0.6180", "813", "0.3130", "814", "0.7065", "815", "0.1849",
      "816", "0.7871", "817", "0.4079", "818", "0.3486", "819", "0.6222", "820", "0.7695",
      "821", "0.2741", "822", "0.0945", "823", "0.4064", "824", "0.3362", "825", "0.0439",
      "826", "0.3362", "827", "0.4106", "828", "0.3071", "829", "0.1453", "830", "0.0804",
      "831", "0.3998", "832", "0.1301", "833", "0.4466", "834", "0.5090", "835", "0.1080",
      "836", "0.2120", "837", "0.1132", "838", "0.2939", "839", "0.5543", "840", "0.1626",
      "841", "0.4521", "842", "0.1573", "843", "0.4959", "844", "0.0624", "845", "0.4314",
      "846", "0.2110", "847", "0.3989", "848", "0.1255", "849", "0.3061", "850", "0.2205" };

  private static String[] x40_rawAP = new String[] {
      "776", "0.2860", "777", "0.3594", "778", "0.1933", "779", "0.5548", "780", "0.4158",
      "781", "0.3738", "782", "0.6590", "783", "0.1533", "784", "0.4728", "785", "0.4653",
      "786", "0.4442", "787", "0.5797", "788", "0.5878", "789", "0.2259", "790", "0.4906",
      "791", "0.4769", "792", "0.1790", "793", "0.4146", "794", "0.1461", "795", "0.0272",
      "796", "0.2446", "797", "0.5902", "798", "0.1703", "799", "0.2584", "800", "0.2298",
      "801", "0.4390", "802", "0.4292", "803", "0.0002", "804", "0.5031", "805", "0.0601",
      "806", "0.1141", "807", "0.6713", "808", "0.7386", "809", "0.3105", "810", "0.4041",
      "811", "0.2926", "812", "0.6181", "813", "0.3227", "814", "0.7074", "815", "0.1972",
      "816", "0.8007", "817", "0.4470", "818", "0.3452", "819", "0.6261", "820", "0.7755",
      "821", "0.2776", "822", "0.0902", "823", "0.4202", "824", "0.3362", "825", "0.0455",
      "826", "0.3520", "827", "0.4104", "828", "0.3406", "829", "0.2221", "830", "0.0951",
      "831", "0.4457", "832", "0.1456", "833", "0.4211", "834", "0.5039", "835", "0.1064",
      "836", "0.2103", "837", "0.1119", "838", "0.2760", "839", "0.5676", "840", "0.1626",
      "841", "0.4575", "842", "0.1827", "843", "0.5260", "844", "0.0800", "845", "0.4331",
      "846", "0.2195", "847", "0.3930", "848", "0.1267", "849", "0.3568", "850", "0.2233" };

  private static String[] x45_rawAP = new String[] {
      "776", "0.2708", "777", "0.3627", "778", "0.1933", "779", "0.5550", "780", "0.4158",
      "781", "0.3814", "782", "0.6613", "783", "0.1766", "784", "0.4728", "785", "0.4653",
      "786", "0.4442", "787", "0.5797", "788", "0.5878", "789", "0.2258", "790", "0.4820",
      "791", "0.4769", "792", "0.1756", "793", "0.4146", "794", "0.1461", "795", "0.0272",
      "796", "0.2466", "797", "0.5902", "798", "0.1676", "799", "0.2643", "800", "0.2316",
      "801", "0.4413", "802", "0.4467", "803", "0.0002", "804", "0.5026", "805", "0.0678",
      "806", "0.1141", "807", "0.6721", "808", "0.7265", "809", "0.3243", "810", "0.4041",
      "811", "0.2926", "812", "0.6253", "813", "0.3277", "814", "0.7074", "815", "0.2047",
      "816", "0.8007", "817", "0.4517", "818", "0.3428", "819", "0.6261", "820", "0.7769",
      "821", "0.2699", "822", "0.0890", "823", "0.4319", "824", "0.3365", "825", "0.0551",
      "826", "0.3873", "827", "0.4188", "828", "0.3406", "829", "0.2209", "830", "0.0951",
      "831", "0.5031", "832", "0.1467", "833", "0.4211", "834", "0.5085", "835", "0.1053",
      "836", "0.2078", "837", "0.1119", "838", "0.2609", "839", "0.5808", "840", "0.1626",
      "841", "0.4603", "842", "0.1827", "843", "0.5260", "844", "0.0800", "845", "0.4416",
      "846", "0.2195", "847", "0.3931", "848", "0.1223", "849", "0.3785", "850", "0.2241" };

  private static String[] x50_rawAP = new String[] {
      "776", "0.2708", "777", "0.3563", "778", "0.1933", "779", "0.5550", "780", "0.4158",
      "781", "0.3814", "782", "0.6613", "783", "0.1766", "784", "0.4728", "785", "0.4948",
      "786", "0.4442", "787", "0.5797", "788", "0.5878", "789", "0.2258", "790", "0.4935",
      "791", "0.4748", "792", "0.1842", "793", "0.4146", "794", "0.1461", "795", "0.0272",
      "796", "0.2499", "797", "0.5889", "798", "0.1676", "799", "0.2643", "800", "0.2316",
      "801", "0.4413", "802", "0.4585", "803", "0.0002", "804", "0.5026", "805", "0.0678",
      "806", "0.1141", "807", "0.6728", "808", "0.7265", "809", "0.3243", "810", "0.4041",
      "811", "0.2926", "812", "0.6324", "813", "0.3277", "814", "0.7074", "815", "0.2047",
      "816", "0.8177", "817", "0.4657", "818", "0.3387", "819", "0.6261", "820", "0.7769",
      "821", "0.2674", "822", "0.0890", "823", "0.4351", "824", "0.3365", "825", "0.0604",
      "826", "0.3873", "827", "0.4253", "828", "0.3406", "829", "0.2012", "830", "0.0951",
      "831", "0.5031", "832", "0.1467", "833", "0.4211", "834", "0.5134", "835", "0.1053",
      "836", "0.2078", "837", "0.1119", "838", "0.2609", "839", "0.5808", "840", "0.1626",
      "841", "0.4603", "842", "0.1827", "843", "0.5260", "844", "0.0800", "845", "0.4416",
      "846", "0.2195", "847", "0.3851", "848", "0.1151", "849", "0.3785", "850", "0.2241" };

  @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.1761f));
    g.put("indep-x1.5", new GroundTruth("indep-x1.5", Metric.AP, 75, x15_rawAP, 0.2724f));
    g.put("indep-x2.0", new GroundTruth("indep-x2.0", Metric.AP, 75, x20_rawAP, 0.3296f));
    g.put("indep-x2.5", new GroundTruth("indep-x2.5", Metric.AP, 75, x25_rawAP, 0.3325f));
    g.put("indep-x3.0", new GroundTruth("indep-x3.0", Metric.AP, 75, x30_rawAP, 0.3379f));
    g.put("indep-x3.5", new GroundTruth("indep-x3.5", Metric.AP, 75, x35_rawAP, 0.3421f));
    g.put("indep-x4.0", new GroundTruth("indep-x4.0", Metric.AP, 75, x40_rawAP, 0.3512f));
    g.put("indep-x4.5", new GroundTruth("indep-x4.5", Metric.AP, 75, x45_rawAP, 0.3540f));
    g.put("indep-x5.0", new GroundTruth("indep-x5.0", Metric.AP, 75, x50_rawAP, 0.3550f));

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

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

    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_Title_Indep.class);
  }
}
TOP

Related Classes of ivory.regression.cikm2010.Gov2_Title_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.