Package org.data2semantics.exp.old.utils.datasets

Examples of org.data2semantics.exp.old.utils.datasets.PropertyPredictionDataSet


      if (maxClassSize == 0) {
        matrix = KernelUtils.shuffle(matrix, seeds[i]);
        dataSet.shuffle(seeds[i]);
        target = LibSVM.createTargets(dataSet.getLabels());
      } else {
        PropertyPredictionDataSet subset = dataSet.getSubSet(maxClassSize, seeds[i]);
        // shuffle the subset, since the creation of the subset might result in a too ordered dataset
        subset.shuffle(seeds[i]);
        matrix = kernel.compute(subset.getGraphs());
        target = LibSVM.createTargets(subset.getLabels());
      }     
       
      LibSVMParameters params = new LibSVMParameters(LibSVMParameters.C_SVC, cs);
      double[] prediction = LibSVM.extractLabels(LibSVM.crossValidate(matrix, target, params, 10));
     
View Full Code Here


      res.setLabel("runtime");
      for (long seed : seeds) {

        createAffiliationPredictionDataSet(frac,seed);
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();

        KernelExperiment<GraphKernel> exp = new GraphKernelRunTimeExperiment(new ECML2013WLSubTreeKernel(iteration), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running WL: " + frac);
        exp.run();
        res.addResult(exp.getResults().get(0));

        double[] comps = {2 * (toc-tic) + res.getScore()};
        Result resC = new Result(comps,"comp time 2")
        res.addResult(resC);
      }

      resTable.addResult(res);
    }
    /*
    resTable.newRow("");
    for (double frac : fractions) {
      createAffiliationPredictionDataSet(frac);
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
      toc = System.currentTimeMillis();


      KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphPathKernel(2,1), seeds, parms, ds.getGraphs(), labels);

      System.out.println("Running IGP: " + frac);
      exp.run();

      double[] comps =  {0,0};
  comps[0] = 2*(toc-tic) + exp.getResults().get(exp.getResults().size()-1).getScore();
      comps[1] = 2*(toc-tic) + exp.getResults().get(exp.getResults().size()-1).getScore();
          Result resC = new Result(comps,"comp time 2"); 
      exp.getResults().get(exp.getResults().size()-1).addResult(resC);

      resTable.addResult(exp.getResults().get(exp.getResults().size()-1));
    }*/


    resTable.newRow("IGW");
    for (double frac : fractions) {

      Result res = new Result();
      res.setLabel("runtime");
      for (long seed : seeds) {
        createAffiliationPredictionDataSet(frac,seed);
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();

        KernelExperiment<GraphKernel> exp = new GraphKernelRunTimeExperiment(new ECML2013IntersectionGraphWalkKernel(2,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGW: " + frac);
        exp.run();

        res.addResult(exp.getResults().get(0));
View Full Code Here

    int[] iterationsIG = {1,2};
    long tic, toc;

    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("WL");
      for (int it : iterations) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013WLSubTreeKernel(it), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running WL: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
          resTable.addResult(res);
        }

        double[] comps =  {0,0};
        comps[0] = toc-tic;
        comps[1] = toc-tic;
        Result resC = new Result(comps,"comp time 2");
        resTable.addResult(resC);

      }
    }
    saveResults(resTable, "affiliation.ser");



    /*
    dataSetsParams = new ArrayList<GeneralPredictionDataSetParameters>();

    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 1, false, false));
    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 2, false, false));

    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 1, false, true));
    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 2, false, true));
     */


    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("IGP");
      for (int it : iterationsIG) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphPathKernel(it,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGP: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
          resTable.addResult(res);
        }

        double[] comps =  {0,0};
        comps[0] = toc-tic;
        comps[1] = toc-tic;
        Result resC = new Result(comps,"comp time 2");
        resTable.addResult(resC);
      }
    }
    saveResults(resTable, "affiliation.ser");


   
    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("IGW");
      for (int it : iterationsIG) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphWalkKernel(it,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGW: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
View Full Code Here

   


   

    PropertyPredictionDataSet dataset;
    PropertyPredictionExperiment exp;

    ResultsTable resultsWL  = new ResultsTable();
    ResultsTable resultsSTF = new ResultsTable();
    ResultsTable resultsSTP = new ResultsTable();
    ResultsTable resultsIGW = new ResultsTable();
    ResultsTable resultsIGP = new ResultsTable();

    Experimenter experimenter = new Experimenter(NUMBER_OF_PROC);
    Thread expT = new Thread(experimenter);
    expT.setDaemon(true);
    expT.start();



    try {
      for (GeneralPredictionDataSetParameters params : dataSetsParams) {
        dataset = DataSetFactory.createPropertyPredictionDataSet(params);
        //dataset.removeSmallClasses(5);
        dataset.setLabels(labels);
        //dataset.removeVertexAndEdgeLabels();

       
       
        resultsWL.newRow(dataset.getLabel() + " WLSubTreeKernel");
        for (int i = 0; i < 4; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "WL" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new WLSubTreeKernel(i), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsWL.addResult(exp.getResults().getAccuracy());
            resultsWL.addResult(exp.getResults().getF1());
          }
        }


       
        resultsSTF.newRow(dataset.getLabel() + " IntersectionFullSubTree");
        for (int i = 0; i < 4; i++) {

          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionFullSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionSubTreeKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTF.addResult(exp.getResults().getAccuracy());
            resultsSTF.addResult(exp.getResults().getF1());
          }
        }

        resultsSTP.newRow(dataset.getLabel() + " IntersectionPartialSubTree");
        for (int i = 0; i < 4; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionPartialSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionPartialSubTreeKernel(i, 0.01), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTP.addResult(exp.getResults().getAccuracy());
            resultsSTP.addResult(exp.getResults().getF1());
          }
        }

        //*/


       
        resultsIGP.newRow(dataset.getLabel() + " IntersectionGraphPath");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphPath" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphPathKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGP.addResult(exp.getResults().getAccuracy());
            resultsIGP.addResult(exp.getResults().getF1());
          }
        }       

        resultsIGW.newRow(dataset.getLabel() + " IntersectionGraphWalk");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphWalk" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphWalkKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGW.addResult(exp.getResults().getAccuracy());
            resultsIGW.addResult(exp.getResults().getF1());
          }
        }
