Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Predictions on test set

  1. #1

    Default Predictions on test set

    hi

    I try to get the prediction of an instance but not possible my code is:

    LinearRegression linear = new LinearRegression();
    linear.buildClassifier(entrenamiento);

    double pred = linear.classifyInstance(test.instance(0));
    System.out.print("ID: " + test.instance(i).value(0));
    System.out.print(", actual: " + test.classAttribute().value((int) test.instance(0).classValue()));
    System.out.println(", predicted: " + test.classAttribute().value((int) pred));



    I tested with weka and I get the perfect result:

    === Predictions on test set ===

    inst# actual predicted error
    1 ? 12 ?


    thanks..

  2. #2
    Join Date
    Jun 2013
    Posts
    44

    Default

    i didn't get well the what do you want to raise here a question or a suggestion .. I'm a bit juggling up in between to assume what to do with it to solve or to get a suggestion ..

  3. #3

    Default

    hi

    what I need is to get a prediction of an instance using LinearRegression
    The above code works well with J48 but with LinearRegression get blank results

    thanks

  4. #4
    Join Date
    Aug 2006
    Posts
    1,741

    Default

    Is your problem a classification problem (i.e. a nominal class attribute)? If so, then you are probably not wanting to use LinearRegression. Instead, for a linear model you should use LogisticRegression. You will then find that your code outputs what is expected. When the class is numeric, a regression scheme's classifyInstance() returns a real number and you can just output this directly. When the class is nominal, classifyInstance() returns an index (coded as a double) and, as your code does, you have to look up the predicted label in the class Attribute.

    Cheers,
    Mark.

  5. #5

    Default

    thanks

    best regards...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.