Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Summary statistics with more decimals

  1. #1
    Join Date
    Oct 2015
    Posts
    6

    Exclamation Summary statistics with more decimals

    Hi,

    How can I compute the summary statistics of my variables with 8 decimal places?

  2. #2
    Join Date
    Oct 2015
    Posts
    6

    Default Solved

    I finally found a java code for that. This is the code:

    HTML Code:
    package weka.api;
    //import required classes
    import weka.experiment.Stats;
    import weka.core.AttributeStats;
    import weka.core.Instance;
    import weka.core.Instances;
    import weka.core.converters.ConverterUtils.DataSource;
     
    public class AttInst {
           public static void main(String args[]) throws Exception{
                  //load dataset
                  DataSource source = new DataSource("D:/y.arff");
                  //get instances object 
                  Instances data = source.getDataSet();
                  //set class index .. as the last attribute
               if (data.classIndex() == -1) {
                  data.setClassIndex(data.numAttributes() - 1);
               }
               //get number of attributes (notice class is not counted)
                  int numAttr = data.numAttributes() - 1;
                  for (int i = 0; i < numAttr; i++) {
                         //check if current attr is of type nominal
                         if (data.attribute(i).isNominal()) {
                               System.out.println("The "+i+"th Attribute is Nominal");       
                               //get number of values
                               int n = data.attribute(i).numValues();
                               System.out.println("The "+i+"th Attribute has: "+n+" values");
                         }                    
                        
                         //get an AttributeStats object
                         AttributeStats as = data.attributeStats(i);
                         int dC = as.distinctCount;
                         System.out.println("The "+i+"th Attribute has: "+dC+" distinct values");
                        
                         //get a Stats object from the AttributeStats
                         if (data.attribute(i).isNumeric()){
                               System.out.println("The "+i+"th Attribute is Numeric");       
                             Stats s = as.numericStats;
                             System.out.println("The "+i+"th Attribute has min value: "+s.min+" and max value: "+s.max+" and mean value: "+s.mean+" and stdDev value: "+s.stdDev );
                         }
          
           }
                 
                 
           }
    }

    Quote Originally Posted by tahamokfi View Post
    Hi,

    How can I compute the summary statistics of my variables with 8 decimal places?
    Last edited by tahamokfi; 10-28-2015 at 02:06 PM. Reason: typo

Tags for this Thread

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.