Package cascading.pattern.model.generalregression

Examples of cascading.pattern.model.generalregression.RegressionTable


    Set<String> parameterList = GeneralRegressionUtil.createParameters( model );
    Set<String> covariateList = GeneralRegressionUtil.createCovariates( model );
    Set<String> factorsList = GeneralRegressionUtil.createFactors( model );

    RegressionTable regressionTable = GeneralRegressionUtil.createPPMatrix( model, parameterList, factorsList, covariateList );

    LinkFunction linkFunction = LinkFunction.getFunction( model.getLinkFunction().value() );

    GeneralRegressionSpec modelParam = new GeneralRegressionSpec( modelSchema, regressionTable, linkFunction );
View Full Code Here


*/
class RegressionUtil
  {
  public static RegressionTable createTable( org.dmg.pmml.RegressionTable regressionTable )
    {
    RegressionTable generalRegressionTable = new RegressionTable();

    String targetCategory = regressionTable.getTargetCategory();

    if( targetCategory != null )
      generalRegressionTable.setTargetCategory( targetCategory );

    generalRegressionTable.addParameter( new Parameter( "intercept", regressionTable.getIntercept() ) );

    int count = 0;

    for( CategoricalPredictor predictor : regressionTable.getCategoricalPredictors() )
      {
      String name = predictor.getName().getValue();
      String value = predictor.getValue();
      double coefficient = predictor.getCoefficient();

      generalRegressionTable.addParameter( new Parameter( "f" + count++, coefficient, new FactorPredictor( name, value ) ) );
      }

    for( NumericPredictor predictor : regressionTable.getNumericPredictors() )
      {
      String name = predictor.getName().getValue();
      int exponent = predictor.getExponent();

      double coefficient = predictor.getCoefficient();

      generalRegressionTable.addParameter( new Parameter( "f" + count++, coefficient, new CovariantPredictor( name, exponent ) ) );
      }

    return generalRegressionTable;
    }
View Full Code Here

  {
  private static final Logger LOG = LoggerFactory.getLogger( GeneralRegressionUtil.class );

  public static RegressionTable createPPMatrix( GeneralRegressionModel model, Set<String> parameterList, Set<String> factorsList, Set<String> covariateList )
    {
    RegressionTable regressionTable = new RegressionTable();

    for( org.dmg.pmml.PCell modelPCell : model.getParamMatrix().getPCells() )
      {
      String parameterName = modelPCell.getParameterName();
      double beta = modelPCell.getBeta();
      Integer df = modelPCell.getDf();

      regressionTable.addParameter( new cascading.pattern.model.generalregression.Parameter( parameterName, beta, df.intValue() ) );
      }

    for( org.dmg.pmml.PPCell modelPPCell : model.getPPMatrix().getPPCells() )
      {
      String parameterName = modelPPCell.getParameterName();
      String predictorName = modelPPCell.getPredictorName().getValue();
      String value = modelPPCell.getValue();

      cascading.pattern.model.generalregression.predictor.Predictor predictor;

      if( factorsList.contains( predictorName ) )
        predictor = new FactorPredictor( predictorName, value );
      else if( covariateList.contains( predictorName ) )
        predictor = new CovariantPredictor( predictorName, Long.parseLong( value ) );
      else
        throw new IllegalStateException( "unknown predictor name: " + predictorName );

      regressionTable.getParameter( parameterName ).addPredictor( predictor );
      }

    Set<String> parameterNames = regressionTable.getParameterNames();

    if( !parameterNames.containsAll( parameterList ) )
      LOG.warn( "different set of parameters: {}", Sets.difference( parameterNames, parameterList ) );

    return regressionTable;
View Full Code Here

    GeneralRegressionSpec regressionSpec = new GeneralRegressionSpec( modelSchema );

    regressionSpec.setLinkFunction( LinkFunction.LOGIT );

    RegressionTable table = new RegressionTable();

    table.addParameter( new Parameter( "p0", -16.9456960387809d ) );
    table.addParameter( new Parameter( "p1", 11.7592159418536d, new CovariantPredictor( "sepal_length" ) ) );
    table.addParameter( new Parameter( "p2", 7.84157781514097d, new CovariantPredictor( "sepal_width" ) ) );
    table.addParameter( new Parameter( "p3", -20.0880078273996d, new CovariantPredictor( "petal_length" ) ) );
    table.addParameter( new Parameter( "p4", -21.6076488529538d, new CovariantPredictor( "petal_width" ) ) );

    regressionSpec.addRegressionTable( table );

    PredictionRegressionFunction regressionFunction = new PredictionRegressionFunction( regressionSpec );
View Full Code Here

    ModelSchema modelSchema = new ModelSchema( expectedFields, predictedFields );

    GeneralRegressionSpec regressionSpec = new GeneralRegressionSpec( modelSchema );

    RegressionTable regressionTable = new RegressionTable();

    regressionTable.addParameter( new Parameter( "intercept", 2.24166872421148d ) );

    regressionTable.addParameter( new Parameter( "p1", 0.53448203205212d, new CovariantPredictor( "sepal_width" ) ) );
    regressionTable.addParameter( new Parameter( "p2", 0.691035562908626d, new CovariantPredictor( "petal_length" ) ) );
    regressionTable.addParameter( new Parameter( "p3", -0.21488157609202d, new CovariantPredictor( "petal_width" ) ) );

    regressionTable.addParameter( new Parameter( "p4", 0d, new FactorPredictor( "species", "setosa" ) ) );
    regressionTable.addParameter( new Parameter( "p5", -0.43150751368126d, new FactorPredictor( "species", "versicolor" ) ) );
    regressionTable.addParameter( new Parameter( "p6", -0.61868924203063d, new FactorPredictor( "species", "virginica" ) ) );

    regressionSpec.addRegressionTable( regressionTable );

    PredictionRegressionFunction regressionFunction = new PredictionRegressionFunction( regressionSpec );
View Full Code Here

    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 );
View Full Code Here

TOP

Related Classes of cascading.pattern.model.generalregression.RegressionTable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.