Package ivory.regression.cikm2010

Source Code of ivory.regression.cikm2010.Gov2_Title_Joint

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_Joint {

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

  private static String[] x10_rawAP = new String[] {
      "776", "0.3171", "777", "0.3698", "778", "0.1296", "779", "0.5474", "780", "0.4078",
      "781", "0.3550", "782", "0.6578", "783", "0.0825", "784", "0.4589", "785", "0.3521",
      "786", "0.4405", "787", "0.5718", "788", "0.5686", "789", "0.2256", "790", "0.4703",
      "791", "0.4896", "792", "0.1244", "793", "0.4204", "794", "0.0689", "795", "0.0272",
      "796", "0.2398", "797", "0.5479", "798", "0.1757", "799", "0.3034", "800", "0.2470",
      "801", "0.4268", "802", "0.3766", "803", "0.0000", "804", "0.4787", "805", "0.0655",
      "806", "0.0207", "807", "0.6270", "808", "0.6650", "809", "0.2913", "810", "0.3716",
      "811", "0.2521", "812", "0.6102", "813", "0.3058", "814", "0.6868", "815", "0.2428",
      "816", "0.8072", "817", "0.3981", "818", "0.4305", "819", "0.5223", "820", "0.7711",
      "821", "0.1527", "822", "0.0923", "823", "0.2454", "824", "0.3283", "825", "0.0082",
      "826", "0.2254", "827", "0.3632", "828", "0.2710", "829", "0.0539", "830", "0.0422",
      "831", "0.2675", "832", "0.1711", "833", "0.4142", "834", "0.4439", "835", "0.0399",
      "836", "0.2101", "837", "0.1241", "838", "0.2801", "839", "0.5203", "840", "0.1548",
      "841", "0.3294", "842", "0.1401", "843", "0.4671", "844", "0.0457", "845", "0.3349",
      "846", "0.1822", "847", "0.3750", "848", "0.1375", "849", "0.1649", "850", "0.2711" };

  private static String[] x15_rawAP = new String[] {
      "776", "0.3171", "777", "0.3738", "778", "0.1296", "779", "0.5523", "780", "0.4078",
      "781", "0.3550", "782", "0.6578", "783", "0.0825", "784", "0.4589", "785", "0.3521",
      "786", "0.4405", "787", "0.5718", "788", "0.5686", "789", "0.2256", "790", "0.4688",
      "791", "0.4795", "792", "0.1319", "793", "0.4204", "794", "0.0689", "795", "0.0274",
      "796", "0.2370", "797", "0.5479", "798", "0.1757", "799", "0.3034", "800", "0.2470",
      "801", "0.4268", "802", "0.3210", "803", "0.0000", "804", "0.4787", "805", "0.0655",
      "806", "0.0207", "807", "0.6589", "808", "0.6745", "809", "0.2913", "810", "0.3716",
      "811", "0.2521", "812", "0.6209", "813", "0.3058", "814", "0.6868", "815", "0.2428",
      "816", "0.8072", "817", "0.3501", "818", "0.4258", "819", "0.5223", "820", "0.7711",
      "821", "0.2327", "822", "0.0923", "823", "0.3213", "824", "0.3283", "825", "0.0237",
      "826", "0.2254", "827", "0.3657", "828", "0.2710", "829", "0.0566", "830", "0.0422",
      "831", "0.2481", "832", "0.1711", "833", "0.4142", "834", "0.4763", "835", "0.0399",
      "836", "0.2101", "837", "0.1241", "838", "0.2801", "839", "0.5203", "840", "0.1548",
      "841", "0.3294", "842", "0.1401", "843", "0.4671", "844", "0.0457", "845", "0.3958",
      "846", "0.1822", "847", "0.4102", "848", "0.1098", "849", "0.1649", "850", "0.2711" };

  private static String[] x20_rawAP = new String[] {
      "776", "0.3351", "777", "0.3636", "778", "0.2248", "779", "0.5523", "780", "0.4161",
      "781", "0.3333", "782", "0.6299", "783", "0.0818", "784", "0.4589", "785", "0.4019",
      "786", "0.4352", "787", "0.5731", "788", "0.6159", "789", "0.2239", "790", "0.4487",
      "791", "0.4795", "792", "0.1858", "793", "0.4348", "794", "0.1517", "795", "0.0276",
      "796", "0.2190", "797", "0.5503", "798", "0.1506", "799", "0.2939", "800", "0.2570",
      "801", "0.4273", "802", "0.3114", "803", "0.0000", "804", "0.4802", "805", "0.0657",
      "806", "0.1426", "807", "0.6727", "808", "0.7203", "809", "0.2544", "810", "0.4194",
      "811", "0.2785", "812", "0.6364", "813", "0.3093", "814", "0.6921", "815", "0.2362",
      "816", "0.7664", "817", "0.3123", "818", "0.4149", "819", "0.6222", "820", "0.7749",
      "821", "0.3078", "822", "0.0861", "823", "0.3902", "824", "0.3309", "825", "0.0462",
      "826", "0.3115", "827", "0.3564", "828", "0.3387", "829", "0.0627", "830", "0.1079",
      "831", "0.2481", "832", "0.1360", "833", "0.3775", "834", "0.4538", "835", "0.1005",
      "836", "0.2072", "837", "0.1203", "838", "0.2792", "839", "0.5238", "840", "0.1626",
      "841", "0.4214", "842", "0.1867", "843", "0.5396", "844", "0.0802", "845", "0.3620",
      "846", "0.1946", "847", "0.4104", "848", "0.1161", "849", "0.2902", "850", "0.2799" };

  private static String[] x25_rawAP = new String[] {
      "776", "0.3098", "777", "0.3661", "778", "0.2248", "779", "0.5524", "780", "0.4161",
      "781", "0.3233", "782", "0.6120", "783", "0.0712", "784", "0.4589", "785", "0.4363",
      "786", "0.4352", "787", "0.5731", "788", "0.6159", "789", "0.2154", "790", "0.4427",
      "791", "0.4824", "792", "0.1336", "793", "0.4348", "794", "0.1517", "795", "0.0276",
      "796", "0.2418", "797", "0.5641", "798", "0.1428", "799", "0.2356", "800", "0.2248",
      "801", "0.4225", "802", "0.3764", "803", "0.0000", "804", "0.5177", "805", "0.0591",
      "806", "0.1426", "807", "0.6839", "808", "0.7158", "809", "0.2412", "810", "0.4194",
      "811", "0.2785", "812", "0.6259", "813", "0.3090", "814", "0.6921", "815", "0.1919",
      "816", "0.7317", "817", "0.4190", "818", "0.3605", "819", "0.6222", "820", "0.7727",
      "821", "0.3083", "822", "0.0857", "823", "0.4003", "824", "0.3226", "825", "0.0524",
      "826", "0.3158", "827", "0.3566", "828", "0.3387", "829", "0.2210", "830", "0.1079",
      "831", "0.1146", "832", "0.0224", "833", "0.3775", "834", "0.4477", "835", "0.1839",
      "836", "0.2151", "837", "0.1203", "838", "0.2837", "839", "0.5297", "840", "0.1626",
      "841", "0.4852", "842", "0.1867", "843", "0.5396", "844", "0.0802", "845", "0.4015",
      "846", "0.1946", "847", "0.4046", "848", "0.1168", "849", "0.3539", "850", "0.2293" };

  private static String[] x30_rawAP = new String[] {
      "776", "0.3396", "777", "0.3476", "778", "0.2260", "779", "0.5529", "780", "0.4230",
      "781", "0.3447", "782", "0.5930", "783", "0.1038", "784", "0.4589", "785", "0.4778",
      "786", "0.4114", "787", "0.5692", "788", "0.6137", "789", "0.2153", "790", "0.4118",
      "791", "0.4668", "792", "0.0985", "793", "0.4394", "794", "0.3043", "795", "0.0276",
      "796", "0.2435", "797", "0.5467", "798", "0.1576", "799", "0.2467", "800", "0.2301",
      "801", "0.4302", "802", "0.4163", "803", "0.0261", "804", "0.5203", "805", "0.0898",
      "806", "0.2844", "807", "0.6876", "808", "0.7178", "809", "0.2903", "810", "0.4454",
      "811", "0.2914", "812", "0.6127", "813", "0.3221", "814", "0.6753", "815", "0.2160",
      "816", "0.7557", "817", "0.4780", "818", "0.3563", "819", "0.5692", "820", "0.7768",
      "821", "0.3067", "822", "0.0799", "823", "0.3992", "824", "0.3218", "825", "0.0559",
      "826", "0.3256", "827", "0.3528", "828", "0.3707", "829", "0.3578", "830", "0.1450",
      "831", "0.2372", "832", "0.0385", "833", "0.3235", "834", "0.4325", "835", "0.1786",
      "836", "0.2198", "837", "0.1165", "838", "0.2567", "839", "0.5529", "840", "0.1626",
      "841", "0.4914", "842", "0.2553", "843", "0.5606", "844", "0.1669", "845", "0.4497",
      "846", "0.1962", "847", "0.3862", "848", "0.1230", "849", "0.3983", "850", "0.2246" };

  private static String[] x35_rawAP = new String[] {
      "776", "0.3217", "777", "0.3378", "778", "0.2260", "779", "0.5529", "780", "0.4230",
      "781", "0.3447", "782", "0.6084", "783", "0.1245", "784", "0.4589", "785", "0.4778",
      "786", "0.4114", "787", "0.5692", "788", "0.6137", "789", "0.2153", "790", "0.4048",
      "791", "0.4668", "792", "0.1133", "793", "0.4394", "794", "0.3043", "795", "0.0278",
      "796", "0.2417", "797", "0.5467", "798", "0.1653", "799", "0.2284", "800", "0.2123",
      "801", "0.4388", "802", "0.4410", "803", "0.0261", "804", "0.5203", "805", "0.0778",
      "806", "0.2844", "807", "0.6873", "808", "0.7057", "809", "0.2959", "810", "0.4454",
      "811", "0.2914", "812", "0.6312", "813", "0.3132", "814", "0.6753", "815", "0.2365",
      "816", "0.7557", "817", "0.4939", "818", "0.3451", "819", "0.5692", "820", "0.7717",
      "821", "0.3158", "822", "0.0799", "823", "0.4012", "824", "0.3179", "825", "0.0615",
      "826", "0.3197", "827", "0.3629", "828", "0.3707", "829", "0.3582", "830", "0.1450",
      "831", "0.3337", "832", "0.0624", "833", "0.3235", "834", "0.4493", "835", "0.1787",
      "836", "0.2002", "837", "0.1165", "838", "0.2375", "839", "0.5719", "840", "0.1626",
      "841", "0.4914", "842", "0.2553", "843", "0.5606", "844", "0.1669", "845", "0.4341",
      "846", "0.1962", "847", "0.3713", "848", "0.1161", "849", "0.4215", "850", "0.1935" };

  private static String[] x40_rawAP = new String[] {
      "776", "0.3217", "777", "0.3351", "778", "0.2260", "779", "0.5489", "780", "0.4230",
      "781", "0.3476", "782", "0.6084", "783", "0.1245", "784", "0.4589", "785", "0.5037",
      "786", "0.4114", "787", "0.5692", "788", "0.6137", "789", "0.2153", "790", "0.4200",
      "791", "0.4639", "792", "0.1142", "793", "0.4394", "794", "0.3043", "795", "0.0278",
      "796", "0.2429", "797", "0.5225", "798", "0.1653", "799", "0.2284", "800", "0.2123",
      "801", "0.4388", "802", "0.4560", "803", "0.0261", "804", "0.5298", "805", "0.0778",
      "806", "0.2844", "807", "0.6836", "808", "0.7057", "809", "0.2959", "810", "0.4454",
      "811", "0.2914", "812", "0.6330", "813", "0.3132", "814", "0.6753", "815", "0.2365",
      "816", "0.7593", "817", "0.4875", "818", "0.3311", "819", "0.5692", "820", "0.7717",
      "821", "0.3309", "822", "0.0799", "823", "0.3911", "824", "0.3179", "825", "0.0771",
      "826", "0.3197", "827", "0.3593", "828", "0.3707", "829", "0.3588", "830", "0.1450",
      "831", "0.3337", "832", "0.0624", "833", "0.3235", "834", "0.4476", "835", "0.1787",
      "836", "0.2002", "837", "0.1165", "838", "0.2375", "839", "0.5719", "840", "0.1626",
      "841", "0.4943", "842", "0.2553", "843", "0.5606", "844", "0.1669", "845", "0.4341",
      "846", "0.1962", "847", "0.3640", "848", "0.1004", "849", "0.4215", "850", "0.1935" };

  private static String[] x45_rawAP = new String[] {
      "776", "0.3217", "777", "0.3351", "778", "0.2260", "779", "0.5489", "780", "0.4230",
      "781", "0.3476", "782", "0.6084", "783", "0.1245", "784", "0.4589", "785", "0.5037",
      "786", "0.4114", "787", "0.5692", "788", "0.6137", "789", "0.2153", "790", "0.4200",
      "791", "0.4639", "792", "0.1142", "793", "0.4394", "794", "0.3043", "795", "0.0278",
      "796", "0.2429", "797", "0.5225", "798", "0.1653", "799", "0.2284", "800", "0.2123",
      "801", "0.4388", "802", "0.4560", "803", "0.0261", "804", "0.5298", "805", "0.0778",
      "806", "0.2844", "807", "0.6836", "808", "0.7057", "809", "0.2959", "810", "0.4454",
      "811", "0.2914", "812", "0.6330", "813", "0.3132", "814", "0.6753", "815", "0.2365",
      "816", "0.7593", "817", "0.4875", "818", "0.3311", "819", "0.5692", "820", "0.7717",
      "821", "0.3309", "822", "0.0799", "823", "0.3911", "824", "0.3179", "825", "0.0771",
      "826", "0.3197", "827", "0.3593", "828", "0.3707", "829", "0.3588", "830", "0.1450",
      "831", "0.3337", "832", "0.0624", "833", "0.3235", "834", "0.4476", "835", "0.1787",
      "836", "0.2002", "837", "0.1165", "838", "0.2375", "839", "0.5719", "840", "0.1626",
      "841", "0.4943", "842", "0.2553", "843", "0.5606", "844", "0.1669", "845", "0.4341",
      "846", "0.1962", "847", "0.3640", "848", "0.1004", "849", "0.4215", "850", "0.1935" };

  private static String[] x50_rawAP = new String[] {
      "776", "0.3217", "777", "0.3351", "778", "0.2260", "779", "0.5489", "780", "0.4230",
      "781", "0.3476", "782", "0.6084", "783", "0.1245", "784", "0.4589", "785", "0.5037",
      "786", "0.4114", "787", "0.5692", "788", "0.6137", "789", "0.2153", "790", "0.4200",
      "791", "0.4639", "792", "0.1142", "793", "0.4394", "794", "0.3043", "795", "0.0278",
      "796", "0.2429", "797", "0.5225", "798", "0.1653", "799", "0.2284", "800", "0.2123",
      "801", "0.4388", "802", "0.4560", "803", "0.0261", "804", "0.5298", "805", "0.0778",
      "806", "0.2844", "807", "0.6836", "808", "0.7057", "809", "0.2959", "810", "0.4454",
      "811", "0.2914", "812", "0.6330", "813", "0.3132", "814", "0.6753", "815", "0.2365",
      "816", "0.7593", "817", "0.4875", "818", "0.3311", "819", "0.5692", "820", "0.7717",
      "821", "0.3309", "822", "0.0799", "823", "0.3911", "824", "0.3179", "825", "0.0771",
      "826", "0.3197", "827", "0.3593", "828", "0.3707", "829", "0.3588", "830", "0.1450",
      "831", "0.3337", "832", "0.0624", "833", "0.3235", "834", "0.4476", "835", "0.1787",
      "836", "0.2002", "837", "0.1165", "838", "0.2375", "839", "0.5719", "840", "0.1626",
      "841", "0.4943", "842", "0.2553", "843", "0.5606", "844", "0.1669", "845", "0.4341",
      "846", "0.1962", "847", "0.3640", "848", "0.1004", "849", "0.4215", "850", "0.1935" };

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

    g.put("joint-x1.0", new GroundTruth("joint-x1.0", Metric.AP, 75, x10_rawAP, 0.3174f));
    g.put("joint-x1.5", new GroundTruth("joint-x1.5", Metric.AP, 75, x15_rawAP, 0.3201f));
    g.put("joint-x2.0", new GroundTruth("joint-x2.0", Metric.AP, 75, x20_rawAP, 0.3361f));
    g.put("joint-x2.5", new GroundTruth("joint-x2.5", Metric.AP, 75, x25_rawAP, 0.3364f));
    g.put("joint-x3.0", new GroundTruth("joint-x3.0", Metric.AP, 75, x30_rawAP, 0.3506f));
    g.put("joint-x3.5", new GroundTruth("joint-x3.5", Metric.AP, 75, x35_rawAP, 0.3522f));
    g.put("joint-x4.0", new GroundTruth("joint-x4.0", Metric.AP, 75, x40_rawAP, 0.3524f));
    g.put("joint-x4.5", new GroundTruth("joint-x4.5", Metric.AP, 75, x45_rawAP, 0.3524f));
    g.put("joint-x5.0", new GroundTruth("joint-x5.0", Metric.AP, 75, x50_rawAP, 0.3524f));

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

    String[] params = new String[] {
        "data/gov2/run.gov2.CIKM2010.title.joint.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_Joint.class);
  }
}
TOP

Related Classes of ivory.regression.cikm2010.Gov2_Title_Joint

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.