⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 values.java

📁 m5 code is used to bring data mining algorithms implementation
💻 JAVA
字号:
/* *    This program is free software; you can redistribute it and/or modify *    it under the terms of the GNU General Public License as published by *    the Free Software Foundation; either version 2 of the License, or *    (at your option) any later version. * *    This program is distributed in the hope that it will be useful, *    but WITHOUT ANY WARRANTY; without even the implied warranty of *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *    GNU General Public License for more details. * *    You should have received a copy of the GNU General Public License *    along with this program; if not, write to the Free Software *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *//* *    Values.java *    Copyright (C) 1999  * */package weka.classifiers.trees.m5;import java.io.*;import java.util.*;import weka.core.*;/** * Stores some statistics. * @author Yong Wang (yongwang@cs.waikato.ac.nz) * @version $Revision: 1.5 $ */public final class Values {  int  numInstances;        // number of the instances  int  missingInstances;    // number of the instances with missing values   int  first;               // index of the first instance  int  last;                // index of the last instance  int  attr;                // attribute  double  sum;              // sum of the instances for attribute  double  sqrSum;           // squared sum of the instances for attribute  double  va;               // variance  double  sd;               // standard deviation    /**   * Constructs an object which stores some statistics of the instances such    *      as sum, squared sum, variance, standard deviation   * @param low the index of the first instance   * @param high the index of the last instance   * @param attribute the attribute   * @param inst the instances   */  public Values(int low,int high,int attribute,Instances inst){    int i,count=0;    double value;    numInstances = high-low+1;    missingInstances = 0;    first = low;    last = high;    attr = attribute;    sum=0.0;    sqrSum=0.0;    for(i=first;i<=last;i++){      if(inst.instance(i).isMissing(attr)==false){	count++;	value = inst.instance(i).value(attr);	sum += value;	sqrSum += value * value;      }            if(count >1){	va = (sqrSum - sum * sum/count)/count;	va = Math.abs(va);	sd = Math.sqrt(va);      }      else {va = 0.0;  sd = 0.0;}          }  }  /**   * Converts the stats to a string   * @return the converted string   */  public final String  toString(){        StringBuffer text = new StringBuffer();    text.append("Print statistic values of instances (" + first + "-" + last + 		"\n");    text.append("    Number of instances:\t" + numInstances + "\n");    text.append("    NUmber of instances with unknowns:\t" + missingInstances +		"\n");    text.append("    Attribute:\t\t\t:" + attr + "\n");    text.append("    Sum:\t\t\t" + sum + "\n");    text.append("    Squared sum:\t\t" + sqrSum + "\n");    text.append("    Stanard Deviation:\t\t" + sd + "\n");    return text.toString();  }    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -