idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
157,700
public void remove ( String key ) { Iterator < Pair < String , ArrayList < String > > > it = store . iterator ( ) ; while ( it . hasNext ( ) ) { String thisKey = it . next ( ) . first ; if ( key . equals ( thisKey ) ) { it . remove ( ) ; break ; } } }
Remove a given key from the file .
74
8
157,701
public ArrayList < String > get ( String key ) { Iterator < Pair < String , ArrayList < String > > > it = store . iterator ( ) ; while ( it . hasNext ( ) ) { Pair < String , ArrayList < String > > pair = it . next ( ) ; if ( key . equals ( pair . first ) ) { return pair . second ; } } return null ; }
Find a saved setting by key .
85
7
157,702
public Clustering < Model > run ( Database database , Relation < V > relation ) { // current dimensionality associated with each seed int dim_c = RelationUtil . dimensionality ( relation ) ; if ( dim_c < l ) { throw new IllegalStateException ( "Dimensionality of data < parameter l! " + "(" + dim_c + " < " + l + ")" ) ;...
Performs the ORCLUS algorithm on the given database .
504
11
157,703
private List < ORCLUSCluster > initialSeeds ( Relation < V > database , int k ) { DBIDs randomSample = DBIDUtil . randomSample ( database . getDBIDs ( ) , k , rnd ) ; List < ORCLUSCluster > seeds = new ArrayList <> ( k ) ; for ( DBIDIter iter = randomSample . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { seeds ....
Initializes the list of seeds wit a random sample of size k .
126
14
157,704
private void assign ( Relation < V > database , List < ORCLUSCluster > clusters ) { NumberVectorDistanceFunction < ? super V > distFunc = SquaredEuclideanDistanceFunction . STATIC ; // clear the current clusters for ( ORCLUSCluster cluster : clusters ) { cluster . objectIDs . clear ( ) ; } // projected centroids of the...
Creates a partitioning of the database by assigning each object to its closest seed .
406
17
157,705
private void merge ( Relation < V > relation , List < ORCLUSCluster > clusters , int k_new , int d_new , IndefiniteProgress cprogress ) { ArrayList < ProjectedEnergy > projectedEnergies = new ArrayList <> ( ( clusters . size ( ) * ( clusters . size ( ) - 1 ) ) >>> 1 ) ; for ( int i = 0 ; i < clusters . size ( ) ; i ++ ...
Reduces the number of seeds to k_new
607
10
157,706
private ProjectedEnergy projectedEnergy ( Relation < V > relation , ORCLUSCluster c_i , ORCLUSCluster c_j , int i , int j , int dim ) { NumberVectorDistanceFunction < ? super V > distFunc = SquaredEuclideanDistanceFunction . STATIC ; // union of cluster c_i and c_j ORCLUSCluster c_ij = union ( relation , c_i , c_j , di...
Computes the projected energy of the specified clusters . The projected energy is given by the mean square distance of the points to the centroid of the union cluster c when all points in c are projected to the subspace of c .
247
46
157,707
private ORCLUSCluster union ( Relation < V > relation , ORCLUSCluster c1 , ORCLUSCluster c2 , int dim ) { ORCLUSCluster c = new ORCLUSCluster ( ) ; c . objectIDs = DBIDUtil . newHashSet ( c1 . objectIDs ) ; c . objectIDs . addDBIDs ( c2 . objectIDs ) ; c . objectIDs = DBIDUtil . newArray ( c . objectIDs ) ; if ( c . ob...
Returns the union of the two specified clusters .
209
9
157,708
private static void initializeNNCache ( double [ ] scratch , double [ ] bestd , int [ ] besti ) { final int size = bestd . length ; Arrays . fill ( bestd , Double . POSITIVE_INFINITY ) ; Arrays . fill ( besti , - 1 ) ; for ( int x = 0 , p = 0 ; x < size ; x ++ ) { assert ( p == MatrixParadigm . triangleSize ( x ) ) ; d...
Initialize the NN cache .
216
7
157,709
protected int findMerge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder ) { double mindist = Double . POSITIVE_INFINITY ; int x = - 1 , y = - 1 ; // Find minimum: for ( int cx = 0 ; cx < size ; cx ++ ) { // Skip if object has already joined a cluster: f...
Perform the next merge step .
214
7
157,710
protected void merge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder , double mindist , int x , int y ) { // Avoid allocating memory, by reusing existing iterators: final DBIDArrayIter ix = mat . ix . seek ( x ) , iy = mat . iy . seek ( y ) ; if ( LOG ....
Execute the cluster merge .
350
6
157,711
private void updateCache ( int size , double [ ] scratch , double [ ] bestd , int [ ] besti , int x , int y , int j , double d ) { // New best if ( d <= bestd [ j ] ) { bestd [ j ] = d ; besti [ j ] = y ; return ; } // Needs slow update. if ( besti [ j ] == x || besti [ j ] == y ) { findBest ( size , scratch , bestd , ...
Update the cache .
113
4
157,712
public VisualizerContext newContext ( ResultHierarchy hier , Result start ) { Collection < Relation < ? > > rels = ResultUtil . filterResults ( hier , Relation . class ) ; for ( Relation < ? > rel : rels ) { if ( samplesize == 0 ) { continue ; } if ( ! ResultUtil . filterResults ( hier , rel , SamplingResult . class ) ...
Make a new visualization context
182
5
157,713
public static String getTitle ( Database db , Result result ) { List < TrackedParameter > settings = new ArrayList <> ( ) ; for ( SettingsResult sr : SettingsResult . getSettingsResults ( result ) ) { settings . addAll ( sr . getSettings ( ) ) ; } String algorithm = null ; String distance = null ; String dataset = null...
Try to automatically generate a title for this .
375
9
157,714
protected static String shortenClassname ( String nam , char c ) { final int lastdot = nam . lastIndexOf ( c ) ; if ( lastdot >= 0 ) { nam = nam . substring ( lastdot + 1 ) ; } return nam ; }
Shorten the class name .
59
6
157,715
private static Class < ? > getRestrictionClass ( OptionID oid , final Parameter < ? > firstopt , Map < OptionID , List < Pair < Parameter < ? > , Class < ? > > > > byopt ) { Class < ? > superclass = getRestrictionClass ( firstopt ) ; // Also look for more general restrictions: for ( Pair < Parameter < ? > , Class < ? >...
Get the restriction class of an option .
298
8
157,716
private static < T > ArrayList < T > sorted ( Collection < T > cls , Comparator < ? super T > c ) { ArrayList < T > sorted = new ArrayList <> ( cls ) ; sorted . sort ( c ) ; return sorted ; }
Sort a collection of classes .
57
6
157,717
protected void handleHoverEvent ( Event evt ) { if ( evt . getTarget ( ) instanceof Element ) { Element e = ( Element ) evt . getTarget ( ) ; Node next = e . getNextSibling ( ) ; if ( next instanceof Element ) { toggleTooltip ( ( Element ) next , evt . getType ( ) ) ; } else { LoggingUtil . warning ( "Tooltip sibling n...
Handle the hover events .
121
5
157,718
protected void toggleTooltip ( Element elem , String type ) { String csscls = elem . getAttribute ( SVGConstants . SVG_CLASS_ATTRIBUTE ) ; if ( SVGConstants . SVG_MOUSEOVER_EVENT_TYPE . equals ( type ) ) { if ( TOOLTIP_HIDDEN . equals ( csscls ) ) { SVGUtil . setAtt ( elem , SVGConstants . SVG_CLASS_ATTRIBUTE , TOOLTIP...
Toggle the Tooltip of an element .
346
9
157,719
@ Override public DoubleDBIDList reverseKNNQuery ( DBIDRef id , int k ) { ModifiableDoubleDBIDList result = DBIDUtil . newDistanceDBIDList ( ) ; final Heap < MTreeSearchCandidate > pq = new UpdatableHeap <> ( ) ; // push root pq . add ( new MTreeSearchCandidate ( 0. , getRootID ( ) , null , Double . NaN ) ) ; // search...
Performs a reverse k - nearest neighbor query for the given object ID . The query result is in ascending order to the distance to the query object .
516
30
157,720
private void leafEntryIDs ( MkAppTreeNode < O > node , ModifiableDBIDs result ) { if ( node . isLeaf ( ) ) { for ( int i = 0 ; i < node . getNumEntries ( ) ; i ++ ) { MkAppEntry entry = node . getEntry ( i ) ; result . add ( ( ( LeafEntry ) entry ) . getDBID ( ) ) ; } } else { for ( int i = 0 ; i < node . getNumEntries...
Determines the ids of the leaf entries stored in the specified subtree .
148
17
157,721
private PolynomialApproximation approximateKnnDistances ( double [ ] knnDistances ) { StringBuilder msg = new StringBuilder ( ) ; // count the zero distances (necessary of log-log space is used) int k_0 = 0 ; if ( settings . log ) { for ( int i = 0 ; i < settings . kmax ; i ++ ) { double dist = knnDistances [ i ] ; if ...
Computes the polynomial approximation of the specified knn - distances .
345
15
157,722
protected final int isLeft ( double [ ] a , double [ ] b , double [ ] o ) { final double cross = getRX ( a , o ) * getRY ( b , o ) - getRY ( a , o ) * getRX ( b , o ) ; if ( cross == 0 ) { // Compare manhattan distances - same angle! final double dista = Math . abs ( getRX ( a , o ) ) + Math . abs ( getRY ( a , o ) ) ;...
Test whether a point is left of the other wrt . the origin .
164
15
157,723
private double mdist ( double [ ] a , double [ ] b ) { return Math . abs ( a [ 0 ] - b [ 0 ] ) + Math . abs ( a [ 1 ] - b [ 1 ] ) ; }
Manhattan distance .
48
4
157,724
private boolean isConvex ( double [ ] a , double [ ] b , double [ ] c ) { // We're using factor to improve numerical contrast for small polygons. double area = ( b [ 0 ] - a [ 0 ] ) * factor * ( c [ 1 ] - a [ 1 ] ) - ( c [ 0 ] - a [ 0 ] ) * factor * ( b [ 1 ] - a [ 1 ] ) ; return ( - 1e-13 < area && area < 1e-13 ) ? ( ...
Simple convexity test .
143
6
157,725
private void grahamScan ( ) { if ( points . size ( ) < 3 ) { return ; } Iterator < double [ ] > iter = points . iterator ( ) ; Stack < double [ ] > stack = new Stack <> ( ) ; // Start with the first two points on the stack final double [ ] first = iter . next ( ) ; stack . add ( first ) ; while ( iter . hasNext ( ) ) {...
The actual graham scan main loop .
249
8
157,726
public Polygon getHull ( ) { if ( ! ok ) { computeConvexHull ( ) ; } return new Polygon ( points , minmaxX . getMin ( ) , minmaxX . getMax ( ) , minmaxY . getMin ( ) , minmaxY . getMax ( ) ) ; }
Compute the convex hull and return the resulting polygon .
70
13
157,727
private static double coverRadius ( double [ ] [ ] matrix , int [ ] idx , int i ) { final int idx_i = idx [ i ] ; final double [ ] row_i = matrix [ i ] ; double m = 0 ; for ( int j = 0 ; j < row_i . length ; j ++ ) { if ( i != j && idx_i == idx [ j ] ) { final double d = row_i [ j ] ; m = d > m ? d : m ; } } return m ;...
Find the cover radius of a partition .
119
8
157,728
private static int [ ] mstPartition ( double [ ] [ ] matrix ) { final int n = matrix . length ; int [ ] edges = PrimsMinimumSpanningTree . processDense ( matrix ) ; // Note: Prims does *not* yield edges sorted by edge length! double meanlength = thresholdLength ( matrix , edges ) ; int [ ] idx = new int [ n ] , best = ...
Partition the data using the minimu spanning tree .
295
11
157,729
private static double thresholdLength ( double [ ] [ ] matrix , int [ ] edges ) { double [ ] lengths = new double [ edges . length >> 1 ] ; for ( int i = 0 , e = edges . length - 1 ; i < e ; i += 2 ) { lengths [ i >> 1 ] = matrix [ edges [ i ] ] [ edges [ i + 1 ] ] ; } Arrays . sort ( lengths ) ; final int pos = ( leng...
Choose the threshold length of edges to consider omittig .
112
12
157,730
private static double edgelength ( double [ ] [ ] matrix , int [ ] edges , int i ) { i <<= 1 ; return matrix [ edges [ i ] ] [ edges [ i + 1 ] ] ; }
Length of edge i .
46
5
157,731
private static void omitEdge ( int [ ] edges , int [ ] idx , int [ ] sizes , int omit ) { for ( int i = 0 ; i < idx . length ; i ++ ) { idx [ i ] = i ; } Arrays . fill ( sizes , 1 ) ; for ( int i = 0 , j = 0 , e = edges . length - 1 ; j < e ; i ++ , j += 2 ) { if ( i == omit ) { continue ; } int ea = edges [ j + 1 ] , ...
Partition the data by omitting one edge .
226
10
157,732
private static int follow ( int i , int [ ] partitions ) { int next = partitions [ i ] , tmp ; while ( i != next ) { tmp = next ; next = partitions [ i ] = partitions [ next ] ; i = tmp ; } return i ; }
Union - find with simple path compression .
56
8
157,733
private static void computeCentroid ( double [ ] centroid , Relation < ? extends NumberVector > relation , DBIDs ids ) { Arrays . fill ( centroid , 0 ) ; int dim = centroid . length ; for ( DBIDIter it = ids . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { NumberVector v = relation . get ( it ) ; for ( int i = 0 ; i ...
Recompute the centroid of a set .
136
10
157,734
public static < O > DistanceQuery < O > getDistanceQuery ( Database database , DistanceFunction < ? super O > distanceFunction , Object ... hints ) { final Relation < O > objectQuery = database . getRelation ( distanceFunction . getInputTypeRestriction ( ) , hints ) ; return database . getDistanceQuery ( objectQuery , ...
Get a distance query for a given distance function automatically choosing a relation .
78
14
157,735
public static < O > SimilarityQuery < O > getSimilarityQuery ( Database database , SimilarityFunction < ? super O > similarityFunction , Object ... hints ) { final Relation < O > objectQuery = database . getRelation ( similarityFunction . getInputTypeRestriction ( ) , hints ) ; return database . getSimilarityQuery ( ob...
Get a similarity query automatically choosing a relation .
82
9
157,736
public static < O > RKNNQuery < O > getRKNNQuery ( Relation < O > relation , DistanceFunction < ? super O > distanceFunction , Object ... hints ) { final DistanceQuery < O > distanceQuery = relation . getDistanceQuery ( distanceFunction , hints ) ; return relation . getRKNNQuery ( distanceQuery , hints ) ; }
Get a rKNN query object for the given distance function .
77
13
157,737
public static < O > RangeQuery < O > getLinearScanSimilarityRangeQuery ( SimilarityQuery < O > simQuery ) { // Slight optimizations of linear scans if ( simQuery instanceof PrimitiveSimilarityQuery ) { final PrimitiveSimilarityQuery < O > pdq = ( PrimitiveSimilarityQuery < O > ) simQuery ; return new LinearScanPrimitiv...
Get a linear scan query for the given similarity query .
108
11
157,738
protected static void register ( Class < ? > parent , String cname ) { Entry e = data . get ( parent ) ; if ( e == null ) { data . put ( parent , e = new Entry ( ) ) ; } e . addName ( cname ) ; }
Register a class with the registry .
58
7
157,739
protected static void register ( Class < ? > parent , Class < ? > clazz ) { Entry e = data . get ( parent ) ; if ( e == null ) { data . put ( parent , e = new Entry ( ) ) ; } final String cname = clazz . getCanonicalName ( ) ; e . addHit ( cname , clazz ) ; if ( clazz . isAnnotationPresent ( Alias . class ) ) { Alias a...
Register a class in the registry .
139
7
157,740
protected static void registerAlias ( Class < ? > parent , String alias , String cname ) { Entry e = data . get ( parent ) ; assert ( e != null ) ; e . addAlias ( alias , cname ) ; }
Register a class alias with the registry .
49
8
157,741
private static Class < ? > tryLoadClass ( String value ) { try { return CLASSLOADER . loadClass ( value ) ; } catch ( ClassNotFoundException e ) { return null ; } }
Attempt to load a class
44
5
157,742
public static List < Class < ? > > findAllImplementations ( Class < ? > restrictionClass ) { if ( restrictionClass == null ) { return Collections . emptyList ( ) ; } if ( ! contains ( restrictionClass ) ) { ELKIServiceLoader . load ( restrictionClass ) ; ELKIServiceScanner . load ( restrictionClass ) ; } Entry e = data...
Find all implementations of a particular interface .
291
8
157,743
public static List < Class < ? > > findAllImplementations ( Class < ? > c , boolean everything , boolean parameterizable ) { if ( c == null ) { return Collections . emptyList ( ) ; } // Default is served from the registry if ( ! everything && parameterizable ) { return findAllImplementations ( c ) ; } // This codepath ...
Find all implementations of a given class in the classpath .
409
12
157,744
private static < C > Class < ? > tryAlternateNames ( Class < ? super C > restrictionClass , String value , Entry e ) { StringBuilder buf = new StringBuilder ( value . length ( ) + 100 ) ; // Try with FACTORY_POSTFIX first: Class < ? > clazz = tryLoadClass ( buf . append ( value ) . append ( FACTORY_POSTFIX ) . toString...
Try loading alternative names .
391
5
157,745
protected Element setupCanvas ( ) { final double margin = context . getStyleLibrary ( ) . getSize ( StyleLibrary . MARGIN ) ; this . layer = setupCanvas ( svgp , this . proj , margin , getWidth ( ) , getHeight ( ) ) ; return layer ; }
Setup our canvas .
64
4
157,746
protected SimpleTypeInformation < ? > convertedType ( SimpleTypeInformation < ? > in , NumberVector . Factory < V > factory ) { return new VectorFieldTypeInformation <> ( factory , tdim ) ; }
Get the output type from the input type after conversion .
44
11
157,747
protected < O > Map < O , IntList > partition ( List < ? extends O > classcolumn ) { Map < O , IntList > classes = new HashMap <> ( ) ; Iterator < ? extends O > iter = classcolumn . iterator ( ) ; for ( int i = 0 ; iter . hasNext ( ) ; i ++ ) { O lbl = iter . next ( ) ; IntList ids = classes . get ( lbl ) ; if ( ids ==...
Partition the bundle based on the class label .
140
10
157,748
public Curve makeCurve ( ) { Curve c = new Curve ( curves . size ( ) ) ; curves . add ( c ) ; return c ; }
Make a new curve .
32
5
157,749
public void publish ( String message , Level level ) { try { publish ( new LogRecord ( level , message ) ) ; } catch ( BadLocationException e ) { throw new RuntimeException ( "Error writing a log-like message." , e ) ; } }
Print a message as if it were logged without going through the full logger .
54
15
157,750
protected synchronized void publish ( LogRecord record ) throws BadLocationException { // choose an appropriate formatter final Formatter fmt ; final Style style ; // always format progress messages using the progress formatter. if ( record . getLevel ( ) . intValue ( ) >= Level . WARNING . intValue ( ) ) { // format e...
Publish a log record to the logging pane .
417
10
157,751
protected void optimizeSNE ( AffinityMatrix pij , double [ ] [ ] sol ) { final int size = pij . size ( ) ; if ( size * 3L * dim > 0x7FFF_FFFA L ) { throw new AbortException ( "Memory exceeds Java array size limit." ) ; } // Meta information on each point; joined for memory locality. // Gradient, Momentum, and learning ...
Perform the actual tSNE optimization .
371
9
157,752
protected double computeQij ( double [ ] [ ] qij , double [ ] [ ] solution ) { double qij_sum = 0 ; for ( int i = 1 ; i < qij . length ; i ++ ) { final double [ ] qij_i = qij [ i ] , vi = solution [ i ] ; for ( int j = 0 ; j < i ; j ++ ) { qij_sum += qij_i [ j ] = qij [ j ] [ i ] = MathUtil . exp ( - sqDist ( vi , solu...
Compute the qij of the solution and the sum .
141
12
157,753
protected void computeGradient ( AffinityMatrix pij , double [ ] [ ] qij , double qij_isum , double [ ] [ ] sol , double [ ] meta ) { final int dim3 = dim * 3 ; int size = pij . size ( ) ; for ( int i = 0 , off = 0 ; i < size ; i ++ , off += dim3 ) { final double [ ] sol_i = sol [ i ] , qij_i = qij [ i ] ; Arrays . fil...
Compute the gradients .
281
6
157,754
public OutlierResult run ( Database database , Relation < O > relation ) { DistanceFunction < ? super O > df = clusterer . getDistanceFunction ( ) ; DistanceQuery < O > dq = database . getDistanceQuery ( relation , df ) ; // TODO: improve ELKI api to ensure we're using the same DBIDs! Clustering < ? > c = clusterer . r...
Run the outlier detection algorithm .
424
7
157,755
@ Override public FittingFunctionResult eval ( double x , double [ ] params ) { final int len = params . length ; // We always need triples: (mean, stddev, scaling) assert ( len % 3 ) == 0 ; double y = 0.0 ; double [ ] gradients = new double [ len ] ; // Loosely based on the book: // Numerical Recipes in C: The Art of ...
Compute the mixture of Gaussians at the given position
325
12
157,756
private void showVisualization ( VisualizerContext context , SimilarityMatrixVisualizer factory , VisualizationTask task ) { VisualizationPlot plot = new VisualizationPlot ( ) ; Visualization vis = factory . makeVisualization ( context , task , plot , 1.0 , 1.0 , null ) ; plot . getRoot ( ) . appendChild ( vis . getLay...
Show a single visualization .
201
5
157,757
public void put ( int [ ] data ) { final int l = data . length ; for ( int i = 0 ; i < l ; i ++ ) { put ( data [ i ] ) ; } }
Process a whole array of int values .
43
8
157,758
public OutlierResult run ( Database database , Relation < O > rel ) { final DBIDs ids = rel . getDBIDs ( ) ; LOG . verbose ( "Running kNN preprocessor." ) ; KNNQuery < O > knnq = DatabaseUtil . precomputedKNNQuery ( database , rel , getDistanceFunction ( ) , kmax + 1 ) ; // Initialize store for densities WritableDataSt...
Run the KDEOS outlier detection algorithm .
316
9
157,759
protected void estimateDensities ( Relation < O > rel , KNNQuery < O > knnq , final DBIDs ids , WritableDataStore < double [ ] > densities ) { final int dim = dimensionality ( rel ) ; final int knum = kmax + 1 - kmin ; // Initialize storage: for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) )...
Perform the kernel density estimation step .
521
8
157,760
private int dimensionality ( Relation < O > rel ) { // Explicit: if ( idim >= 0 ) { return idim ; } // Cast to vector field relation. @ SuppressWarnings ( "unchecked" ) final Relation < NumberVector > frel = ( Relation < NumberVector > ) rel ; int dim = RelationUtil . dimensionality ( frel ) ; if ( dim < 1 ) { throw ne...
Ugly hack to allow using this implementation without having a well - defined dimensionality .
125
17
157,761
protected void computeOutlierScores ( KNNQuery < O > knnq , final DBIDs ids , WritableDataStore < double [ ] > densities , WritableDoubleDataStore kdeos , DoubleMinMax minmax ) { final int knum = kmax + 1 - kmin ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Computing KDEOS scores" , ids . size ( )...
Compute the final KDEOS scores .
540
8
157,762
public Clustering < Model > run ( Relation < V > rel ) { fulldatabase = preprocess ( rel ) ; processedIDs = DBIDUtil . newHashSet ( fulldatabase . size ( ) ) ; noiseDim = dimensionality ( fulldatabase ) ; FiniteProgress progress = LOG . isVerbose ( ) ? new FiniteProgress ( "CASH Clustering" , fulldatabase . size ( ) , ...
Run CASH on the relation .
296
7
157,763
private Relation < ParameterizationFunction > preprocess ( Relation < V > vrel ) { DBIDs ids = vrel . getDBIDs ( ) ; SimpleTypeInformation < ParameterizationFunction > type = new SimpleTypeInformation <> ( ParameterizationFunction . class ) ; WritableDataStore < ParameterizationFunction > prep = DataStoreUtil . makeSto...
Preprocess the dataset precomputing the parameterization functions .
174
12
157,764
private void initHeap ( ObjectHeap < CASHInterval > heap , Relation < ParameterizationFunction > relation , int dim , DBIDs ids ) { CASHIntervalSplit split = new CASHIntervalSplit ( relation , minPts ) ; // determine minimum and maximum function value of all functions double [ ] minMax = determineMinMaxDistance ( relat...
Initializes the heap with the root intervals .
591
9
157,765
private MaterializedRelation < ParameterizationFunction > buildDB ( int dim , double [ ] [ ] basis , DBIDs ids , Relation < ParameterizationFunction > relation ) { ProxyDatabase proxy = new ProxyDatabase ( ids ) ; SimpleTypeInformation < ParameterizationFunction > type = new SimpleTypeInformation <> ( ParameterizationF...
Builds a dim - 1 dimensional database where the objects are projected into the specified subspace .
256
19
157,766
private ParameterizationFunction project ( double [ ] [ ] basis , ParameterizationFunction f ) { // Matrix m = new Matrix(new // double[][]{f.getPointCoordinates()}).times(basis); double [ ] m = transposeTimes ( basis , f . getColumnVector ( ) ) ; return new ParameterizationFunction ( DoubleVector . wrap ( m ) ) ; }
Projects the specified parameterization function into the subspace described by the given basis .
87
17
157,767
private double [ ] [ ] determineBasis ( double [ ] alpha ) { final int dim = alpha . length ; // Primary vector: double [ ] nn = new double [ dim + 1 ] ; for ( int i = 0 ; i < nn . length ; i ++ ) { double alpha_i = i == alpha . length ? 0 : alpha [ i ] ; nn [ i ] = ParameterizationFunction . sinusProduct ( 0 , i , alp...
Determines a basis defining a subspace described by the specified alpha values .
455
16
157,768
private CASHInterval determineNextIntervalAtMaxLevel ( ObjectHeap < CASHInterval > heap ) { CASHInterval next = doDetermineNextIntervalAtMaxLevel ( heap ) ; // noise path was chosen while ( next == null ) { if ( heap . isEmpty ( ) ) { return null ; } next = doDetermineNextIntervalAtMaxLevel ( heap ) ; } return next ; }
Determines the next best interval at maximum level i . e . the next interval containing the most unprocessed objects .
92
25
157,769
private CASHInterval doDetermineNextIntervalAtMaxLevel ( ObjectHeap < CASHInterval > heap ) { CASHInterval interval = heap . poll ( ) ; int dim = interval . getDimensionality ( ) ; while ( true ) { // max level is reached if ( interval . getLevel ( ) >= maxLevel && interval . getMaxSplitDimension ( ) == ( dim - 1 ) ) {...
Recursive helper method to determine the next best interval at maximum level i . e . the next interval containing the most unprocessed objects
420
27
157,770
private double [ ] determineMinMaxDistance ( Relation < ParameterizationFunction > relation , int dimensionality ) { double [ ] min = new double [ dimensionality - 1 ] ; double [ ] max = new double [ dimensionality - 1 ] ; Arrays . fill ( max , Math . PI ) ; HyperBoundingBox box = new HyperBoundingBox ( min , max ) ; d...
Determines the minimum and maximum function value of all parameterization functions stored in the specified database .
267
20
157,771
public HistogramResult run ( Database database , Relation < O > relation ) { final DistanceQuery < O > distanceQuery = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; final KNNQuery < O > knnQuery = database . getKNNQuery ( distanceQuery , relation . size ( ) ) ; if ( LOG . isVerbose ( ) ) { LOG . ...
Process a database
544
3
157,772
public Clustering < M > run ( Database database , Relation < V > relation ) { if ( relation . size ( ) == 0 ) { throw new IllegalArgumentException ( "database empty: must contain elements" ) ; } // initial models List < ? extends EMClusterModel < M > > models = mfactory . buildInitialModels ( database , relation , k , ...
Performs the EM clustering algorithm on the given database .
777
12
157,773
public static void recomputeCovarianceMatrices ( Relation < ? extends NumberVector > relation , WritableDataStore < double [ ] > probClusterIGivenX , List < ? extends EMClusterModel < ? > > models , double prior ) { final int k = models . size ( ) ; boolean needsTwoPass = false ; for ( EMClusterModel < ? > m : models )...
Recompute the covariance matrixes .
512
9
157,774
public static double assignProbabilitiesToInstances ( Relation < ? extends NumberVector > relation , List < ? extends EMClusterModel < ? > > models , WritableDataStore < double [ ] > probClusterIGivenX ) { final int k = models . size ( ) ; double emSum = 0. ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . ...
Assigns the current probability values to the instances in the database and compute the expectation value of the current mixture of distributions .
272
25
157,775
protected synchronized void updateVisualizerMenus ( ) { Projection proj = null ; if ( svgCanvas . getPlot ( ) instanceof DetailView ) { PlotItem item = ( ( DetailView ) svgCanvas . getPlot ( ) ) . getPlotItem ( ) ; proj = item . proj ; } menubar . removeAll ( ) ; menubar . add ( filemenu ) ; ResultHierarchy hier = cont...
Update the visualizer menus .
328
6
157,776
public OutlierResult run ( Relation < V > relation ) { final DBIDs ids = relation . getDBIDs ( ) ; ArrayList < ArrayDBIDs > subspaceIndex = buildOneDimIndexes ( relation ) ; Set < HiCSSubspace > subspaces = calculateSubspaces ( relation , subspaceIndex , rnd . getSingleThreadedRandom ( ) ) ; if ( LOG . isVerbose ( ) ) ...
Perform HiCS on a given database .
601
9
157,777
private ArrayList < ArrayDBIDs > buildOneDimIndexes ( Relation < ? extends NumberVector > relation ) { final int dim = RelationUtil . dimensionality ( relation ) ; ArrayList < ArrayDBIDs > subspaceIndex = new ArrayList <> ( dim + 1 ) ; SortDBIDsBySingleDimension comp = new VectorUtil . SortDBIDsBySingleDimension ( rela...
Calculates index structures for every attribute i . e . sorts a ModifiableArray of every DBID in the database for every dimension and stores them in a list
164
33
157,778
private double [ ] max ( double [ ] distances1 , double [ ] distances2 ) { if ( distances1 . length != distances2 . length ) { throw new RuntimeException ( "different lengths!" ) ; } double [ ] result = new double [ distances1 . length ] ; for ( int i = 0 ; i < distances1 . length ; i ++ ) { result [ i ] = Math . max (...
Returns an array that holds the maximum values of the both specified arrays in each index .
103
17
157,779
public static int compileShader ( Class < ? > context , GL2 gl , int type , String name ) throws ShaderCompilationException { int prog = - 1 ; try ( InputStream in = context . getResourceAsStream ( name ) ) { int [ ] error = new int [ 1 ] ; String shaderdata = FileUtil . slurp ( in ) ; prog = gl . glCreateShader ( type...
Compile a shader from a file .
365
8
157,780
protected int effectiveBandSize ( final int dim1 , final int dim2 ) { if ( bandSize == Double . POSITIVE_INFINITY ) { return ( dim1 > dim2 ) ? dim1 : dim2 ; } if ( bandSize >= 1. ) { return ( int ) bandSize ; } // Max * bandSize: return ( int ) Math . ceil ( ( dim1 >= dim2 ? dim1 : dim2 ) * bandSize ) ; }
Compute the effective band size .
100
7
157,781
@ Override public final int addLeafEntry ( E entry ) { // entry is not a leaf entry if ( ! ( entry instanceof LeafEntry ) ) { throw new UnsupportedOperationException ( "Entry is not a leaf entry!" ) ; } // this is a not a leaf node if ( ! isLeaf ( ) ) { throw new UnsupportedOperationException ( "Node is not a leaf node...
Adds a new leaf entry to this node s children and returns the index of the entry in this node s children array . An UnsupportedOperationException will be thrown if the entry is not a leaf entry or this node is not a leaf node .
99
49
157,782
@ Override public final int addDirectoryEntry ( E entry ) { // entry is not a directory entry if ( entry instanceof LeafEntry ) { throw new UnsupportedOperationException ( "Entry is not a directory entry!" ) ; } // this is a not a directory node if ( isLeaf ( ) ) { throw new UnsupportedOperationException ( "Node is not...
Adds a new directory entry to this node s children and returns the index of the entry in this node s children array . An UnsupportedOperationException will be thrown if the entry is not a directory entry or this node is not a directory node .
91
49
157,783
public boolean deleteEntry ( int index ) { System . arraycopy ( entries , index + 1 , entries , index , numEntries - index - 1 ) ; entries [ -- numEntries ] = null ; return true ; }
Deletes the entry at the specified index and shifts all entries after the index to left .
47
18
157,784
@ SuppressWarnings ( "unchecked" ) @ Deprecated public final List < E > getEntries ( ) { List < E > result = new ArrayList <> ( numEntries ) ; for ( Entry entry : entries ) { if ( entry != null ) { result . add ( ( E ) entry ) ; } } return result ; }
Returns a list of the entries .
75
7
157,785
public void removeMask ( long [ ] mask ) { int dest = BitsUtil . nextSetBit ( mask , 0 ) ; if ( dest < 0 ) { return ; } int src = BitsUtil . nextSetBit ( mask , dest ) ; while ( src < numEntries ) { if ( ! BitsUtil . get ( mask , src ) ) { entries [ dest ] = entries [ src ] ; dest ++ ; } src ++ ; } int rm = src - dest ...
Remove entries according to the given mask .
129
8
157,786
public final void splitTo ( AbstractNode < E > newNode , List < E > sorting , int splitPoint ) { assert ( isLeaf ( ) == newNode . isLeaf ( ) ) ; deleteAllEntries ( ) ; StringBuilder msg = LoggingConfiguration . DEBUG ? new StringBuilder ( 1000 ) : null ; for ( int i = 0 ; i < splitPoint ; i ++ ) { addEntry ( sorting . ...
Redistribute entries according to the given sorting .
272
10
157,787
public static void ensureClusteringResult ( final Database db , final Result result ) { Collection < Clustering < ? > > clusterings = ResultUtil . filterResults ( db . getHierarchy ( ) , result , Clustering . class ) ; if ( clusterings . isEmpty ( ) ) { ResultUtil . addChildResult ( db , new ByLabelOrAllInOneClustering...
Ensure that the result contains at least one Clustering .
97
13
157,788
public static < A > double [ ] toPrimitiveDoubleArray ( A data , NumberArrayAdapter < ? , A > adapter ) { if ( adapter == DoubleArrayAdapter . STATIC ) { return ( ( double [ ] ) data ) . clone ( ) ; } final int len = adapter . size ( data ) ; double [ ] x = new double [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { x [ ...
Local copy see ArrayLikeUtil . toPrimitiveDoubleArray .
112
14
157,789
@ Override public void flush ( ) { try { out . flush ( ) ; } catch ( Exception ex ) { reportError ( null , ex , ErrorManager . FLUSH_FAILURE ) ; } try { err . flush ( ) ; } catch ( Exception ex ) { reportError ( null , ex , ErrorManager . FLUSH_FAILURE ) ; } }
Flush output streams
78
4
157,790
@ Override public void publish ( final LogRecord record ) { // determine destination final Writer destination ; if ( record . getLevel ( ) . intValue ( ) >= Level . WARNING . intValue ( ) ) { destination = this . err ; } else { destination = this . out ; } // format final String m ; // Progress records are handled spec...
Publish a log record .
531
6
157,791
private boolean checkForNaNs ( NumberVector vec ) { for ( int i = 0 , d = vec . getDimensionality ( ) ; i < d ; i ++ ) { double v = vec . doubleValue ( i ) ; if ( v != v ) { // NaN! return true ; } } return false ; }
Check for NaN values .
69
6
157,792
public static Relation < String > guessLabelRepresentation ( Database database ) throws NoSupportedDataTypeException { try { Relation < ? extends ClassLabel > classrep = database . getRelation ( TypeUtil . CLASSLABEL ) ; if ( classrep != null ) { return new ConvertToStringView ( classrep ) ; } } catch ( NoSupportedData...
Guess a potentially label - like representation preferring class labels .
226
12
157,793
public static ArrayModifiableDBIDs getObjectsByLabelMatch ( Database database , Pattern name_pattern ) { Relation < String > relation = guessLabelRepresentation ( database ) ; if ( name_pattern == null ) { return DBIDUtil . newArray ( ) ; } ArrayModifiableDBIDs ret = DBIDUtil . newArray ( ) ; for ( DBIDIter iditer = re...
Find object by matching their labels .
144
7
157,794
@ Override public void writeExternal ( ObjectOutput out ) throws IOException { super . writeExternal ( out ) ; out . writeObject ( conservativeApproximation ) ; }
Calls the super method and writes the conservative approximation of the knn distances of this entry to the specified stream .
36
23
157,795
@ Override public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { super . readExternal ( in ) ; conservativeApproximation = ( ApproximationLine ) in . readObject ( ) ; }
Calls the super method and reads the the conservative approximation of the knn distances of this entry from the specified input stream .
48
25
157,796
protected void updateDensities ( WritableDoubleDataStore rbod_score , DoubleDBIDList referenceDists ) { DoubleDBIDListIter it = referenceDists . iter ( ) ; for ( int l = 0 ; l < referenceDists . size ( ) ; l ++ ) { double density = computeDensity ( referenceDists , it , l ) ; // computeDensity modified the iterator, re...
Update the density estimates for each object .
141
8
157,797
static void chooseRemaining ( Relation < ? extends NumberVector > relation , DBIDs ids , DistanceQuery < NumberVector > distQ , int k , List < NumberVector > means , WritableDoubleDataStore weights , double weightsum , Random random ) { while ( true ) { if ( weightsum > Double . MAX_VALUE ) { throw new IllegalStateExce...
Choose remaining means weighted by distance .
344
7
157,798
private double factor ( int dimension ) { return maxima [ dimension ] > minima [ dimension ] ? maxima [ dimension ] - minima [ dimension ] : maxima [ dimension ] > 0 ? maxima [ dimension ] : 1 ; }
Returns a factor for normalization in a certain dimension .
50
11
157,799
protected double derivative ( int i , NumberVector v ) { final int dim = v . getDimensionality ( ) ; if ( dim == 1 ) { return 0. ; } // Adjust for boundary conditions, as per the article: i = ( i == 0 ) ? 1 : ( i == dim - 1 ) ? dim - 2 : i ; return ( v . doubleValue ( i ) - v . doubleValue ( i - 1 ) + ( v . doubleValue...
Given a NumberVector and the position of an element approximates the gradient of given element .
122
18