ModelSchema modelSchema = new ModelSchema( expectedFields, predictedFields );
modelSchema.setPredictedCategories( "species", "setosa", "versicolor", "virginica" );
GeneralRegressionSpec regressionSpec = new GeneralRegressionSpec( modelSchema );
regressionSpec.setNormalization( new SoftMaxNormalization() );
{
RegressionTable regressionTable = new RegressionTable( "versicolor" );
regressionTable.addParameter( new Parameter( "intercept", 86.7061379450354d ) );
regressionTable.addParameter( new Parameter( "p0", -11.3336819785783d, new CovariantPredictor( "sepal_length" ) ) );
regressionTable.addParameter( new Parameter( "p1", -40.8601511206805d, new CovariantPredictor( "sepal_width" ) ) );
regressionTable.addParameter( new Parameter( "p2", 38.439099544679d, new CovariantPredictor( "petal_length" ) ) );
regressionTable.addParameter( new Parameter( "p3", -12.2920287460217d, new CovariantPredictor( "petal_width" ) ) );
regressionSpec.addRegressionTable( regressionTable );
}
{
RegressionTable regressionTable = new RegressionTable( "virginica" );
regressionTable.addParameter( new Parameter( "intercept", -111.666532867146d ) );
regressionTable.addParameter( new Parameter( "p0", -47.1170644419116d, new CovariantPredictor( "sepal_length" ) ) );
regressionTable.addParameter( new Parameter( "p1", -51.6805606658275d, new CovariantPredictor( "sepal_width" ) ) );
regressionTable.addParameter( new Parameter( "p2", 108.27736751831d, new CovariantPredictor( "petal_length" ) ) );
regressionTable.addParameter( new Parameter( "p3", 54.0277175236148d, new CovariantPredictor( "petal_width" ) ) );
regressionSpec.addRegressionTable( regressionTable );
}
{
RegressionTable regressionTable = new RegressionTable( "setosa" );
regressionTable.addParameter( new Parameter( "intercept", 0d ) );
regressionSpec.addRegressionTable( regressionTable );
}
CategoricalRegressionFunction regressionFunction = new CategoricalRegressionFunction( regressionSpec );
{