idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
33,700
public double getWeight ( double distance , double max , double stddev ) { if ( stddev <= 0 ) { return 1 ; } double scaleddistance = distance / stddev ; return stddev * FastMath . exp ( - .5 * scaleddistance ) ; }
Get exponential weight max is ignored .
33,701
protected static < A > int [ ] sortedIndex ( final NumberArrayAdapter < ? , A > adapter , final A data , int len ) { int [ ] s1 = MathUtil . sequence ( 0 , len ) ; IntegerArrayQuickSort . sort ( s1 , ( x , y ) -> Double . compare ( adapter . getDouble ( data , x ) , adapter . getDouble ( data , y ) ) ) ; return s1 ; }
Build a sorted index of objects .
33,702
protected static < A > int [ ] discretize ( NumberArrayAdapter < ? , A > adapter , A data , final int len , final int bins ) { double min = adapter . getDouble ( data , 0 ) , max = min ; for ( int i = 1 ; i < len ; i ++ ) { double v = adapter . getDouble ( data , i ) ; if ( v < min ) { min = v ; } else if ( v > max ) {...
Discretize a data set into equi - width bin numbers .
33,703
protected void finishGridRow ( ) { GridBagConstraints constraints = new GridBagConstraints ( ) ; constraints . gridwidth = GridBagConstraints . REMAINDER ; constraints . weightx = 0 ; final JLabel icon ; if ( param . isOptional ( ) ) { if ( param . isDefined ( ) && param . tookDefaultValue ( ) && ! ( param instanceof F...
Complete the current grid row adding the icon at the end
33,704
private double normalize ( int d , double val ) { d = ( mean . length == 1 ) ? 0 : d ; return ( val - mean [ d ] ) / stddev [ d ] ; }
Normalize a single dimension .
33,705
private static EigenPair [ ] processDecomposition ( EigenvalueDecomposition evd ) { double [ ] eigenvalues = evd . getRealEigenvalues ( ) ; double [ ] [ ] eigenvectors = evd . getV ( ) ; EigenPair [ ] eigenPairs = new EigenPair [ eigenvalues . length ] ; for ( int i = 0 ; i < eigenvalues . length ; i ++ ) { double e = ...
Convert an eigenvalue decomposition into EigenPair objects .
33,706
public void nextIteration ( double [ ] [ ] means ) { this . means = means ; changed = false ; final int k = means . length ; final int dim = means [ 0 ] . length ; centroids = new double [ k ] [ dim ] ; sizes = new int [ k ] ; Arrays . fill ( varsum , 0. ) ; }
Initialize for a new iteration .
33,707
public double [ ] [ ] getMeans ( ) { double [ ] [ ] newmeans = new double [ centroids . length ] [ ] ; for ( int i = 0 ; i < centroids . length ; i ++ ) { if ( sizes [ i ] == 0 ) { newmeans [ i ] = means [ i ] ; continue ; } newmeans [ i ] = centroids [ i ] ; } return newmeans ; }
Get the new means .
33,708
public static String format ( double [ ] v , int w , int d ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; format . setMinimumFractionDigits ( d ) ; forma...
Returns a string representation of this vector .
33,709
public static StringBuilder formatTo ( StringBuilder buf , double [ ] d , String sep ) { if ( d == null ) { return buf . append ( "null" ) ; } if ( d . length == 0 ) { return buf ; } buf . append ( d [ 0 ] ) ; for ( int i = 1 ; i < d . length ; i ++ ) { buf . append ( sep ) . append ( d [ i ] ) ; } return buf ; }
Formats the double array d with the default number format .
33,710
public static String format ( float [ ] f ) { return ( f == null ) ? "null" : ( f . length == 0 ) ? "" : formatTo ( new StringBuilder ( ) , f , ", " ) . toString ( ) ; }
Formats the float array f with as separator and default precision .
33,711
public static String format ( int [ ] a , String sep ) { return ( a == null ) ? "null" : ( a . length == 0 ) ? "" : formatTo ( new StringBuilder ( ) , a , sep ) . toString ( ) ; }
Formats the int array a for printing purposes .
33,712
public static String format ( boolean [ ] b , final String sep ) { return ( b == null ) ? "null" : ( b . length == 0 ) ? "" : formatTo ( new StringBuilder ( ) , b , ", " ) . toString ( ) ; }
Formats the boolean array b with as separator .
33,713
public static String format ( double [ ] [ ] d ) { return d == null ? "null" : ( d . length == 0 ) ? "[]" : formatTo ( new StringBuilder ( ) . append ( "[\n" ) , d , " [" , "]\n" , ", " , NF2 ) . append ( ']' ) . toString ( ) ; }
Formats the double array d with as separator and 2 fraction digits .
33,714
public static String format ( double [ ] [ ] m , int w , int d , String pre , String pos , String csep ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; for...
Returns a string representation of this matrix .
33,715
public static String format ( double [ ] [ ] m , NumberFormat nf ) { return formatTo ( new StringBuilder ( ) . append ( "[\n" ) , m , " [" , "]\n" , ", " , nf ) . append ( "]" ) . toString ( ) ; }
returns String - representation of Matrix .
33,716
public static String format ( Collection < String > d , String sep ) { if ( d == null ) { return "null" ; } if ( d . isEmpty ( ) ) { return "" ; } if ( d . size ( ) == 1 ) { return d . iterator ( ) . next ( ) ; } int len = sep . length ( ) * ( d . size ( ) - 1 ) ; for ( String s : d ) { len += s . length ( ) ; } Iterat...
Formats the String collection with the specified separator .
33,717
public static String format ( String [ ] d , String sep ) { if ( d == null ) { return "null" ; } if ( d . length == 0 ) { return "" ; } if ( d . length == 1 ) { return d [ 0 ] ; } int len = sep . length ( ) * ( d . length - 1 ) ; for ( String s : d ) { len += s . length ( ) ; } StringBuilder buffer = new StringBuilder ...
Formats the string array d with the specified separator .
33,718
public static int findSplitpoint ( String s , int width ) { int in = s . indexOf ( NEWLINE ) ; in = in < 0 ? s . length ( ) : in ; if ( in < width ) { return in ; } int iw = s . lastIndexOf ( ' ' , width ) ; if ( iw >= 0 && iw < width ) { return iw ; } int bp = nextPosition ( s . indexOf ( ' ' , width ) , s . indexOf (...
Find the first space before position w or if there is none after w .
33,719
public static List < String > splitAtLastBlank ( String s , int width ) { List < String > chunks = new ArrayList < > ( ) ; String tmp = s ; while ( tmp . length ( ) > 0 ) { int index = findSplitpoint ( tmp , width ) ; chunks . add ( tmp . substring ( 0 , index ) ) ; while ( index < tmp . length ( ) && tmp . charAt ( in...
Splits the specified string at the last blank before width . If there is no blank before the given width it is split at the next .
33,720
public static String pad ( String o , int len ) { return o . length ( ) >= len ? o : ( o + whitespace ( len - o . length ( ) ) ) ; }
Pad a string to a given length by adding whitespace to the right .
33,721
public static String padRightAligned ( String o , int len ) { return o . length ( ) >= len ? o : ( whitespace ( len - o . length ( ) ) + o ) ; }
Pad a string to a given length by adding whitespace to the left .
33,722
public static String formatTimeDelta ( long time , CharSequence sep ) { final StringBuilder sb = new StringBuilder ( ) ; final Formatter fmt = new Formatter ( sb ) ; for ( int i = TIME_UNIT_SIZES . length - 1 ; i >= 0 ; -- i ) { if ( i == 0 && sb . length ( ) > 4 ) { continue ; } if ( sb . length ( ) > 0 ) { sb . appen...
Formats a time delta in human readable format .
33,723
public static StringBuilder appendZeros ( StringBuilder buf , int zeros ) { for ( int i = zeros ; i > 0 ; i -= ZEROPADDING . length ) { buf . append ( ZEROPADDING , 0 , i < ZEROPADDING . length ? i : ZEROPADDING . length ) ; } return buf ; }
Append zeros to a buffer .
33,724
public static StringBuilder appendSpace ( StringBuilder buf , int spaces ) { for ( int i = spaces ; i > 0 ; i -= SPACEPADDING . length ) { buf . append ( SPACEPADDING , 0 , i < SPACEPADDING . length ? i : SPACEPADDING . length ) ; } return buf ; }
Append whitespace to a buffer .
33,725
protected void makeLayerElement ( ) { plotwidth = StyleLibrary . SCALE ; plotheight = StyleLibrary . SCALE / optics . getOPTICSPlot ( context ) . getRatio ( ) ; final double margin = context . getStyleLibrary ( ) . getSize ( StyleLibrary . MARGIN ) ; layer = SVGUtil . svgElement ( svgp . getDocument ( ) , SVGConstants ...
Produce a new layer element .
33,726
protected List < Centroid > computeCentroids ( int dim , List < V > vectorcolumn , List < ClassLabel > keys , Map < ClassLabel , IntList > classes ) { final int numc = keys . size ( ) ; List < Centroid > centroids = new ArrayList < > ( numc ) ; for ( int i = 0 ; i < numc ; i ++ ) { Centroid c = new Centroid ( dim ) ; f...
Compute the centroid for each class .
33,727
protected double kNNDistance ( ) { double knnDist = 0. ; for ( int i = 0 ; i < getNumEntries ( ) ; i ++ ) { MkMaxEntry entry = getEntry ( i ) ; knnDist = Math . max ( knnDist , entry . getKnnDistance ( ) ) ; } return knnDist ; }
Determines and returns the k - nearest neighbor distance of this node as the maximum of the k - nearest neighbor distances of all entries .
33,728
public boolean adjustEntry ( MkMaxEntry entry , DBID routingObjectID , double parentDistance , AbstractMTree < O , MkMaxTreeNode < O > , MkMaxEntry , ? > mTree ) { super . adjustEntry ( entry , routingObjectID , parentDistance , mTree ) ; entry . setKnnDistance ( kNNDistance ( ) ) ; return true ; }
Calls the super method and adjust additionally the k - nearest neighbor distance of this node as the maximum of the k - nearest neighbor distances of all its entries .
33,729
protected void integrityCheckParameters ( MkMaxEntry parentEntry , MkMaxTreeNode < O > parent , int index , AbstractMTree < O , MkMaxTreeNode < O > , MkMaxEntry , ? > mTree ) { super . integrityCheckParameters ( parentEntry , parent , index , mTree ) ; MkMaxEntry entry = parent . getEntry ( index ) ; double knnDistance...
Calls the super method and tests if the k - nearest neighbor distance of this node is correctly set .
33,730
public void initialize ( ) { if ( databaseConnection == null ) { return ; } if ( LOG . isDebugging ( ) ) { LOG . debugFine ( "Loading data from database connection." ) ; } MultipleObjectsBundle bundle = databaseConnection . loadData ( ) ; databaseConnection = null ; { DBIDs bids = bundle . getDBIDs ( ) ; if ( bids inst...
Initialize the database by getting the initial data from the database connection .
33,731
protected void zSort ( List < ? extends SpatialComparable > objs , int start , int end , double [ ] mms , int [ ] dims , int depth ) { final int numdim = ( dims != null ) ? dims . length : ( mms . length >> 1 ) ; final int edim = ( dims != null ) ? dims [ depth ] : depth ; final double min = mms [ 2 * edim ] , max = mm...
The actual Z sorting function
33,732
public StringBuilder appendTo ( StringBuilder buf ) { return buf . append ( DBIDUtil . toString ( ( DBIDRef ) id ) ) . append ( " " ) . append ( column ) . append ( " " ) . append ( score ) ; }
Append to a text buffer .
33,733
protected Cluster < SubspaceModel > runDOC ( Database database , Relation < V > relation , ArrayModifiableDBIDs S , final int d , int n , int m , int r , int minClusterSize ) { DBIDs C = null ; long [ ] D = null ; double quality = Double . NEGATIVE_INFINITY ; FiniteProgress iprogress = LOG . isVerbose ( ) ? new FiniteP...
Performs a single run of DOC finding a single cluster .
33,734
protected DBIDs findNeighbors ( DBIDRef q , long [ ] nD , ArrayModifiableDBIDs S , Relation < V > relation ) { DistanceQuery < V > dq = relation . getDistanceQuery ( new SubspaceMaximumDistanceFunction ( nD ) ) ; ArrayModifiableDBIDs nC = DBIDUtil . newArray ( ) ; for ( DBIDIter it = S . iter ( ) ; it . valid ( ) ; it ...
Find the neighbors of point q in the given subspace
33,735
protected Cluster < SubspaceModel > makeCluster ( Relation < V > relation , DBIDs C , long [ ] D ) { DBIDs ids = DBIDUtil . newHashSet ( C ) ; Cluster < SubspaceModel > cluster = new Cluster < > ( ids ) ; cluster . setModel ( new SubspaceModel ( new Subspace ( D ) , Centroid . make ( relation , ids ) . getArrayRef ( ) ...
Utility method to create a subspace cluster from a list of DBIDs and the relevant attributes .
33,736
protected static < M extends Model > int [ ] findDepth ( Clustering < M > c ) { final Hierarchy < Cluster < M > > hier = c . getClusterHierarchy ( ) ; int [ ] size = { 0 , 0 } ; for ( It < Cluster < M > > iter = c . iterToplevelClusters ( ) ; iter . valid ( ) ; iter . advance ( ) ) { findDepth ( hier , iter . get ( ) ,...
Compute the size of the clustering .
33,737
private static < M extends Model > void findDepth ( Hierarchy < Cluster < M > > hier , Cluster < M > cluster , int [ ] size ) { if ( hier . numChildren ( cluster ) > 0 ) { for ( It < Cluster < M > > iter = hier . iterChildren ( cluster ) ; iter . valid ( ) ; iter . advance ( ) ) { findDepth ( hier , iter . get ( ) , si...
Recursive depth computation .
33,738
protected static int getPreferredColumns ( double width , double height , int numc , double maxwidth ) { final double rows = Math . ceil ( FastMath . pow ( numc * maxwidth , height / ( width + height ) ) ) ; return ( int ) Math . ceil ( numc / ( rows + 1 ) ) ; }
Compute the preferred number of columns .
33,739
public ELKIBuilder < T > with ( String opt , Object value ) { p . addParameter ( opt , value ) ; return this ; }
Add an option to the builder .
33,740
@ SuppressWarnings ( "unchecked" ) public < C extends T > C build ( ) { if ( p == null ) { throw new AbortException ( "build() may be called only once." ) ; } final T obj = ClassGenericsUtil . parameterizeOrAbort ( clazz , p ) ; if ( p . hasUnusedParameters ( ) ) { LOG . warning ( "Unused parameters: " + p . getRemaini...
Instantiate consuming the parameter list .
33,741
protected static double [ ] [ ] randomInitialSolution ( final int size , final int dim , Random random ) { double [ ] [ ] sol = new double [ size ] [ dim ] ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < dim ; j ++ ) { sol [ i ] [ j ] = random . nextGaussian ( ) * INITIAL_SOLUTION_SCALE ; } } return sol ;...
Generate a random initial solution .
33,742
protected double sqDist ( double [ ] v1 , double [ ] v2 ) { assert ( v1 . length == v2 . length ) : "Lengths do not agree: " + v1 . length + " " + v2 . length ; double sum = 0 ; for ( int i = 0 ; i < v1 . length ; i ++ ) { final double diff = v1 [ i ] - v2 [ i ] ; sum += diff * diff ; } ++ projectedDistances ; return s...
Squared distance in projection space .
33,743
protected void updateSolution ( double [ ] [ ] sol , double [ ] meta , int it ) { final double mom = ( it < momentumSwitch && initialMomentum < finalMomentum ) ? initialMomentum : finalMomentum ; final int dim3 = dim * 3 ; for ( int i = 0 , off = 0 ; i < sol . length ; i ++ , off += dim3 ) { final double [ ] sol_i = so...
Update the current solution on iteration .
33,744
private int getOffset ( int x , int y ) { return ( y < x ) ? ( triangleSize ( x ) + y ) : ( triangleSize ( y ) + x ) ; }
Array offset computation .
33,745
public double getWeight ( double distance , double max , double stddev ) { if ( stddev <= 0 ) { return 1 ; } double scaleddistance = distance / ( scaling * stddev ) ; if ( scaleddistance >= 1.0 ) { return 0.0 ; } return 1.0 - scaleddistance * scaleddistance ; }
Evaluate weight function at given parameters . max is ignored .
33,746
public OPTICSPlot getOPTICSPlot ( VisualizerContext context ) { if ( plot == null ) { plot = OPTICSPlot . plotForClusterOrder ( clusterOrder , context ) ; } return plot ; }
Get or produce the actual OPTICS plot .
33,747
public void setValue ( boolean val ) { try { super . setValue ( Boolean . valueOf ( val ) ) ; } catch ( ParameterException e ) { throw new AbortException ( "Flag did not accept boolean value!" , e ) ; } }
Convenience function using a native boolean that doesn t require error handling .
33,748
public OutlierResult run ( Database database , Relation < O > relation ) { StepProgress stepprog = LOG . isVerbose ( ) ? new StepProgress ( 5 ) : null ; Pair < KNNQuery < O > , KNNQuery < O > > pair = getKNNQueries ( database , relation , stepprog ) ; KNNQuery < O > knnComp = pair . getFirst ( ) ; KNNQuery < O > knnRea...
Performs the LoOP algorithm on the given database .
33,749
protected void computePDists ( Relation < O > relation , KNNQuery < O > knn , WritableDoubleDataStore pdists ) { FiniteProgress prdsProgress = LOG . isVerbose ( ) ? new FiniteProgress ( "pdists" , relation . size ( ) , LOG ) : null ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . valid ( ) ; iditer . advan...
Compute the probabilistic distances used by LoOP .
33,750
protected double computePLOFs ( Relation < O > relation , KNNQuery < O > knn , WritableDoubleDataStore pdists , WritableDoubleDataStore plofs ) { FiniteProgress progressPLOFs = LOG . isVerbose ( ) ? new FiniteProgress ( "PLOFs for objects" , relation . size ( ) , LOG ) : null ; double nplof = 0. ; for ( DBIDIter iditer...
Compute the LOF values using the pdist distances .
33,751
@ SuppressWarnings ( "unchecked" ) public final void writeObject ( TextWriterStream out , String label , Object object ) throws IOException { write ( out , label , ( O ) object ) ; }
Non - type - checking version .
33,752
public int filter ( double [ ] eigenValues ) { double totalSum = 0 ; for ( int i = 0 ; i < eigenValues . length ; i ++ ) { totalSum += eigenValues [ i ] ; } double expectedVariance = totalSum / eigenValues . length * walpha ; double currSum = 0 ; for ( int i = 0 ; i < eigenValues . length - 1 ; i ++ ) { if ( eigenValue...
Filter eigenpairs .
33,753
public static List < OutlierResult > getOutlierResults ( Result r ) { if ( r instanceof OutlierResult ) { List < OutlierResult > ors = new ArrayList < > ( 1 ) ; ors . add ( ( OutlierResult ) r ) ; return ors ; } if ( r instanceof HierarchicalResult ) { return ResultUtil . filterResults ( ( ( HierarchicalResult ) r ) . ...
Collect all outlier results from a Result
33,754
double evaluateBy ( ScoreEvaluation eval ) { return eval . evaluate ( new DBIDsTest ( DBIDUtil . ensureSet ( scores . getDBIDs ( ) ) ) , new OutlierScoreAdapter ( this ) ) ; }
Evaluate given a set of positives and a scoring .
33,755
public double distance ( double [ ] v1 , double [ ] v2 ) { final int dim1 = v1 . length , dim2 = v2 . length ; final int mindim = dim1 < dim2 ? dim1 : dim2 ; double agg = preDistance ( v1 , v2 , 0 , mindim ) ; if ( dim1 > mindim ) { agg += preNorm ( v1 , mindim , dim1 ) ; } else if ( dim2 > mindim ) { agg += preNorm ( ...
Special version for double arrays .
33,756
private void computeWeights ( Node node ) { int wsum = 0 ; for ( Node child : node . children ) { computeWeights ( child ) ; wsum += child . weight ; } node . weight = Math . max ( 1 , wsum ) ; }
Recursively assign node weights .
33,757
public void processNewResult ( ResultHierarchy hier , Result result ) { List < Clustering < ? > > clusterings = Clustering . getClusteringResults ( result ) ; if ( clusterings . size ( ) < 2 ) { return ; } Segments segments = new Segments ( clusterings ) ; hier . add ( result , segments ) ; }
Perform clusterings evaluation
33,758
public double getPartialMinDist ( int dimension , int vp ) { final int qp = queryApprox . getApproximation ( dimension ) ; if ( vp < qp ) { return lookup [ dimension ] [ vp + 1 ] ; } else if ( vp > qp ) { return lookup [ dimension ] [ vp ] ; } else { return 0.0 ; } }
Get the minimum distance contribution of a single dimension .
33,759
public double getMinDist ( VectorApproximation vec ) { final int dim = lookup . length ; double minDist = 0 ; for ( int d = 0 ; d < dim ; d ++ ) { final int vp = vec . getApproximation ( d ) ; minDist += getPartialMinDist ( d , vp ) ; } return FastMath . pow ( minDist , onebyp ) ; }
Get the minimum distance to approximated vector vec .
33,760
public double getPartialMaxDist ( int dimension , int vp ) { final int qp = queryApprox . getApproximation ( dimension ) ; if ( vp < qp ) { return lookup [ dimension ] [ vp ] ; } else if ( vp > qp ) { return lookup [ dimension ] [ vp + 1 ] ; } else { return Math . max ( lookup [ dimension ] [ vp ] , lookup [ dimension ...
Get the maximum distance contribution of a single dimension .
33,761
private void initializeLookupTable ( double [ ] [ ] splitPositions , NumberVector query , double p ) { final int dimensions = splitPositions . length ; final int bordercount = splitPositions [ 0 ] . length ; lookup = new double [ dimensions ] [ bordercount ] ; for ( int d = 0 ; d < dimensions ; d ++ ) { final double va...
Initialize the lookup table .
33,762
protected void makeStyleResult ( StyleLibrary stylelib ) { final Database db = ResultUtil . findDatabase ( hier ) ; stylelibrary = stylelib ; List < Clustering < ? extends Model > > clusterings = Clustering . getClusteringResults ( db ) ; if ( ! clusterings . isEmpty ( ) ) { stylepolicy = new ClusterStylingPolicy ( clu...
Generate a new style result for the given style library .
33,763
public void contentChanged ( DataStoreEvent e ) { for ( int i = 0 ; i < listenerList . size ( ) ; i ++ ) { listenerList . get ( i ) . contentChanged ( e ) ; } }
Proxy datastore event to child listeners .
33,764
private void notifyFactories ( Object item ) { for ( VisualizationProcessor f : factories ) { try { f . processNewResult ( this , item ) ; } catch ( Throwable e ) { LOG . warning ( "VisFactory " + f . getClass ( ) . getCanonicalName ( ) + " failed:" , e ) ; } } }
Notify factories of a change .
33,765
protected int chooseBulkSplitPoint ( int numEntries , int minEntries , int maxEntries ) { if ( numEntries < minEntries ) { throw new IllegalArgumentException ( "numEntries < minEntries!" ) ; } if ( numEntries <= maxEntries ) { return numEntries ; } else if ( numEntries < maxEntries + minEntries ) { return ( numEntries ...
Computes and returns the best split point .
33,766
protected < T > List < List < T > > trivialPartition ( List < T > objects , int minEntries , int maxEntries ) { final int size = objects . size ( ) ; final int numberPartitions = ( int ) Math . ceil ( ( ( double ) size ) / maxEntries ) ; List < List < T > > partitions = new ArrayList < > ( numberPartitions ) ; int star...
Perform the trivial partitioning of the given list .
33,767
protected Relation < ? > [ ] alignColumns ( ObjectBundle pack ) { Relation < ? > [ ] targets = new Relation < ? > [ pack . metaLength ( ) ] ; long [ ] used = BitsUtil . zero ( relations . size ( ) ) ; for ( int i = 0 ; i < targets . length ; i ++ ) { SimpleTypeInformation < ? > meta = pack . meta ( i ) ; for ( int j = ...
Find a mapping from package columns to database columns eventually adding new database columns when needed .
33,768
private Relation < ? > addNewRelation ( SimpleTypeInformation < ? > meta ) { @ SuppressWarnings ( "unchecked" ) SimpleTypeInformation < Object > ometa = ( SimpleTypeInformation < Object > ) meta ; Relation < ? > relation = new MaterializedRelation < > ( ometa , ids ) ; relations . add ( relation ) ; getHierarchy ( ) . ...
Add a new representation for the given meta .
33,769
private void doDelete ( DBIDRef id ) { ids . remove ( id ) ; for ( Relation < ? > relation : relations ) { if ( relation == idrep ) { continue ; } if ( ! ( relation instanceof ModifiableRelation ) ) { throw new AbortException ( "Non-modifiable relations have been added to the database." ) ; } ( ( ModifiableRelation < ?...
Removes the object with the specified id from this database .
33,770
private ArrayDBIDs greedy ( DistanceQuery < V > distFunc , DBIDs sampleSet , int m , Random random ) { ArrayModifiableDBIDs medoids = DBIDUtil . newArray ( m ) ; ArrayModifiableDBIDs s = DBIDUtil . newArray ( sampleSet ) ; DBIDArrayIter iter = s . iter ( ) ; DBIDVar m_i = DBIDUtil . newVar ( ) ; int size = s . size ( )...
Returns a piercing set of k medoids from the specified sample set .
33,771
private ArrayDBIDs initialSet ( DBIDs sampleSet , int k , Random random ) { return DBIDUtil . ensureArray ( DBIDUtil . randomSample ( sampleSet , k , random ) ) ; }
Returns a set of k elements from the specified sample set .
33,772
private ArrayDBIDs computeM_current ( DBIDs m , DBIDs m_best , DBIDs m_bad , Random random ) { ArrayModifiableDBIDs m_list = DBIDUtil . newArray ( m ) ; m_list . removeDBIDs ( m_best ) ; DBIDArrayMIter it = m_list . iter ( ) ; ArrayModifiableDBIDs m_current = DBIDUtil . newArray ( ) ; for ( DBIDIter iter = m_best . ite...
Computes the set of medoids in current iteration .
33,773
private long [ ] [ ] findDimensions ( ArrayDBIDs medoids , Relation < V > database , DistanceQuery < V > distFunc , RangeQuery < V > rangeQuery ) { DataStore < DBIDs > localities = getLocalities ( medoids , distFunc , rangeQuery ) ; final int dim = RelationUtil . dimensionality ( database ) ; final int numc = medoids ....
Determines the set of correlated dimensions for each medoid in the specified medoid set .
33,774
private List < Pair < double [ ] , long [ ] > > findDimensions ( ArrayList < PROCLUSCluster > clusters , Relation < V > database ) { final int dim = RelationUtil . dimensionality ( database ) ; final int numc = clusters . size ( ) ; double [ ] [ ] averageDistances = new double [ numc ] [ ] ; for ( int i = 0 ; i < numc ...
Refinement step that determines the set of correlated dimensions for each cluster centroid .
33,775
private List < DoubleIntInt > computeZijs ( double [ ] [ ] averageDistances , final int dim ) { List < DoubleIntInt > z_ijs = new ArrayList < > ( averageDistances . length * dim ) ; for ( int i = 0 ; i < averageDistances . length ; i ++ ) { double [ ] x_i = averageDistances [ i ] ; double y_i = 0 ; for ( int j = 0 ; j ...
Compute the z_ij values .
33,776
private long [ ] [ ] computeDimensionMap ( List < DoubleIntInt > z_ijs , final int dim , final int numc ) { long [ ] [ ] dimensionMap = new long [ numc ] [ ( ( dim - 1 ) >> 6 ) + 1 ] ; int max = Math . max ( k * l , 2 ) ; for ( int m = 0 ; m < max ; m ++ ) { DoubleIntInt z_ij = z_ijs . get ( m ) ; long [ ] dims_i = dim...
Compute the dimension map .
33,777
private ArrayList < PROCLUSCluster > assignPoints ( ArrayDBIDs m_current , long [ ] [ ] dimensions , Relation < V > database ) { ModifiableDBIDs [ ] clusterIDs = new ModifiableDBIDs [ dimensions . length ] ; for ( int i = 0 ; i < m_current . size ( ) ; i ++ ) { clusterIDs [ i ] = DBIDUtil . newHashSet ( ) ; } DBIDArray...
Assigns the objects to the clusters .
33,778
private List < PROCLUSCluster > finalAssignment ( List < Pair < double [ ] , long [ ] > > dimensions , Relation < V > database ) { Map < Integer , ModifiableDBIDs > clusterIDs = new HashMap < > ( ) ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { clusterIDs . put ( i , DBIDUtil . newHashSet ( ) ) ; } for ( DBID...
Refinement step to assign the objects to the final clusters .
33,779
private double manhattanSegmentalDistance ( NumberVector o1 , double [ ] o2 , long [ ] dimensions ) { double result = 0 ; int card = 0 ; for ( int d = BitsUtil . nextSetBit ( dimensions , 0 ) ; d >= 0 ; d = BitsUtil . nextSetBit ( dimensions , d + 1 ) ) { result += Math . abs ( o1 . doubleValue ( d ) - o2 [ d ] ) ; ++ ...
Returns the Manhattan segmental distance between o1 and o2 relative to the specified dimensions .
33,780
private double evaluateClusters ( ArrayList < PROCLUSCluster > clusters , long [ ] [ ] dimensions , Relation < V > database ) { double result = 0 ; for ( int i = 0 ; i < dimensions . length ; i ++ ) { PROCLUSCluster c_i = clusters . get ( i ) ; double [ ] centroid_i = c_i . centroid ; long [ ] dims_i = dimensions [ i ]...
Evaluates the quality of the clusters .
33,781
private double avgDistance ( double [ ] centroid , DBIDs objectIDs , Relation < V > database , int dimension ) { Mean avg = new Mean ( ) ; for ( DBIDIter iter = objectIDs . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { V o = database . get ( iter ) ; avg . put ( Math . abs ( centroid [ dimension ] - o . doubleVa...
Computes the average distance of the objects to the centroid along the specified dimension .
33,782
private DBIDs computeBadMedoids ( ArrayDBIDs m_current , ArrayList < PROCLUSCluster > clusters , int threshold ) { ModifiableDBIDs badMedoids = DBIDUtil . newHashSet ( m_current . size ( ) ) ; int i = 0 ; for ( DBIDIter it = m_current . iter ( ) ; it . valid ( ) ; it . advance ( ) , i ++ ) { PROCLUSCluster c_i = cluste...
Computes the bad medoids where the medoid of a cluster with less than the specified threshold of objects is bad .
33,783
public static Bit valueOf ( String bit ) throws NumberFormatException { final int i = ParseUtil . parseIntBase10 ( bit ) ; if ( i != 0 && i != 1 ) { throw new NumberFormatException ( "Input \"" + bit + "\" must be 0 or 1." ) ; } return ( i > 0 ) ? TRUE : FALSE ; }
Method to construct a Bit for a given String expression .
33,784
public ChangePoints run ( Relation < DoubleVector > relation ) { if ( ! ( relation . getDBIDs ( ) instanceof ArrayDBIDs ) ) { throw new AbortException ( "This implementation may only be used on static databases, with ArrayDBIDs to provide a clear order." ) ; } return new Instance ( rnd . getSingleThreadedRandom ( ) ) ....
Executes multiple change point detection for given relation
33,785
public static void cusum ( double [ ] data , double [ ] out , int begin , int end ) { assert ( out . length >= data . length ) ; double m = 0. , carry = 0. ; for ( int i = begin ; i < end ; i ++ ) { double v = data [ i ] - carry ; double n = out [ i ] = ( m + v ) ; carry = ( n - m ) - v ; m = n ; } }
Compute the incremental sum of an array i . e . the sum of all points up to the given index .
33,786
public static DoubleIntPair bestChangeInMean ( double [ ] sums , int begin , int end ) { final int len = end - begin , last = end - 1 ; final double suml = begin > 0 ? sums [ begin - 1 ] : 0. ; final double sumr = sums [ last ] ; int bestpos = begin ; double bestscore = Double . NEGATIVE_INFINITY ; for ( int j = begin ...
Find the best position to assume a change in mean .
33,787
public static void shuffle ( double [ ] bstrap , int len , Random rnd ) { int i = len ; while ( i > 0 ) { final int r = rnd . nextInt ( i ) ; -- i ; double tmp = bstrap [ r ] ; bstrap [ r ] = bstrap [ i ] ; bstrap [ i ] = tmp ; } }
Fisher - Yates shuffle of a partial array
33,788
@ SuppressWarnings ( "unchecked" ) public T get ( double coord ) { if ( coord == Double . NEGATIVE_INFINITY ) { return getSpecial ( 0 ) ; } if ( coord == Double . POSITIVE_INFINITY ) { return getSpecial ( 1 ) ; } if ( Double . isNaN ( coord ) ) { return getSpecial ( 2 ) ; } int bin = getBinNr ( coord ) ; if ( bin < 0 )...
Access the value of a bin with new data .
33,789
protected void loadCache ( int size , InputStream in ) throws IOException { cache = new Long2FloatOpenHashMap ( size * 20 ) ; cache . defaultReturnValue ( Float . POSITIVE_INFINITY ) ; min = Integer . MAX_VALUE ; max = Integer . MIN_VALUE ; parser . parse ( in , new DistanceCacheWriter ( ) { public void put ( int id1 ,...
Fill cache from an input stream .
33,790
public Element svgElement ( String name , String cssclass ) { Element elem = SVGUtil . svgElement ( document , name ) ; if ( cssclass != null ) { elem . setAttribute ( SVGConstants . SVG_CLASS_ATTRIBUTE , cssclass ) ; } return elem ; }
Create a SVG element in the SVG namespace . Non - static version .
33,791
public Element svgRect ( double x , double y , double w , double h ) { return SVGUtil . svgRect ( document , x , y , w , h ) ; }
Create a SVG rectangle
33,792
public Element svgCircle ( double cx , double cy , double r ) { return SVGUtil . svgCircle ( document , cx , cy , r ) ; }
Create a SVG circle
33,793
public Element svgLine ( double x1 , double y1 , double x2 , double y2 ) { return SVGUtil . svgLine ( document , x1 , y1 , x2 , y2 ) ; }
Create a SVG line element
33,794
public SVGPoint elementCoordinatesFromEvent ( Element tag , Event evt ) { return SVGUtil . elementCoordinatesFromEvent ( document , tag , evt ) ; }
Convert screen coordinates to element coordinates .
33,795
public void addCSSClassOrLogError ( CSSClass cls ) { try { cssman . addClass ( cls ) ; } catch ( CSSNamingConflict e ) { LoggingUtil . exception ( e ) ; } }
Convenience method to add a CSS class or log an error .
33,796
public void updateStyleElement ( ) { Element newstyle = cssman . makeStyleElement ( document ) ; style . getParentNode ( ) . replaceChild ( newstyle , style ) ; style = newstyle ; }
Update style element - invoke this appropriately after any change to the CSS styles .
33,797
public void saveAsSVG ( File file ) throws IOException , TransformerFactoryConfigurationError , TransformerException { OutputStream out = new BufferedOutputStream ( new FileOutputStream ( file ) ) ; javax . xml . transform . Result result = new StreamResult ( out ) ; SVGDocument doc = cloneDocument ( ) ; Transformer xf...
Save document into a SVG file .
33,798
protected void transcode ( File file , Transcoder transcoder ) throws IOException , TranscoderException { transcoder . addTranscodingHint ( XMLAbstractTranscoder . KEY_XML_PARSER_VALIDATING , Boolean . FALSE ) ; SVGDocument doc = cloneDocument ( ) ; TranscoderInput input = new TranscoderInput ( doc ) ; OutputStream out...
Transcode a document into a file using the given transcoder .
33,799
protected SVGDocument cloneDocument ( ) { return ( SVGDocument ) new CloneInlineImages ( ) { public Node cloneNode ( Document doc , Node eold ) { if ( eold instanceof Element ) { Element eeold = ( Element ) eold ; String vis = eeold . getAttribute ( NO_EXPORT_ATTRIBUTE ) ; if ( vis != null && vis . length ( ) > 0 ) { r...
Clone the SVGPlot document for transcoding .