Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
Measures.java
Package: Weka-3-2.rar [view]
Upload User: rhdiban
Upload Date: 2013-08-09
Package Size: 15085k
Code Size: 4k
Category:
Windows Develop
Development Platform:
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.
- */
- /*
- * Measures.java
- * Copyright (C) 1999 Yong Wang
- *
- */
- package weka.classifiers.m5;
- import java.io.*;
- import java.util.*;
- import weka.core.*;
- /**
- * Class for performance measures
- * @author Yong Wang (yongwang@cs.waikato.ac.nz)
- * @version $Revision: 1.4 $
- */
- public final class Measures {
- int type; /* type for printing */
- double correlation; /* correlation coefficient */
- double meanAbsErr; /* mean absolute error */
- double meanSqrErr; /* mean sqaured error */
- /**
- * Constructs a Measures object which could containing the performance measures
- */
- public Measures(){
- type = 0;
- correlation =0.0;
- meanAbsErr =0.0;
- meanSqrErr =0.0;
- }
- /**
- * Converts the performance measures to a string
- * @param absDev the absolute deviation of the class attribute
- * @param sd the standard deviation of the class attribute
- * @set the type of the performance measures, is one of "t","T","f","F","x", for training, test, training of one fold in cross-validation, test of one test in cross-validation, cross-validation final resuls respectively
- * @param smooth either "u" or "s" for unsmoothed or smoothed
- * @return the converted string
- */
- public final String toString(double absDev,double sd,String set,String smooth){
- StringBuffer text = new StringBuffer();
- switch(type){
- case 0:
- text.append(" Correlation coefficient:tt" + M5Utils.doubleToStringF(correlation,9,3) + "ttt " + set + smooth);
- text.append(" Mean absolute error:tt" + M5Utils.doubleToStringG(meanAbsErr,9,4) + "ttt " + set + smooth);
- text.append(" Root mean squared error:tt" + M5Utils.doubleToStringG(Math.sqrt(Math.abs(meanSqrErr)),9,4) + "ttt " + set + smooth);
- text.append(" Relative absolute error:tt" + M5Utils.doubleToStringF(meanAbsErr/absDev*100.0,9,2) + " %ttt " + set + smooth);
- text.append(" Root relative squared error:t" + M5Utils.doubleToStringF(Math.sqrt(Math.abs(meanSqrErr))/sd*100.0,9,2) + " %ttt " + set + smooth);
- break;
- case 1:
- text.append(" Correlation coefficient:tt" + M5Utils.doubleToStringF(correlation,9,3) + "ttt " + set + smooth);
- text.append(" Mean absolute error:tt" + M5Utils.doubleToStringG(meanAbsErr,9,4) + "ttt " + set + smooth);
- text.append(" Root mean squared error:tt" + M5Utils.doubleToStringG(Math.sqrt(Math.abs(meanSqrErr)),9,4) + "ttt " + set + smooth);
- text.append(" Relative absolute error:ttundefinedttt " + set + smooth);
- text.append(" Root relative squared error:tundefinedttt " + set + smooth);
- break;
- case 2:
- text.append(" Correlation coefficient:tt" + M5Utils.doubleToStringF(correlation,9,3) + "ttt " + set + smooth);
- text.append(" Mean absolute error:ttundefinedttt " + set + smooth);
- text.append(" Root mean squared error:ttundefinedttt " + set + smooth);
- text.append(" Relative absolute error:ttundefinedttt " + set + smooth);
- text.append(" Root relative squared error:tundefinedttt " + set + smooth);
- break;
- default:
- M5Utils.errorMsg("wrong type in Measures.print().");
- }
- return text.toString();
- }
- /**
- * Adds up performance measures for cross-validation
- * @param m performance measures of a fold
- */
- public final void incremental(Measures m){
- correlation += m.correlation;
- meanAbsErr += m.meanAbsErr;
- meanSqrErr += m.meanSqrErr;
- }
- }