example.java

来自「Boosting算法软件包」· Java 代码 · 共 91 行

JAVA
91
字号
package jboost.examples;/** * The Example class holds a single Instance of an example, along with its Label.  */public class Example {  /** array of the attributes, null if attribute is undefined */  protected Instance m_instance;  /** a discrete-valued label */  protected Label m_label;  /** a private weight for this example */  protected double m_weight;  /** a textual comment */  protected String m_comment;  /** a pointer to the exampleDescription */  protected ExampleDescription m_exampleDescription;      /**   * Default ctor   * @param attArray   * @param label   * @param ed   */  public Example(Attribute[] attArray, Label label, double weight, ExampleDescription ed) {    m_instance = new Instance(attArray);    m_label=label;    m_weight= weight;    m_exampleDescription = ed;  }  /**   * This ctor defaults the ExampleDescriptions to null   * @param attArray   * @param label   */  public Example(Attribute[] attArray, Label label) {    this(attArray,label, 1.0, null);  }    /** set instance */  public void setInstance(Instance instance) {    m_instance=instance;  }    /** return the whole instance (array of attributes) */  public Instance getInstance() {    return m_instance;  }    /** returns the i'th attribute (null if undefined) */  public Attribute getAttribute(int i) {    return m_instance.attribute[i];  }    public Label getLabel() {    return(m_label);  }    public void setLabel(Label label) {    m_label=label;  }  /**   * Get the weight of this example   * @return weight   */  public double getWeight() {    return m_weight;  }    /**   * Set the weight of this example   * @param weight   */  public void setWeight(double weight) {    m_weight= weight;  }     public void setDescription(ExampleDescription ed) {    m_exampleDescription = ed;  }    public String toString() {    return "instance=" + m_instance.toString(m_exampleDescription)     + " label=" + m_label.toString() + "\n";  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?