Package org.data2semantics.proppred.kernels.rdfgraphkernels

Examples of org.data2semantics.proppred.kernels.rdfgraphkernels.RDFWLSubTreeWithTextKernel$EdgeIndexPair


            weights[(int) label - 1] = 1 / counts.get(label);
          }
          linParms.setWeightLabels(wLabels);
          linParms.setWeights(weights);

          RDFLinearKernelExperiment exp = new RDFLinearKernelExperiment(new RDFWLSubTreeWithTextKernel(it, i, inference, true), seeds2, linParms, dataset, instances, target, blackList, evalFuncs);

          System.out.println("Running WL RDF with text: " + i + " " + it);
          exp.setDoCV(true);
          exp.run();
          res.add(exp.getResults());
View Full Code Here



    for (int d : depths) {
      resTable.newRow("WL RDF BoW, depth="+d);
      for (int it : iterations) {
        RDFWLSubTreeWithTextKernel k = new RDFWLSubTreeWithTextKernel(it, d, inference, false);
        k.setDoTFIDFkernel(true);
       
        RDFOldKernelExperiment exp = new RDFOldKernelExperiment(k, seeds, svmParms, dataset, instances, labels, blackList);
   
        System.out.println("Running WL RDF text: " + d + " " + it);
        exp.run();

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

 
   
   
    for (int d : depths) {
      resTable.newRow("ITP, depth="+d);

      RDFOldKernelExperiment exp = new RDFOldKernelExperiment(new RDFIntersectionTreeEdgeVertexPathKernel(d, false, inference, true), seeds, svmParms, dataset, instances, labels, blackList);

      System.out.println("Running Edge Vertex Tree Path: " + d);
      exp.run();

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

    }
    System.out.println(resTable);
   


    for (int d : depths) {
      resTable.newRow("ITP BoW, depth="+d);

     
      RDFIntersectionTreeEdgeVertexPathWithTextKernel k = new RDFIntersectionTreeEdgeVertexPathWithTextKernel(d, false, inference, false);
      k.setDoTFIDFkernel(true);
     
      RDFOldKernelExperiment exp = new RDFOldKernelExperiment(k, seeds, svmParms, dataset, instances, labels, blackList);

      System.out.println("Running Edge Vertex Tree Path with Text: " + d);
      exp.run();
View Full Code Here

    }
    linParms.setWeightLabels(wLabels);
    linParms.setWeights(weights);

   
    RDFFeatureVectorKernel kernel = new RDFWLSubTreeWithTextKernel(4, 2, inference, false);
   
    List<Resource> allInstances = new ArrayList<Resource>(instances);
    allInstances.addAll(testInstances);
   
    System.out.println("Computing kernel....");
    SparseVector[] fv = kernel.computeFeatureVectors(dataset, allInstances, blackList);
    System.out.println("Computing TFIDF....");
    fv = TextUtils.computeTFIDF(Arrays.asList(fv)).toArray(new SparseVector[1]);
    fv = KernelUtils.normalize(fv);
   
    SparseVector[] trainFV = Arrays.copyOfRange(fv, 0, instances.size());
View Full Code Here


    for (int d : depths) {
      resTable.newRow("WL RDF, depth="+d);
      for (int it : iterations) {
        RDFWLSubTreeWithTextKernel k = new RDFWLSubTreeWithTextKernel(it, d, inference, false);
        //k.setIgnoreLiterals(false);
       
        //RDFOldKernelExperiment exp = new RDFOldKernelExperiment(k, seeds, svmParms, dataset, instances, labels, blackList);

       
View Full Code Here

        kernels.add(new RDFWLSubTreeKernel(it,d, inference, false));
        kernels.add(new RDFSimpleTextKernel(d, inference, false));
        RDFFeatureVectorKernel kernel = new RDFCombinedKernel(kernels, true);
        */
       
        RDFFeatureVectorKernel kernel = new RDFWLSubTreeWithTextKernel(it, d, inference, false);
       
       
       
        System.out.println("Running RDFWL + text kernel: " + d + " " + it);

        Map<EvaluationFunction, double[]> resultMap = new HashMap<EvaluationFunction,double[]>();
        Map<EvaluationFunction, double[]> resultMap2 = new HashMap<EvaluationFunction,double[]>();

        List<Result> results = new ArrayList<Result>();

        for (EvaluationFunction evalFunc : evalFuncs1) {
          Result res = new Result();
          double[] resA = new double[seeds.length];
          res.setLabel(evalFunc.getLabel());
          res.setScores(resA);
          res.setHigherIsBetter(evalFunc.isHigherIsBetter());
          results.add(res);
          resultMap.put(evalFunc, resA);
        }

        for (EvaluationFunction evalFunc : evalFuncs2) {
          Result res = new Result();
          double[] resA = new double[seeds.length];
          res.setLabel(evalFunc.getLabel());
          res.setScores(resA);
          res.setHigherIsBetter(evalFunc.isHigherIsBetter());
          results.add(res);
          resultMap2.put(evalFunc, resA);
        }

        Result compR = new Result();
        results.add(compR);


        long tic, toc;

        List<Double> tempLabels = new ArrayList<Double>();
        List<Double> tempLabelsBins = new ArrayList<Double>();
        tempLabels.addAll(target);
        tempLabelsBins.addAll(targetBins);

        tic = System.currentTimeMillis();
        SparseVector[] fv = kernel.computeFeatureVectors(dataset, instances, blackList);
        toc = System.currentTimeMillis();

        fv = TextUtils.computeTFIDF(Arrays.asList(fv)).toArray(new SparseVector[1]);
        fv = KernelUtils.normalize(fv);

View Full Code Here

    System.out.println(resTable);

    for (int depth : depths) {
      resTable.newRow("WL RDF BoW, depth="+depth);
      for (int it : iterations) {
        RDFOldKernelExperiment exp = new RDFOldKernelExperiment(new RDFWLSubTreeWithTextKernel(it, depth, inference, true), seeds, svmParms, dataset, instances, labels, blackList);

       
        System.out.println("Running WL RDF with Text: " + depth + " " + it);
        exp.run();
View Full Code Here

      //for (double frac : fractions) {
      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");   

        RDFFeatureVectorKernel k = new RDFWLSubTreeWithTextKernel(6,3,false, false);

        System.out.println("RDF WL text FV: " + frac);
        tic = System.currentTimeMillis();
        TextUtils.computeTFIDF(Arrays.asList(k.computeFeatureVectors(dataset, instances, blackList)));       
        toc = System.currentTimeMillis();
        comp[i] = toc-tic;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
      //}
      //System.out.println(resTable);


      //resTable.newRow("EVP FV");
      //for (double frac : fractions) {
      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");   

        RDFFeatureVectorKernel k = new RDFIntersectionTreeEdgeVertexPathKernel(3,false, false, true);

        System.out.println("RDF EVP FV: " + frac);
        tic = System.currentTimeMillis();
        k.computeFeatureVectors(dataset, instances, blackList);
        toc = System.currentTimeMillis();
        comp[i] = toc-tic;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
      //}
      //System.out.println(resTable);

      //resTable.newRow("EVP Kernel");
      //for (double frac : fractions) {
      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");   

        RDFGraphKernel k = new RDFIntersectionTreeEdgeVertexPathKernel(3,false, false, true);

        System.out.println("RDF EVP Kernel: " + frac);
        tic = System.currentTimeMillis();
        k.compute(dataset, instances, blackList);
        toc = System.currentTimeMillis();
        comp[i] = toc-tic;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
      //}
      //System.out.println(resTable);

      //resTable.newRow("EVP text FV");
      //for (double frac : fractions) {
      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");   

        RDFFeatureVectorKernel k = new RDFIntersectionTreeEdgeVertexPathWithTextKernel(3,false, false, false);

        System.out.println("EVP text FV: " + frac);
        tic = System.currentTimeMillis();
        TextUtils.computeTFIDF(Arrays.asList(k.computeFeatureVectors(dataset, instances, blackList)));       
        toc = System.currentTimeMillis();
        comp[i] = toc-tic;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
      //}
      //System.out.println(resTable);




      //resTable.newRow("RDF IST");
      //for (double frac : fractions) {
      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");   
        RDFGraphKernel k = new RDFIntersectionSubTreeKernel(3,1, false, true);


        System.out.println("RDF IST: " + frac);
        tic = System.currentTimeMillis();
        k.compute(dataset, instances, blackList);
        toc = System.currentTimeMillis();
        comp[i] = toc-tic;
      }
      res = new Result(comp, "comp time");
      resTable.addResult(res);
      //}
      //System.out.println(resTable);



     
    //resTable.newRow("WL FV");
    //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

TOP

Related Classes of org.data2semantics.proppred.kernels.rdfgraphkernels.RDFWLSubTreeWithTextKernel$EdgeIndexPair

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.