Skip to content

Commit

Permalink
now derived from RandomizableClassifier
Browse files Browse the repository at this point in the history
  • Loading branch information
fracpete committed Feb 10, 2023
1 parent c97b4eb commit 038d2fb
Showing 1 changed file with 6 additions and 57 deletions.
63 changes: 6 additions & 57 deletions src/main/java/weka/classifiers/functions/LightGBM.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
import com.microsoft.ml.lightgbm.PredictionType;
import io.github.metarank.lightgbm4j.LGBMBooster;
import io.github.metarank.lightgbm4j.LGBMDataset;
import weka.classifiers.AbstractClassifier;
import weka.classifiers.RandomizableClassifier;
import weka.core.Capabilities;
import weka.core.Instance;
import weka.core.Instances;
import weka.core.Option;
import weka.core.Randomizable;
import weka.core.RevisionUtils;
import weka.core.SelectedTag;
import weka.core.Tag;
Expand Down Expand Up @@ -56,8 +55,8 @@
* @author fracpete (fracpete at waikato dot ac dot nz)
*/
public class LightGBM
extends AbstractClassifier
implements TechnicalInformationHandler, Randomizable {
extends RandomizableClassifier
implements TechnicalInformationHandler {

private static final long serialVersionUID = -6138516902729782286L;

Expand Down Expand Up @@ -117,9 +116,6 @@ public class LightGBM
/** whether to randomize before splitting off the validation set. */
protected boolean m_RandomizeBeforeSplit = false;

/** the seed value to use for the randomization. */
protected int m_Seed = 1;

/** the booster instance in use. */
protected transient LGBMBooster m_Booster = null;

Expand Down Expand Up @@ -178,6 +174,7 @@ public TechnicalInformation getTechnicalInformation() {
*
* @return an enumeration of all the available options.
*/
@Override
public Enumeration listOptions() {
Vector<Option> result;
String desc;
Expand Down Expand Up @@ -219,12 +216,6 @@ public Enumeration listOptions() {
+ "\t(default: off)\n",
"R", 0, "-R"));

result.addElement(new Option(
"\tThe seed value to use for randomizing the data before splitting off\n"
+ "\tthe validations set.\n"
+ "\t(default: 1)\n",
"S", 1, "-S <seed>"));

return result.elements();
}

Expand All @@ -237,6 +228,7 @@ public Enumeration listOptions() {
* @param options the options to parse
* @throws Exception if parsing fails
*/
@Override
public void setOptions(String[] options) throws Exception {
String tmpStr;

Expand All @@ -262,12 +254,6 @@ public void setOptions(String[] options) throws Exception {

setRandomizeBeforeSplit(Utils.getFlag('R', options));

tmpStr = Utils.getOption('S', options);
if (tmpStr.length() != 0)
setSeed(Integer.parseInt(tmpStr));
else
setSeed(1);

super.setOptions(options);
}

Expand All @@ -276,6 +262,7 @@ public void setOptions(String[] options) throws Exception {
*
* @return an array of strings suitable for passing to setOptions
*/
@Override
public String[] getOptions() {
List<String> result;

Expand Down Expand Up @@ -449,34 +436,6 @@ public String randomizeBeforeSplitTipText() {
return "If enabled, the data gets randomized before splitting off the validation set.";
}

/**
* Sets the seed value to use when randomizing the data before splitting off the validation set.
*
* @param value the seed value
*/
public void setSeed(int value) {
m_Seed = value;
}

/**
* Gets the seed value to use when randomizing the data before splitting off the validation set.
*
* @return the seed value
*/
public int getSeed() {
return m_Seed;
}

/**
* Returns the tip text for this property
*
* @return tip text for this property suitable for
* displaying in the explorer/experimenter gui
*/
public String seedTipText() {
return "The seed value to use when randomizing the data before splitting off the validation set.";
}

/**
* Returns the Capabilities of this classifier.
*
Expand Down Expand Up @@ -660,16 +619,6 @@ public String toString() {
return result.toString();
}

/**
* Returns the revision string.
*
* @return the revision
*/
@Override
public String getRevision() {
return RevisionUtils.extract("$Revision$");
}

/**
* Main method.
*
Expand Down

0 comments on commit 038d2fb

Please sign in to comment.