예제 #1
0
  @Override
  protected SBPrintStream toJavaInit(SBPrintStream sb, CodeGeneratorPipeline fileCtx) {
    sb = super.toJavaInit(sb, fileCtx);
    sb.ip("public boolean isSupervised() { return " + isSupervised() + "; }").nl();
    sb.ip("public int nfeatures() { return " + _output.nfeatures() + "; }").nl();
    sb.ip("public int nclasses() { return " + _output.nclasses() + "; }").nl();

    JCodeGen.toStaticVar(sb, "RESCNT", _output._rescnt, "Count of categorical levels in response.");
    JCodeGen.toStaticVar(
        sb, "APRIORI", _output._apriori_raw, "Apriori class distribution of the response.");
    JCodeGen.toStaticVar(sb, "PCOND", _output._pcond_raw, "Conditional probability of predictors.");

    double[] dlen = null;
    if (_output._ncats > 0) {
      dlen = new double[_output._ncats];
      for (int i = 0; i < _output._ncats; i++) dlen[i] = _output._domains[i].length;
    }
    JCodeGen.toStaticVar(
        sb, "DOMLEN", dlen, "Number of unique levels for each categorical predictor.");
    return sb;
  }
예제 #2
0
  @Override
  protected SB toJavaInit(SB sb, SB fileContextSB) {
    sb = super.toJavaInit(sb, fileContextSB);
    sb.ip("public boolean isSupervised() { return " + isSupervised() + "; }").nl();
    sb.ip("public int nfeatures() { return " + _output.nfeatures() + "; }").nl();
    sb.ip("public int nclasses() { return " + _parms._k + "; }").nl();

    if (_output._nnums > 0) {
      JCodeGen.toStaticVar(
          sb,
          "NORMMUL",
          _output._normMul,
          "Standardization/Normalization scaling factor for numerical variables.");
      JCodeGen.toStaticVar(
          sb,
          "NORMSUB",
          _output._normSub,
          "Standardization/Normalization offset for numerical variables.");
    }
    JCodeGen.toStaticVar(sb, "CATOFFS", _output._catOffsets, "Categorical column offsets.");
    JCodeGen.toStaticVar(sb, "PERMUTE", _output._permutation, "Permutation index vector.");
    JCodeGen.toStaticVar(sb, "EIGVECS", _output._eigenvectors_raw, "Eigenvector matrix.");
    return sb;
  }