Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:18:10+00:00 2026-06-12T07:18:10+00:00

I am generating decision trees in Weka in Java code as follows: J48 j48DecisionTree

  • 0

I am generating decision trees in Weka in Java code as follows:

        J48 j48DecisionTree = new J48();   
        Instances data = null;
        data = new Instances(new BufferedReader(new FileReader(dt.getArffFile())));              
        data.setClassIndex(data.numAttributes() - 1);
        j48DecisionTree.buildClassifier(data);

Can I save the results of the Weka results buffer to a text file in the program, such that the following can be saved at run-time to a text file:

=== Stratified cross-validation ===
=== Summary ===

Correctly Classified Instances         229               40.1754 %
Incorrectly Classified Instances       341               59.8246 %
Kappa statistic                          0.2022
Mean absolute error                      0.1916
Root mean squared error                  0.3138
Relative absolute error                 80.8346 %
Root relative squared error             91.1615 %
Coverage of cases (0.95 level)          96.3158 %
 Mean rel. region size (0.95 level)      70.9774 %
Total Number of Instances              570     

=== Detailed Accuracy By Class ===

           TP Rate   FP Rate   Precision   Recall  F-Measure   ROC Area  Class
             0.44      0.012      0.786     0.44      0.564      0.76     Business and finance and economics
             0         0          0         0         0          0.616    Fashion and celebrity lifestyle
             0.125     0.01       0.667     0.125     0.211      0.663    Film
             0         0.002      0         0         0          0.617    Music
             0.931     0.78       0.318     0.931     0.474      0.633    News and current affairs
             0.11      0.006      0.786     0.11      0.193      0.653    Science and nature and technology
             0.74      0.012      0.86      0.74      0.796      0.85     Sport

Weighted Avg. 0.402 0.224 0.465 0.402 0.316 0.667

=== Confusion Matrix ===

  a   b   c   d   e   f   g   <-- classified as
 22   0   0   0  25   2   1 |   a = Business and finance and economics
  0   0   1   0  59   0   0 |   b = Fashion and celebrity lifestyle
  0   0  10   1  69   0   0 |   c = Film
  0   0   1   0  69   0   0 |   d = Music
  5   0   2   0 149   0   4 |   e = News and current affairs
  1   0   0   0  87  11   1 |   f = Science and nature and technology
  0   0   1   0  11   1  37 |   g = Sport

dt is an instance of a class of mine to represent decision tree details.

As I’m running a large number of classifiers, this would help somewhat.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:18:12+00:00Added an answer on June 12, 2026 at 7:18 am

    Yes, this can be done. But you need to create an instance of Evaluation in Weka and call the appropriate methods from the instance:

    Evaluation eval = new Evaluation(data);
    eval.evaluateModel(j48DecisionTree, data);
    System.out.println(eval.toSummaryString("\nResults\n======\n", true));
    

    Will give a summary.

    But then methods such as:

    eval.pctCorrect();
    

    Can be called. See Weka Javadoc for further info.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Generating normal columnar data in excel file is quite easy but does any one
When generating models from postgresql with ColdFusion Illudium Code generator the boolean values get
In generating a select tag for a Boolean value, I use the following code:
I am generating pdf using java and itext. When I add image that we
I'm looking for the most suitable tool for generating dynamic geographical maps in Java
For generating random string i written code like this But if the function is
When generating new lines in a continuous form, the last line appears with a
When generating graphs and showing different sets of data it usually a good idea
When generating Java from an XSD via the XJC compiler, I always get the
Generating a UIWebView with on-board resources is easy enough with the following code. NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.