Menu

Error Executing RankLib in Java - CreateProcess error=5, Access is denied

RankLib
2016-08-11
2016-08-18
  • Kwabena Mensa-Bonsu

    Hello,
    I need help running RankLib in Java.Here is the code:
    String javapath = "C:\Learning to Rank";
    String traindata = "C:\Learning to Rank\MQ2008\Fold1\train.txt";
    int ranker = 4;
    String modelsStore = "C:\Learning to Rank\models";
    ProcessBuilder pb = new ProcessBuilder(javapath,"-jar","RankLib-2.1-patched.jar",
    "-train " + traindata,"-ranker " + ranker,"-kcv 5", "-kcvmd " + modelsStore ,
    "-kcvmn ca","-metric2t NDCG@10","-metric2T ERR@10");
    try {

            pb.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    

    And below is the error message:
    java.io.IOException: Cannot run program "C:\Learning to Rank": CreateProcess error=5, Access is denied
    at java.lang.ProcessBuilder.start(Unknown Source)
    at com.server.LTRModel.trainModel(LTRModel.java:129)
    at com.server.ResumeSearchAppMain.main(ResumeSearchAppMain.java:44)
    Caused by: java.io.IOException: CreateProcess error=5, Access is denied
    at java.lang.ProcessImpl.create(Native Method)
    at java.lang.ProcessImpl.<init>(Unknown Source)
    at java.lang.ProcessImpl.start(Unknown Source)
    ... 3 more</init>

    Even giving the everyone group full permissions to the "Learning to Rank" folder hasn't helped

     

    Last edit: Kwabena Mensa-Bonsu 2016-08-11
  • Lemur Project

    Lemur Project - 2016-08-11

    I'm not really familiar with the Java ProcessBuilder class. Have you properly defined the input/output streams (i.e. are they really coming/going where you think?). Does the program file have execute permissions?

    Why not try using the RankLib classes themselves to run your program? The Evaluator class will take a bunch of strings that define the arguments and values you want.

    Take a look at the RankLib test program EvaluatorTest.java in RankLib/test/ciir/umass/edu/eval/. You should be able to easily modify the arguments for your own purposes and run it using appropriate RankLib classes instead of via external Java ProcessBuilder.

    For more complete ideas on how to run a custom RankLib implementation, look at the Evaluator.java code in RankLib/src/ciir/umass/edu/eval/. Just keep the options you want from that program source for your own use.

     
  • Kwabena Mensa-Bonsu

    Thank you very much for your quick response as usual.Will let you know if I have further questions

     
  • Kwabena Mensa-Bonsu

    Hi Stephen,
    I have a few questions for you

    1. I get the error "Could not find or load main class ciir.umass.edu.learning.Evaluator" when I try to run the following command > java -jar RankLib-2.3.jar -help. Am I wrong in thinking all you all RankLib jar files are command line applications?
    2. I also got the error "Unknown command-line parameter: ciir.umass.edu.eval.Analyzer" when I tried toe following command > java -jar RankLib-2.1-patched.jar ciir.umass.edu.eval.Analyzer -all output/ -base baseline.ndcg.txt > analysis.txt. Is the parameter not supported on version 2.1.
    3. What is the minimum number of query- document pair required to properly train and build an LTR model?
    4. You get an x number of models when you run an x-fold cross validation. Is the idea to compare the models and choose the best for the LTR model?
    5. I plan to use the command line to train my model using RankLib-2.1-patched.jar but programmatically load the model and create datapoints to re-rank my unseen documents using RankLib-2.3.jar' s sourcecode.RankLib-2.1-patched.jar does not seem to support datapoints hence the reason for the different versions. Will that work?
    6. I saw in one of the posts that the latest version is 2.5.Can I mix and match  build the model using the command line but call the model programmatically? And if yes, can I get the download link?
    
     
  • Lemur Project

    Lemur Project - 2016-08-16

    Not entirely certain what you are trying to do.

    If you wish to run RankLib to build a model, save it, then load it and run it again on some training/test data, you can do that directly using the jar file (which invokes the Evaluator) without the need to write any of your own code.

    You then load your saved model and run it on more data to test how it does.

    Be sure RankLib.jar is on your classpath or explicitly define where it is when you run it.

    You can get the list of RankLib parameters by typing the java command with the -help parameter or no parameters at all.

      java -jar /home/mylibs/Ranklib.jar
    

    Use RankLib to build and save a ranking model (say LambdaMART) splitting the training data into 80% for training and 20% for testing using default training metric.

      java -jar RankLib.jar -train /mydata/train.txt -ranker 6 \
                 -tts 0.8 -save /mymodels/LMmodel.txt
    

    Then load the model and run it on some more data to see how it did.

     java -jar RankLib.jar -load /mymodels/LMmodel.txt \
               -test /mydata/test.txt
    

    Although k-fold cross validation can produce a model for each fold defined, it's really just a way to more thoroughly randomize the training process to better eliminate the possibility of producing a model that under or over fits the data.

    You should use the latest release which is RankLib-2.7. I would avoid mixing RankLib versions. Just use one version for everything you want to do.

      https://sourceforge.net/projects/lemur/files/lemur/RankLib-2.7/
    

    If you are going to customize RankLib for your own purposes, checkout the sources from SourceForge using SVN:

     svn checkout --username=myusername \
          svn+ssh://myusername@svn.code.sf.net/p/lemur/code/RankLib/trunk \
          RankLib-2.7
    

    You'll need Maven to build the sources.

     
  • Kwabena Mensa-Bonsu

    Hi Stephen,
    I am not able to download the souce file using the lin below.can you please check it again for me?
    svn checkout --username=myusername \
    svn+ssh://myusername@svn.code.sf.net/p/lemur/code/RankLib/trunk \
    RankLib-2.7

     
  • Kwabena Mensa-Bonsu

    It keeps asking for the password and then eventually throws up an error saying the path is incorrect

     
  • David Fisher

    David Fisher - 2016-08-17

    You need to use the read only (RO) instruction:

    svn checkout svn://svn.code.sf.net/p/lemur/code/RankLib/trunk RankLib-2.7

     
  • Kwabena Mensa-Bonsu

    Thank you

     
  • Kwabena Mensa-Bonsu

    Hello,
    Can someone please show mw how to implement the follwoiwing example in Java

    java -jar bin/RankLib.jar -load mymodel.txt -rank MQ2008/Fold1/test.txt -score myscorefile.txt

    I want to use the model to re-rank Lucene results but want to implement the above command using Java.I've started with the code below but not sure how to extract the score and assign it to my POJO

        RankerFactory rf = new RankerFactory();
        File myModel = new File("mymodel.txt");
    
        Ranker model = rf.loadRanker(myModel.getAbsolutePath());
        RankList results = model.rank(rankList);
    
     

Log in to post a comment.

MongoDB Logo MongoDB