Package cascading.pattern.model.clustering

Examples of cascading.pattern.model.clustering.ClusteringSpec


    ComparisonMeasure comparisonMeasure = model.getComparisonMeasure();

    if( comparisonMeasure.getKind() != ComparisonMeasure.Kind.DISTANCE )
      throw new UnsupportedOperationException( "unsupported comparison kind, got: " + comparisonMeasure.getKind() );

    ClusteringSpec clusteringSpec = new ClusteringSpec( modelSchema );

    Measure measure = comparisonMeasure.getMeasure();
    if( measure instanceof Euclidean )
      clusteringSpec.setComparisonMeasure( new EuclideanMeasure() );
    else if( measure instanceof SquaredEuclidean )
      clusteringSpec.setComparisonMeasure( new SquaredEuclideanMeasure() );
    else
      throw new UnsupportedOperationException( "unsupported comparison measure: " + comparisonMeasure );

    clusteringSpec.setDefaultCompareFunction( ClusteringUtil.setComparisonFunction( model ) );

    for( Cluster cluster : model.getClusters() )
      {
      List<Double> exemplar = (List<Double>) PMMLUtil.parseArray( cluster.getArray() );

      LOG.debug( "exemplar: {}", exemplar );

      clusteringSpec.addCluster( new cascading.pattern.model.clustering.Cluster( cluster.getName(), exemplar ) );
      }

    return create( tail, modelSchema, new ClusteringFunction( clusteringSpec ) );
    }
View Full Code Here


      .append( new Fields( "petal_length", double.class ) )
      .append( new Fields( "petal_width", double.class ) );

    ModelSchema modelSchema = new ModelSchema( expectedFields, predictedFields );

    ClusteringSpec clusteringSpec = new ClusteringSpec( modelSchema );

    clusteringSpec.setDefaultCompareFunction( new AbsoluteDifferenceCompareFunction() );
    clusteringSpec.setComparisonMeasure( new SquaredEuclideanMeasure() );

    clusteringSpec.addCluster( new Cluster( "1", 5.006d, 3.428d, 1.462d, 0.246d ) );
    clusteringSpec.addCluster( new Cluster( "2", 5.9296875d, 2.7578125d, 4.4109375d, 1.4390625d ) );
    clusteringSpec.addCluster( new Cluster( "3", 6.85277777777778d, 3.075d, 5.78611111111111d, 2.09722222222222d ) );

    ClusteringFunction clusteringFunction = new ClusteringFunction( clusteringSpec );

//    TupleEntry tupleArguments = new TupleEntry( expectedFields, new Tuple( 6.9d, 3.1d, 4.9d, 1.5d ) );
    TupleEntry tupleArguments = new TupleEntry( expectedFields, new Tuple( 6.4d, 3.1d, 5.5d, 1.8d ) );
View Full Code Here

TOP

Related Classes of cascading.pattern.model.clustering.ClusteringSpec

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.