Source Code Cross Referenced for MIPolyKernel.java in  » Science » weka » weka » classifiers » mi » supportVector » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » weka » weka.classifiers.mi.supportVector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    This program is free software; you can redistribute it and/or modify
003:         *    it under the terms of the GNU General Public License as published by
004:         *    the Free Software Foundation; either version 2 of the License, or
005:         *    (at your option) any later version.
006:         *
007:         *    This program is distributed in the hope that it will be useful,
008:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
009:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
010:         *    GNU General Public License for more details.
011:         *
012:         *    You should have received a copy of the GNU General Public License
013:         *    along with this program; if not, write to the Free Software
014:         *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
015:         */
016:
017:        /*
018:         * MIPolyKernel.java
019:         * Copyright (C) 2005 University of Waikato, Hamilton, New Zealand
020:         *
021:         */
022:
023:        package weka.classifiers.mi.supportVector;
024:
025:        import weka.classifiers.functions.supportVector.PolyKernel;
026:        import weka.core.Capabilities;
027:        import weka.core.Instance;
028:        import weka.core.Instances;
029:        import weka.core.MultiInstanceCapabilitiesHandler;
030:        import weka.core.Capabilities.Capability;
031:
032:        /**
033:         <!-- globalinfo-start -->
034:         * The polynomial kernel : K(x, y) = &lt;x, y&gt;^p or K(x, y) = (&lt;x, y&gt;+1)^p
035:         * <p/>
036:         <!-- globalinfo-end -->
037:         * 
038:         <!-- options-start -->
039:         * Valid options are: <p/>
040:         * 
041:         * <pre> -D
042:         *  Enables debugging output (if available) to be printed.
043:         *  (default: off)</pre>
044:         * 
045:         * <pre> -no-checks
046:         *  Turns off all checks - use with caution!
047:         *  (default: checks on)</pre>
048:         * 
049:         * <pre> -C &lt;num&gt;
050:         *  The size of the cache (a prime number).
051:         *  (default: 250007)</pre>
052:         * 
053:         * <pre> -E &lt;num&gt;
054:         *  The Exponent to use.
055:         *  (default: 1.0)</pre>
056:         * 
057:         * <pre> -L
058:         *  Use lower-order terms.
059:         *  (default: no)</pre>
060:         * 
061:         <!-- options-end -->
062:         *
063:         * @author Eibe Frank (eibe@cs.waikato.ac.nz)
064:         * @author Shane Legg (shane@intelligenesis.net) (sparse vector code)
065:         * @author Stuart Inglis (stuart@reeltwo.com) (sparse vector code)
066:         * @author Lin Dong (ld21@cs.waikato.ac.nz) (MIkernel)
067:         * @version $Revision: 1.2 $ 
068:         */
069:        public class MIPolyKernel extends PolyKernel implements 
070:                MultiInstanceCapabilitiesHandler {
071:
072:            /** for serialiation */
073:            private static final long serialVersionUID = 7926421479341051777L;
074:
075:            /**
076:             * default constructor - does nothing.
077:             */
078:            public MIPolyKernel() {
079:                super ();
080:            }
081:
082:            /**
083:             * Creates a new <code>MIPolyKernel</code> instance.
084:             * 
085:             * @param data	the training dataset used.
086:             * @param cacheSize	the size of the cache (a prime number)
087:             * @param exponent	the exponent to use
088:             * @param lowerOrder	whether to use lower-order terms
089:             * @throws Exception	if something goes wrong
090:             */
091:            public MIPolyKernel(Instances data, int cacheSize, double exponent,
092:                    boolean lowerOrder) throws Exception {
093:
094:                super (data, cacheSize, exponent, lowerOrder);
095:            }
096:
097:            /**
098:             * 
099:             * @param id1   	the index of instance 1
100:             * @param id2		the index of instance 2
101:             * @param inst1	the instance 1 object
102:             * @return 		the dot product
103:             * @throws Exception 	if something goes wrong
104:             */
105:            protected double evaluate(int id1, int id2, Instance inst1)
106:                    throws Exception {
107:
108:                double result, res;
109:                Instances data1 = new Instances(inst1.relationalValue(1));
110:                Instances data2;
111:                if (id1 == id2)
112:                    data2 = new Instances(data1);
113:                else
114:                    data2 = new Instances(m_data.instance(id2).relationalValue(
115:                            1));
116:
117:                res = 0;
118:                for (int i = 0; i < data1.numInstances(); i++) {
119:                    for (int j = 0; j < data2.numInstances(); j++) {
120:                        result = dotProd(data1.instance(i), data2.instance(j));
121:
122:                        // Use lower order terms?
123:                        if (getUseLowerOrder()) {
124:                            result += 1.0;
125:                        }
126:                        if (getExponent() != 1.0) {
127:                            result = Math.pow(result, getExponent());
128:                        }
129:
130:                        res += result;
131:                    }
132:                }
133:
134:                return res;
135:            }
136:
137:            /** 
138:             * Returns the Capabilities of this kernel.
139:             *
140:             * @return            the capabilities of this object
141:             * @see               Capabilities
142:             */
143:            public Capabilities getCapabilities() {
144:                Capabilities result = super .getCapabilities();
145:
146:                // attributes
147:                result.enable(Capability.NOMINAL_ATTRIBUTES);
148:                result.enable(Capability.RELATIONAL_ATTRIBUTES);
149:                result.enable(Capability.MISSING_VALUES);
150:
151:                // class
152:                result.enableAllClasses();
153:
154:                // other
155:                result.enable(Capability.ONLY_MULTIINSTANCE);
156:
157:                return result;
158:            }
159:
160:            /**
161:             * Returns the capabilities of this multi-instance kernel for the
162:             * relational data.
163:             *
164:             * @return            the capabilities of this object
165:             * @see               Capabilities
166:             */
167:            public Capabilities getMultiInstanceCapabilities() {
168:                Capabilities result = super .getCapabilities();
169:
170:                // class
171:                result.disableAllClasses();
172:                result.enable(Capability.NO_CLASS);
173:
174:                return result;
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.