View Full Code Here

      Result res = new Result();
      res.setLabel("runtime");
      for (long seed : seeds) {
        createGeoDataSet(seed,frac,6,"http://data.bgs.ac.uk/ref/Lexicon/hasLithogenesis");
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();

        KernelExperiment<GraphKernel> exp = new GraphKernelRunTimeExperiment(new ECML2013WLSubTreeKernel(iteration), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running WL: " + frac);
        exp.run();

        res.addResult(exp.getResults().get(0));

        double[] comps = {2 * (toc-tic) + res.getScore()};
        Result resC = new Result(comps,"comp time 2")
        res.addResult(resC);
      }

      resTable.addResult(res)
    }

    /*
    resTable.newRow("");
    for (double frac : fractions) {
      createGeoDataSet(11,frac,"http://data.bgs.ac.uk/ref/Lexicon/hasLithogenesis");
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
      toc = System.currentTimeMillis();


      KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphPathKernel(2,1), seeds, parms, ds.getGraphs(), labels);

      System.out.println("Running IGP: " + frac);
      exp.run();

      double[] comps =  {0,0};
      comps[0] = 2*(toc-tic) + exp.getResults().get(exp.getResults().size()-1).getScore();
      comps[1] = 2*(toc-tic) + exp.getResults().get(exp.getResults().size()-1).getScore();
      Result resC = new Result(comps,"comp time 2"); 
      exp.getResults().get(exp.getResults().size()-1).addResult(resC);


      resTable.addResult(exp.getResults().get(exp.getResults().size()-1)); 
    }
     */

    resTable.newRow("IGW");
    for (double frac : fractions) {

      Result res = new Result();
      res.setLabel("runtime");
      for (long seed : seeds) {
        createGeoDataSet(seed,frac,6,"http://data.bgs.ac.uk/ref/Lexicon/hasLithogenesis");
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();


        KernelExperiment<GraphKernel> exp = new GraphKernelRunTimeExperiment(new ECML2013IntersectionGraphWalkKernel(2,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGW: " + frac);
        exp.run();

        res.addResult(exp.getResults().get(0));
View Full Code Here

    int[] iterationsIG = {1,2};
    long tic, toc;

    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("WL");
      for (int it : iterations) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013WLSubTreeKernel(it), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running WL: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
          resTable.addResult(res);
        }

        double[] comps =  {0,0};
        comps[0] = toc-tic;
        comps[1] = toc-tic;
        Result resC = new Result(comps,"comp time 2");
        resTable.addResult(resC);

      }
    }
    saveResults(resTable, "geo_litho.ser");


    /*
    dataSetsParams = new ArrayList<GeneralPredictionDataSetParameters>();

    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 1, false, false));
    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 2, false, false));

    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 1, false, true));
    dataSetsParams.add(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 2, false, true));
     */




    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("IGP");
      for (int it : iterationsIG) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphPathKernel(it,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGP: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
          resTable.addResult(res);
        }

        double[] comps =  {0,0};
        comps[0] = toc-tic;
        comps[1] = toc-tic;
        Result resC = new Result(comps,"comp time 2");
        resTable.addResult(resC);
      }
    }
    saveResults(resTable, "geo_litho.ser");


    for (GeneralPredictionDataSetParameters params : dataSetsParams) {
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(params);
      toc = System.currentTimeMillis();

      if (blankLabels) {
        ds.removeVertexAndEdgeLabels();
      }

      resTable.newRow("IGW");
      for (int it : iterationsIG) {
        KernelExperiment<GraphKernel> exp = new GraphKernelExperiment(new ECML2013IntersectionGraphWalkKernel(it,1), seeds, parms, ds.getGraphs(), labels);

        System.out.println("Running IGW: " + it);
        exp.run();

        for (Result res : exp.getResults()) {
View Full Code Here

    dataSetsParams.add(new BinaryPropertyPredictionDataSetParameters(testSetA, "http://data.semanticweb.org/ns/swc/ontology#holdsRole", "http://data.semanticweb.org/ns/swc/ontology#heldBy", "http://data.semanticweb.org/conference/eswc/2012/research-track-committee-member", "http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "http://xmlns.com/foaf/0.1/Person", 2, true, true));
   
    //*/


    PropertyPredictionDataSet dataset;
    PropertyPredictionExperiment exp;

    ResultsTable resultsWL  = new ResultsTable();
    ResultsTable resultsSTF = new ResultsTable();
    ResultsTable resultsSTP = new ResultsTable();
    ResultsTable resultsIGW = new ResultsTable();
    ResultsTable resultsIGP = new ResultsTable();

    Experimenter experimenter = new Experimenter(NUMBER_OF_PROC);
    Thread expT = new Thread(experimenter);
    expT.setDaemon(true);
    expT.start();



    try {
      for (BinaryPropertyPredictionDataSetParameters params : dataSetsParams) {
        dataset = DataSetFactory.createPropertyPredictionDataSet(params);
        dataset.removeSmallClasses(5);
        dataset.setLabels(labels);
        //dataset.removeVertexAndEdgeLabels();

        resultsWL.newRow(dataset.getLabel() + " WLSubTreeKernel");

        for (int i = 0; i < 4; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "WL" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new WLSubTreeKernel(i), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsWL.addResult(exp.getResults().getAccuracy());
            resultsWL.addResult(exp.getResults().getF1());
           
            System.out.println("Running WL, it " + i + " on " + dataset.getLabel());
          }
        }

       
        resultsSTF.newRow(dataset.getLabel() + " IntersectionFullSubTree");
        for (int i = 0; i < 3; i++) {

          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionFullSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionSubTreeKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTF.addResult(exp.getResults().getAccuracy());
            resultsSTF.addResult(exp.getResults().getF1());
           
            System.out.println("Running STF, it " + i + " on " + dataset.getLabel());
          }
        }

        resultsSTP.newRow(dataset.getLabel() + " IntersectionPartialSubTree");
        for (int i = 0; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionPartialSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionPartialSubTreeKernel(i, 0.01), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTP.addResult(exp.getResults().getAccuracy());
            resultsSTP.addResult(exp.getResults().getF1());
           
            System.out.println("Running STP, it " + i + " on " + dataset.getLabel());
          }
        }


       
        resultsIGP.newRow(dataset.getLabel() + " IntersectionGraphPath");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphPath" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphPathKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGP.addResult(exp.getResults().getAccuracy());
            resultsIGP.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGP, it " + i + " on " + dataset.getLabel());
          }
        }       

        resultsIGW.newRow(dataset.getLabel() + " IntersectionGraphWalk");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphWalk" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphWalkKernel(i, 1), seeds, cs, maxClassSize, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGW.addResult(exp.getResults().getAccuracy());
            resultsIGW.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGW, it " + i + " on " + dataset.getLabel());
          }
        }
        //*/


 
