EdwardRaff / JSAT

Java Statistical Analysis Tool, a Java library for Machine Learning

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NPE when getting parameters from (a few) Parameterized algos getValueString

salamanders opened this issue · comments

jsat.classifiers.linear.BBR
Exception in thread "main" java.lang.NullPointerException at jsat.parameters.ObjectParameter.getValueString(ObjectParameter.java:38)

The context I was calling it in:

  public String toString() {
    if (classifier instanceof Parameterized) {
      state.putAll(((Parameterized) classifier).getParameters().stream()
          .collect(Collectors.toMap(Parameter::getName, Parameter::getValueString)));
    }
    return GSON.toJson(state);
  }

Could you make a more contained example where this errors out?

Now that newGLMNET is implemented BBR isn't a big loss. The former is faster and much more accurate.

Tighter example:

  public static void main(String[] args) {
    Classifier classifier = new jsat.classifiers.linear.BBR(7);
    if (classifier instanceof Parameterized) {
      for (final Parameter p : ((Parameterized) classifier).getParameters()) {
        System.out.print(p.getName() + "=" + p.getValueString());
      }
    }
  }

I have no particular love for BBR, it just looked like a missed null check in the getValueString.

Fixed!