Changeset 41 for trunk/CrossPare/src/de/ugoe/cs/cpdp/wekaclassifier
- Timestamp:
- 09/24/15 10:59:05 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/wekaclassifier/FixClass.java
r30 r41 1 // Copyright 2015 Georg-August-Universität Göttingen, Germany 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 1 15 package de.ugoe.cs.cpdp.wekaclassifier; 2 3 16 4 17 import weka.classifiers.AbstractClassifier; … … 16 29 public class FixClass extends AbstractClassifier { 17 30 18 31 private static final long serialVersionUID = 1L; 19 32 20 33 private double fixedClassValue = 0.0d; 21 34 22 23 24 35 public FixClass() { 36 // TODO Auto-generated constructor stub 37 } 25 38 26 27 28 29 30 31 32 33 34 39 /** 40 * Returns default capabilities of the classifier. 41 * 42 * @return the capabilities of this classifier 43 */ 44 @Override 45 public Capabilities getCapabilities() { 46 Capabilities result = super.getCapabilities(); 47 result.disableAll(); 35 48 36 37 38 39 40 41 42 49 // attributes 50 result.enable(Capability.NOMINAL_ATTRIBUTES); 51 result.enable(Capability.NUMERIC_ATTRIBUTES); 52 result.enable(Capability.DATE_ATTRIBUTES); 53 result.enable(Capability.STRING_ATTRIBUTES); 54 result.enable(Capability.RELATIONAL_ATTRIBUTES); 55 result.enable(Capability.MISSING_VALUES); 43 56 44 45 46 47 57 // class 58 result.enable(Capability.NOMINAL_CLASS); 59 result.enable(Capability.NUMERIC_CLASS); 60 result.enable(Capability.MISSING_CLASS_VALUES); 48 61 49 50 62 // instances 63 result.setMinimumNumberInstances(0); 51 64 52 53 65 return result; 66 } 54 67 55 56 57 58 68 @Override 69 public void setOptions(String[] options) throws Exception { 70 fixedClassValue = Double.parseDouble(Utils.getOption('C', options)); 71 } 59 72 60 61 62 63 73 @Override 74 public double classifyInstance(Instance instance) { 75 return fixedClassValue; 76 } 64 77 65 66 67 68 78 @Override 79 public void buildClassifier(Instances traindata) throws Exception { 80 // do nothing 81 } 69 82 }
Note: See TracChangeset
for help on using the changeset viewer.