View Full Code Here

   
    resTable.newRow("WL FV");
    for (double frac : fractionsSlow) {
      createGeoDataSet((int)(1000 * frac), frac, seed, "http://data.bgs.ac.uk/ref/Lexicon/hasUnitClass");   
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
      toc = System.currentTimeMillis();
      double dsComp = toc-tic;
     
      FeatureVectorKernel k = new WLSubTreeKernel(6,true);
     
      System.out.println("WL: " + frac);
      tic = System.currentTimeMillis();
      k.computeFeatureVectors(ds.getGraphs());
      toc = System.currentTimeMillis();
      double[] comp = {(toc-tic) + dsComp};
      Result res = new Result(comp, "comp time");
      resTable.addResult(res);
    }   
    System.out.println(resTable);
   
   
    resTable.newRow("WL Kernel");
    for (double frac : fractionsSlow) {
      createGeoDataSet((int)(1000 * frac), frac, seed, "http://data.bgs.ac.uk/ref/Lexicon/hasUnitClass");   
      tic = System.currentTimeMillis();
      PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
      toc = System.currentTimeMillis();
      double dsComp = toc-tic;
     
      GraphKernel k = new WLSubTreeKernel(6,true);
     
      System.out.println("WL: " + frac);
      tic = System.currentTimeMillis();
      k.compute(ds.getGraphs());
      toc = System.currentTimeMillis();
      double[] comp = {(toc-tic) + dsComp};
      Result res = new Result(comp, "comp time");
      resTable.addResult(res);
    }   
