congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
ClusteringSpec
Code IndexAdd Tabnine to your IDE (free)

How to use
ClusteringSpec
in
cascading.pattern.model.clustering

Best Java code snippets using cascading.pattern.model.clustering.ClusteringSpec (Showing top 7 results out of 315)

origin: cascading/pattern-core

public void setClusters( List<Cluster> clusters )
 {
 this.clusters.clear();
 for( Cluster cluster : clusters )
  addCluster( cluster );
 }
origin: cascading/pattern-core

public void addCluster( Cluster cluster )
 {
 if( getModelSchema().getExpectedFieldNames().size() != cluster.getPointsSize() )
  throw new IllegalArgumentException( "given points must be same size as active fields" );
 cluster.setOrdinal( getClusters().size() + 1 );
 this.clusters.add( cluster );
 }
origin: cascading/pattern-core

public ClusteringSpec( ModelSchema schemaParam, List<Cluster> clusters )
 {
 super( schemaParam );
 setClusters( clusters );
 }
origin: cascading/pattern-core

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 ) );
origin: cascading/pattern-core

public ClusterEvaluator[] getClusterEvaluator( Fields argumentFields )
 {
 List<Cluster> sorted = new ArrayList<Cluster>( clusters );
 final DataField predictedField = getModelSchema().getPredictedField( getModelSchema().getPredictedFieldNames().get( 0 ) );
 // order tables in category order as this is the declared field name order
 if( predictedField instanceof CategoricalDataField )
  {
  Ordering<Cluster> ordering = Ordering.natural().onResultOf( new Function<Cluster, Comparable>()
  {
  @Override
  public Comparable apply( Cluster cluster )
   {
   return ( (CategoricalDataField) predictedField ).getCategories().indexOf( cluster.getTargetCategory() );
   }
  } );
  Collections.sort( sorted, ordering );
  }
 ClusterEvaluator[] clusterEvaluators = new ClusterEvaluator[ sorted.size() ];
 for( int i = 0; i < sorted.size(); i++ )
  clusterEvaluators[ i ] = new ClusterEvaluator( argumentFields, sorted.get( i ), getComparisonMeasure(), getDefaultCompareFunction() );
 return clusterEvaluators;
 }
origin: cascading/pattern-core

@Override
public void prepare( FlowProcess flowProcess, OperationCall<Context<EvaluatorContext>> operationCall )
 {
 super.prepare( flowProcess, operationCall );
 operationCall.getContext().payload = new EvaluatorContext();
 operationCall.getContext().payload.evaluators = getSpec().getClusterEvaluator( operationCall.getArgumentFields() );
 operationCall.getContext().payload.results = new double[ getSpec().getClusters().size() ];
 }
origin: cascading/pattern-core

@Override
public void operate( FlowProcess flowProcess, FunctionCall<Context<EvaluatorContext>> functionCall )
 {
 ClusterEvaluator[] evaluators = functionCall.getContext().payload.evaluators;
 double[] results = functionCall.getContext().payload.results;
 for( int i = 0; i < evaluators.length; i++ )
  results[ i ] = evaluators[ i ].evaluate( functionCall.getArguments() );
 LOG.debug( "results: {}", results );
 // calc min distance
 double min = Doubles.min( results );
 int index = Doubles.indexOf( results, min );
 String category = evaluators[ index ].getTargetCategory();
 LOG.debug( "category: {}", category );
 // emit distance, and intermediate cluster category scores
 if( !getSpec().getModelSchema().isIncludePredictedCategories() )
  {
  functionCall.getOutputCollector().add( functionCall.getContext().result( category ) );
  return;
  }
 Tuple result = functionCall.getContext().tuple;
 result.set( 0, category );
 for( int i = 0; i < results.length; i++ )
  result.set( i + 1, results[ i ] );
 functionCall.getOutputCollector().add( result );
 }
}
cascading.pattern.model.clusteringClusteringSpec

Javadoc

Class ClusteringSpec is used to define a cluster model for scoring.

Most used methods

  • addCluster
  • <init>
  • getClusterEvaluator
  • getClusters
  • getComparisonMeasure
  • getDefaultCompareFunction
  • getModelSchema
  • setClusters
  • setComparisonMeasure
  • setDefaultCompareFunction

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onRequestPermissionsResult (Fragment)
  • requestLocationUpdates (LocationManager)
  • findViewById (Activity)
  • Menu (java.awt)
  • Kernel (java.awt.image)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now