iddescription.java
来自「Boosting算法软件包」· Java 代码 · 共 51 行
JAVA
51 行
package jboost.examples;import jboost.controller.Configuration;import jboost.tokenizer.BadAttException;/** * The description for a private weight of each example. */public class IdDescription extends IntegerDescription { public static final int MAX_ID = Integer.MAX_VALUE; IdDescription(String name, Configuration config, int default_val) throws ClassNotFoundException { super(name,config); } /** * Reads an id * If no value is specified, default to 1 * If the value is negative, return 0 as the weight. * If the value is greater than 1, return 1. * @param weight the string representation of the weight * @return Attribute the RealAttribute corresponding to the weight */ public Attribute str2Att(String id) throws BadAttException { double att = 1.0; // initialized because try complains otherwise. if (id != null) { id= id.trim(); if (id.length() != 0) { try { att= Double.parseDouble(id); } catch (NumberFormatException nfe) { throw new BadAttException(id + " is not a float",0,0); } if (att < 0) { att= 0; throw new BadAttException("The id: " + id + " is less than 0",0,0); } if (att > MAX_ID) { throw new BadAttException("The id: " + id + " is larger than MAX_ID=" + MAX_ID,0,0); } } } return new RealAttribute (att); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?