public void addModel(Model m) {
    if (Model.isSubclass(m.getClass(), FunctionModel.class)) {
      if (function == null) {
        function = (FunctionModel) m;
      } else {
        function = new SumFunction(function, (FunctionModel) m);
      }

      dispatchChangedEvent();
    }
  }
Esempio n. 2
0
  public Predicted(DataFrame<M> f, String pfn) {
    frame = f;
    numericField = null;

    Class<M> mcls = frame.getModelClass();

    try {
      Field mf = mcls.getField(pfn);
      Class t = mf.getType();
      if (Model.isSubclass(t, Number.class)) {
        numericField = mf;
      } else {
        throw new IllegalArgumentException(
            String.format("Field %s is not numeric", pfn, t.getName()));
      }

    } catch (NoSuchFieldException e) {
      e.printStackTrace();
      throw new IllegalArgumentException(String.format("Unknown field name: %s", pfn));
    }
  }