Changeset 41 for trunk/CrossPare/src/de/ugoe/cs/cpdp/training/FixClass.java
- Timestamp:
- 09/24/15 10:59:05 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CrossPare/src/de/ugoe/cs/cpdp/training/FixClass.java
r31 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.training; 2 16 … … 14 28 * @author Steffen Herbold 15 29 */ 16 public class FixClass extends AbstractClassifier implements ITrainingStrategy, IWekaCompatibleTrainer { 30 public class FixClass extends AbstractClassifier implements ITrainingStrategy, 31 IWekaCompatibleTrainer 32 { 17 33 18 34 private static final long serialVersionUID = 1L; 19 35 20 36 private double fixedClassValue = 0.0d; 21 37 22 23 24 25 26 27 28 29 30 38 /** 39 * Returns default capabilities of the classifier. 40 * 41 * @return the capabilities of this classifier 42 */ 43 @Override 44 public Capabilities getCapabilities() { 45 Capabilities result = super.getCapabilities(); 46 result.disableAll(); 31 47 32 33 34 35 36 37 38 48 // attributes 49 result.enable(Capability.NOMINAL_ATTRIBUTES); 50 result.enable(Capability.NUMERIC_ATTRIBUTES); 51 result.enable(Capability.DATE_ATTRIBUTES); 52 result.enable(Capability.STRING_ATTRIBUTES); 53 result.enable(Capability.RELATIONAL_ATTRIBUTES); 54 result.enable(Capability.MISSING_VALUES); 39 55 40 41 42 43 56 // class 57 result.enable(Capability.NOMINAL_CLASS); 58 result.enable(Capability.NUMERIC_CLASS); 59 result.enable(Capability.MISSING_CLASS_VALUES); 44 60 45 46 61 // instances 62 result.setMinimumNumberInstances(0); 47 63 48 49 64 return result; 65 } 50 66 51 52 53 54 67 @Override 68 public void setOptions(String[] options) throws Exception { 69 fixedClassValue = Double.parseDouble(Utils.getOption('C', options)); 70 } 55 71 56 57 58 59 72 @Override 73 public double classifyInstance(Instance instance) { 74 return fixedClassValue; 75 } 60 76 61 62 63 64 77 @Override 78 public void buildClassifier(Instances traindata) throws Exception { 79 // do nothing 80 } 65 81 66 @Override 67 public void setParameter(String parameters) { 68 try { 69 this.setOptions(parameters.split(" ")); 70 } catch (Exception e) { 71 e.printStackTrace(); 72 } 73 } 82 @Override 83 public void setParameter(String parameters) { 84 try { 85 this.setOptions(parameters.split(" ")); 86 } 87 catch (Exception e) { 88 e.printStackTrace(); 89 } 90 } 74 91 75 76 77 78 92 @Override 93 public void apply(Instances traindata) { 94 // do nothing! 95 } 79 96 80 81 82 83 97 @Override 98 public String getName() { 99 return "FixClass"; 100 } 84 101 85 86 87 88 102 @Override 103 public Classifier getClassifier() { 104 return this; 105 } 89 106 90 107 }
Note: See TracChangeset
for help on using the changeset viewer.