jeffheaton / encog-java-core

http://www.heatonresearch.com/encog
Other
743 stars 268 forks source link

Unsupervised PNN machine learning method #161

Open wiemp opened 10 years ago

wiemp commented 10 years ago

Hello Jeff, while checking in the PNN source code from the Analyst, I saw, that there is an interface, to use unsupervised machine learning method available, but no interface to higher levels, to use it. I would like to suggest an extension for this, to play around with it:

org.encog.app.analyst.AnalystGoal:

public enum AnalystGoal { /* * Goal of regression. / Regression,

/**
 * Goal of classification.
 */
Classification,

/**
 * Goal of unsupervised
 */
Unsupervised

}

org.encog.app.analyst.wizard:

private void generatePNN(final int inputColumns, final int outputColumns) {

    StringBuilder arch = new StringBuilder();
    arch.append("?->");
    if (this.goal == AnalystGoal.Classification) {
        arch.append("C");
    } else if (this.goal == AnalystGoal.Unsupervised) {
        arch.append("U");
    } else {
        arch.append("R");
    }

……

org.encog.app.analyst.script.prop:

public final void setProperty(final String name, final AnalystGoal value) {
    switch (value) {
    case Classification:
        this.data.put(name, "classification");
        break;
    case Regression:
        this.data.put(name, "regression");
        break;
    case Unsupervised:
        this.data.put(name, "unsupervised");
        break;
    default:
        this.data.put(name, "");
    }

}

org.encog.neural.pnn.PersistBasicPNN:

public static String outputModeToString(final PNNOutputMode mode) {
    switch (mode) {
    case Regression:
        return "regression";
    case Unsupervised:
        return "unsupervised";
    case Classification:
        return "classification";
    default:
        return null;
    }
}

public static PNNOutputMode stringToOutputMode(final String mode) {
    if (mode.equalsIgnoreCase("regression")) {
        return PNNOutputMode.Regression;
    } else if (mode.equalsIgnoreCase("unsupervised")) {
        return PNNOutputMode.Unsupervised;
    } else if (mode.equalsIgnoreCase("classification")) {
        return PNNOutputMode.Classification;
    } else {
        return null;
    }
}
jeffheaton commented 10 years ago

Looks like a good change. I am going to add this to Encog 3.3, as 3.2 is just about complete.