View Full Code Here

    //for (double frac : fractionsSlow) {
      comp = new double[seeds.length];
      for (int i = 0; i < seeds.length; i++) {
        createGeoDataSet((int)(1000 * frac), frac, seeds[i], "http://data.bgs.ac.uk/ref/Lexicon/hasTheme");   
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();
        double dsComp = toc-tic;

        FeatureVectorKernel k = new WLSubTreeKernel(6,true);

        System.out.println("WL: " + frac);
        tic = System.currentTimeMillis();
        k.computeFeatureVectors(ds.getGraphs());
        toc = System.currentTimeMillis();
        comp[i] = (toc-tic) + dsComp;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
    //}   
    //System.out.println(resTable);


    //resTable.newRow("WL Kernel");
    //for (double frac : fractionsSlow) {
      comp = new double[seeds.length];
      for (int i = 0; i < seeds.length; i++) {
        createGeoDataSet((int)(1000 * frac), frac, seeds[i], "http://data.bgs.ac.uk/ref/Lexicon/hasTheme");   
        tic = System.currentTimeMillis();
        PropertyPredictionDataSet ds = DataSetFactory.createPropertyPredictionDataSet(new GeneralPredictionDataSetParameters(dataset, blackLists, instances, 3, false, true));
        toc = System.currentTimeMillis();
        double dsComp = toc-tic;

        GraphKernel k = new WLSubTreeKernel(6,true);

        System.out.println("WL: " + frac);
        tic = System.currentTimeMillis();
        k.compute(ds.getGraphs());
        toc = System.currentTimeMillis();
        comp[i] = (toc-tic) + dsComp;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
View Full Code Here

    RDFDataSet testSetB = new RDFFileDataSet(DATA_DIR + "aifb-fixed_no_schema.n3", RDFFormat.N3);

    long[] seeds = {11,21,31,41,51,61,71,81,91,101};
    double[] cs = {0.001, 0.01, 0.1, 1, 10, 100, 1000}

    PropertyPredictionDataSet dataset;
    PropertyPredictionExperiment exp;
   
    Experimenter experimenter = new Experimenter(NUMBER_OF_PROC);
    Thread expT = new Thread(experimenter);
    expT.setDaemon(true);
    expT.start();

    ResultsTable resultsWL = new ResultsTable();
    ResultsTable resultsSTF = new ResultsTable();
    ResultsTable resultsSTP = new ResultsTable();
    ResultsTable resultsIGW = new ResultsTable();
    ResultsTable resultsIGP = new ResultsTable();

    ResultsTable resultsWLadd = new ResultsTable();
    ResultsTable resultsSTFadd = new ResultsTable();
    ResultsTable resultsSTPadd = new ResultsTable();
    ResultsTable resultsIGWadd = new ResultsTable();
    ResultsTable resultsIGPadd = new ResultsTable();

   
    /** 
     * FIRST EXPERIMENT, STANDARD SETTINGS
     *
     */   
    List<PropertyPredictionDataSetParameters> dataSetsParams = new ArrayList<PropertyPredictionDataSetParameters>();

   
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, true));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, true));
   
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, true, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, true, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, true, true));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, true, true));
   
    /*
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, true));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, true));
   
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, true, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, true, false));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, true, true));
    dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetB, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, true, true));
    //*/   
 

    try {
     
     
 
 
      for (PropertyPredictionDataSetParameters params : dataSetsParams) {
        dataset = DataSetFactory.createPropertyPredictionDataSet(params);
        dataset.removeSmallClasses(5);
        dataset.removeVertexAndEdgeLabels();

        resultsWL.newRow(dataset.getLabel() + " WLSubTreeKernel");
        for (int i = 0; i < 3; i++) {
          if (experimenter.hasSpace()) { 
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "WL" + "_" + i + ".txt");
            WLSubTreeKernel kernel = new WLSubTreeKernel(i, true);
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), kernel, seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsWL.addResult(exp.getResults().getAccuracy());
            resultsWL.addResult(exp.getResults().getF1());
           
            System.out.println("Running WL, it " + i + " on " + dataset.getLabel());
          }
        }

       
        resultsSTF.newRow(dataset.getLabel() + " IntersectionFullSubTree");
        for (int i = 0; i < 3; i++) {

          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionFullSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionSubTreeKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTF.addResult(exp.getResults().getAccuracy());
            resultsSTF.addResult(exp.getResults().getF1());
           
            System.out.println("Running STF, it " + i + " on " + dataset.getLabel());
          }

        }

        resultsSTP.newRow(dataset.getLabel() + " IntersectionPartialSubTree");
        for (int i = 0; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionPartialSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionPartialSubTreeKernel(i, 0.01), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTP.addResult(exp.getResults().getAccuracy());
            resultsSTP.addResult(exp.getResults().getF1());
           
            System.out.println("Running STP, it " + i + " on " + dataset.getLabel());
          }
        }


       
        resultsIGP.newRow(dataset.getLabel() + " IntersectionGraphPath");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphPath" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphPathKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGP.addResult(exp.getResults().getAccuracy());
            resultsIGP.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGP, it " + i + " on " + dataset.getLabel());
          }
        }       

        resultsIGW.newRow(dataset.getLabel() + " IntersectionGraphWalk");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphWalk" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphWalkKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGW.addResult(exp.getResults().getAccuracy());
            resultsIGW.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGW, it " + i + " on " + dataset.getLabel());
          }
        }
       
      }
     
      //*/
     

      /******
       * ADDITIONAL EXPERIMENTS
       */
      dataSetsParams = new ArrayList<PropertyPredictionDataSetParameters>();
     
     
     
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, false));
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, false));
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 3, false, false));
      //dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 4, false, false));

     
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 1, false, true));
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 2, false, true));
      dataSetsParams.add(new PropertyPredictionDataSetParameters(testSetA, "http://swrc.ontoware.org/ontology#affiliation", "http://swrc.ontoware.org/ontology#employs", 3, false, true));
     

     
      for (PropertyPredictionDataSetParameters params : dataSetsParams) {
        dataset = DataSetFactory.createPropertyPredictionDataSet(params);
        dataset.removeSmallClasses(5);
        dataset.removeVertexAndEdgeLabels();

        resultsWLadd.newRow(dataset.getLabel() + " WLSubTreeKernel");
        for (int i = 0; i < 4; i++) {
          if (experimenter.hasSpace()) { 
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "WL" + "_" + i + ".txt");
            WLSubTreeKernel kernel = new WLSubTreeKernel(i, true);
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), kernel, seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsWLadd.addResult(exp.getResults().getAccuracy());
            resultsWLadd.addResult(exp.getResults().getF1());
           
            System.out.println("Running WL, it " + i + " on " + dataset.getLabel());
          }
        }

       
        resultsSTFadd.newRow(dataset.getLabel() + " IntersectionFullSubTree");
        for (int i = 0; i < 4; i++) {

          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionFullSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionSubTreeKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTFadd.addResult(exp.getResults().getAccuracy());
            resultsSTFadd.addResult(exp.getResults().getF1());
           
            System.out.println("Running STF, it " + i + " on " + dataset.getLabel());
          }

        }

        resultsSTPadd.newRow(dataset.getLabel() + " IntersectionPartialSubTree");
        for (int i = 0; i < 4; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionPartialSubTree" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionPartialSubTreeKernel(i, 0.01), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsSTPadd.addResult(exp.getResults().getAccuracy());
            resultsSTPadd.addResult(exp.getResults().getF1());
           
            System.out.println("Running STP, it " + i + " on " + dataset.getLabel());
          }
        }
       
        resultsIGPadd.newRow(dataset.getLabel() + " IntersectionGraphPath");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphPath" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphPathKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGPadd.addResult(exp.getResults().getAccuracy());
            resultsIGPadd.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGP, it " + i + " on " + dataset.getLabel());
          }
        }       

        resultsIGWadd.newRow(dataset.getLabel() + " IntersectionGraphWalk");
        for (int i = 1; i < 3; i++) {
          if (experimenter.hasSpace()) {   
            int fileId = (int) (Math.random() * 100000000)
            File file = new File(DATA_DIR + fileId + "_" + "IntersectionGraphWalk" + "_" + i + ".txt");
            exp = new PropertyPredictionExperiment(new PropertyPredictionDataSet(dataset), new IntersectionGraphWalkKernel(i, 1), seeds, cs, new FileOutputStream(file));
            experimenter.addExperiment(exp);
            resultsIGWadd.addResult(exp.getResults().getAccuracy());
            resultsIGWadd.addResult(exp.getResults().getF1());
           
            System.out.println("Running IGW, it " + i + " on " + dataset.getLabel());
          }
        }
      }
     

View Full Code Here

TOP

Related Classes of org.data2semantics.exp.old.utils.datasets.PropertyPredictionDataSet

Copyright © 2018 www.massapicom. 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.