idx
int64
0
41.2k
question
stringlengths
83
4.15k
target
stringlengths
5
715
34,300
public static List < CollectionResult < ? > > getCollectionResults ( Result r ) { if ( r instanceof CollectionResult < ? > ) { List < CollectionResult < ? > > crs = new ArrayList < > ( 1 ) ; crs . add ( ( CollectionResult < ? > ) r ) ; return crs ; } if ( r instanceof HierarchicalResult ) { return filterResults ( ( ( H...
Collect all collection results from a Result
34,301
public static List < IterableResult < ? > > getIterableResults ( Result r ) { if ( r instanceof IterableResult < ? > ) { List < IterableResult < ? > > irs = new ArrayList < > ( 1 ) ; irs . add ( ( IterableResult < ? > ) r ) ; return irs ; } if ( r instanceof HierarchicalResult ) { return filterResults ( ( ( Hierarchica...
Return all Iterable results
34,302
public static < C extends Result > ArrayList < C > filterResults ( ResultHierarchy hier , Result r , Class < ? super C > restrictionClass ) { ArrayList < C > res = new ArrayList < > ( ) ; final It < C > it = hier . iterDescendantsSelf ( r ) . filter ( restrictionClass ) ; it . forEach ( res :: add ) ; return res ; }
Return only results of the given restriction class
34,303
public static void addChildResult ( HierarchicalResult parent , Result child ) { parent . getHierarchy ( ) . add ( parent , child ) ; }
Add a child result .
34,304
public static Database findDatabase ( ResultHierarchy hier , Result baseResult ) { final List < Database > dbs = filterResults ( hier , baseResult , Database . class ) ; return ( ! dbs . isEmpty ( ) ) ? dbs . get ( 0 ) : null ; }
Find the first database result in the tree .
34,305
public static void removeRecursive ( ResultHierarchy hierarchy , Result child ) { for ( It < Result > iter = hierarchy . iterParents ( child ) ; iter . valid ( ) ; iter . advance ( ) ) { hierarchy . remove ( iter . get ( ) , child ) ; } for ( It < Result > iter = hierarchy . iterChildren ( child ) ; iter . valid ( ) ; ...
Recursively remove a result and its children .
34,306
protected void findEigenVectors ( double [ ] [ ] imat , double [ ] [ ] evs , double [ ] lambda ) { final int size = imat . length ; Random rnd = random . getSingleThreadedRandom ( ) ; double [ ] tmp = new double [ size ] ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Learning projections" , tdim , ...
Find the first eigenvectors and eigenvalues using power iterations .
34,307
protected void randomInitialization ( double [ ] out , Random rnd ) { double l2 = 0. ; while ( ! ( l2 > 0 ) ) { for ( int d = 0 ; d < out . length ; d ++ ) { final double val = rnd . nextDouble ( ) ; out [ d ] = val ; l2 += val * val ; } } final double s = 1. / FastMath . sqrt ( l2 ) ; for ( int d = 0 ; d < out . lengt...
Choose a random vector of unit norm for power iterations .
34,308
protected double updateEigenvector ( double [ ] in , double [ ] out , double l ) { double s = 1. / ( l > 0. ? l : l < 0. ? - l : 1. ) ; s = ( in [ 0 ] > 0. ) ? s : - s ; double diff = 0. ; for ( int d = 0 ; d < in . length ; d ++ ) { in [ d ] *= s ; double delta = in [ d ] - out [ d ] ; diff += delta * delta ; out [ d ...
Compute the change in the eigenvector and normalize the output vector while doing so .
34,309
protected void updateMatrix ( double [ ] [ ] mat , final double [ ] evec , double eval ) { final int size = mat . length ; for ( int i = 0 ; i < size ; i ++ ) { final double [ ] mati = mat [ i ] ; final double eveci = evec [ i ] ; for ( int j = 0 ; j < size ; j ++ ) { mati [ j ] -= eval * eveci * evec [ j ] ; } } }
Update matrix by removing the effects of a known Eigenvector .
34,310
public static double pdf ( double x , double mu , double sigma , double k ) { if ( x == Double . POSITIVE_INFINITY || x == Double . NEGATIVE_INFINITY ) { return 0. ; } x = ( x - mu ) / sigma ; if ( k > 0 || k < 0 ) { if ( k * x > 1 ) { return 0. ; } double t = FastMath . log ( 1 - k * x ) ; return t == Double . NEGATIV...
PDF of GEV distribution
34,311
public static double cdf ( double val , double mu , double sigma , double k ) { final double x = ( val - mu ) / sigma ; if ( k > 0 || k < 0 ) { if ( k * x > 1 ) { return k > 0 ? 1 : 0 ; } return FastMath . exp ( - FastMath . exp ( FastMath . log ( 1 - k * x ) / k ) ) ; } else { return FastMath . exp ( - FastMath . exp ...
CDF of GEV distribution
34,312
public static double quantile ( double val , double mu , double sigma , double k ) { if ( val < 0.0 || val > 1.0 ) { return Double . NaN ; } if ( k < 0 ) { return mu + sigma * Math . max ( ( 1. - FastMath . pow ( - FastMath . log ( val ) , k ) ) / k , 1. / k ) ; } else if ( k > 0 ) { return mu + sigma * Math . min ( ( ...
Quantile function of GEV distribution
34,313
public static double cdf ( double x , double sigma ) { if ( x <= 0. ) { return 0. ; } final double xs = x / sigma ; return 1. - FastMath . exp ( - .5 * xs * xs ) ; }
CDF of Rayleigh distribution
34,314
public static double quantile ( double val , double sigma ) { if ( ! ( val >= 0. ) || ! ( val <= 1. ) ) { return Double . NaN ; } if ( val == 0. ) { return 0. ; } if ( val == 1. ) { return Double . POSITIVE_INFINITY ; } return sigma * FastMath . sqrt ( - 2. * FastMath . log ( 1. - val ) ) ; }
Quantile function of Rayleigh distribution
34,315
public OutlierResult run ( Database db , Relation < V > relation ) { ArrayDBIDs ids = DBIDUtil . ensureArray ( relation . getDBIDs ( ) ) ; SimilarityQuery < V > sq = db . getSimilarityQuery ( relation , kernelFunction ) ; KernelMatrix kernelMatrix = new KernelMatrix ( sq , relation , ids ) ; WritableDoubleDataStore abo...
Run ABOD on the data set .
34,316
protected double computeABOF ( KernelMatrix kernelMatrix , DBIDRef pA , DBIDArrayIter pB , DBIDArrayIter pC , MeanVariance s ) { s . reset ( ) ; double simAA = kernelMatrix . getSimilarity ( pA , pA ) ; for ( pB . seek ( 0 ) ; pB . valid ( ) ; pB . advance ( ) ) { if ( DBIDUtil . equal ( pB , pA ) ) { continue ; } doub...
Compute the exact ABOF value .
34,317
public OutlierResult run ( Database database , Relation < O > relation ) { DBIDs ids = relation . getDBIDs ( ) ; WritableDoubleDataStore store = DataStoreUtil . makeDoubleStorage ( ids , DataStoreFactory . HINT_DB ) ; DistanceQuery < O > distq = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; KNNQu...
Run the parallel kNN weight outlier detector .
34,318
public Clustering < ? > run ( final Database database , final Relation < DiscreteUncertainObject > relation ) { if ( relation . size ( ) <= 0 ) { return new Clustering < > ( "Uk-Means Clustering" , "ukmeans-clustering" ) ; } DBIDs sampleids = DBIDUtil . randomSample ( relation . getDBIDs ( ) , k , rnd ) ; List < double...
Run the clustering .
34,319
protected boolean updateAssignment ( DBIDIter iditer , List < ? extends ModifiableDBIDs > clusters , WritableIntegerDataStore assignment , int newA ) { final int oldA = assignment . intValue ( iditer ) ; if ( oldA == newA ) { return false ; } clusters . get ( newA ) . add ( iditer ) ; assignment . putInt ( iditer , new...
Update the cluster assignment .
34,320
protected double getExpectedRepDistance ( NumberVector rep , DiscreteUncertainObject uo ) { SquaredEuclideanDistanceFunction euclidean = SquaredEuclideanDistanceFunction . STATIC ; int counter = 0 ; double sum = 0.0 ; for ( int i = 0 ; i < uo . getNumberSamples ( ) ; i ++ ) { sum += euclidean . distance ( rep , uo . ge...
Get expected distance between a Vector and an uncertain object
34,321
protected void logVarstat ( DoubleStatistic varstat , double [ ] varsum ) { if ( varstat != null ) { double s = sum ( varsum ) ; getLogger ( ) . statistics ( varstat . setDouble ( s ) ) ; } }
Log statistics on the variance sum .
34,322
public void save ( ) throws FileNotFoundException { PrintStream p = new PrintStream ( file ) ; p . println ( COMMENT_PREFIX + "Saved ELKI settings. First line is title, remaining lines are parameters." ) ; for ( Pair < String , ArrayList < String > > settings : store ) { p . println ( settings . first ) ; for ( String ...
Save the current data to the given file .
34,323
public void load ( ) throws FileNotFoundException , IOException { BufferedReader is = new BufferedReader ( new InputStreamReader ( new FileInputStream ( file ) ) ) ; ArrayList < String > buf = new ArrayList < > ( ) ; while ( is . ready ( ) ) { String line = is . readLine ( ) ; if ( line . startsWith ( COMMENT_PREFIX ) ...
Read the current file
34,324
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 .
34,325
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 .
34,326
public Clustering < Model > run ( Database database , Relation < V > relation ) { int dim_c = RelationUtil . dimensionality ( relation ) ; if ( dim_c < l ) { throw new IllegalStateException ( "Dimensionality of data < parameter l! " + "(" + dim_c + " < " + l + ")" ) ; } int k_c = Math . min ( relation . size ( ) , k_i ...
Performs the ORCLUS algorithm on the given database .
34,327
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 .
34,328
private void assign ( Relation < V > database , List < ORCLUSCluster > clusters ) { NumberVectorDistanceFunction < ? super V > distFunc = SquaredEuclideanDistanceFunction . STATIC ; for ( ORCLUSCluster cluster : clusters ) { cluster . objectIDs . clear ( ) ; } List < NumberVector > projectedCentroids = new ArrayList < ...
Creates a partitioning of the database by assigning each object to its closest seed .
34,329
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
34,330
private ProjectedEnergy projectedEnergy ( Relation < V > relation , ORCLUSCluster c_i , ORCLUSCluster c_j , int i , int j , int dim ) { NumberVectorDistanceFunction < ? super V > distFunc = SquaredEuclideanDistanceFunction . STATIC ; ORCLUSCluster c_ij = union ( relation , c_i , c_j , dim ) ; double sum = 0. ; NumberVe...
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 .
34,331
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 .
34,332
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 .
34,333
protected int findMerge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder ) { double mindist = Double . POSITIVE_INFINITY ; int x = - 1 , y = - 1 ; for ( int cx = 0 ; cx < size ; cx ++ ) { final int cy = besti [ cx ] ; if ( cy < 0 ) { continue ; } final d...
Perform the next merge step .
34,334
protected void merge ( int size , MatrixParadigm mat , double [ ] bestd , int [ ] besti , PointerHierarchyRepresentationBuilder builder , double mindist , int x , int y ) { final DBIDArrayIter ix = mat . ix . seek ( x ) , iy = mat . iy . seek ( y ) ; if ( LOG . isDebuggingFine ( ) ) { LOG . debugFine ( "Merging: " + DB...
Execute the cluster merge .
34,335
private void updateCache ( int size , double [ ] scratch , double [ ] bestd , int [ ] besti , int x , int y , int j , double d ) { if ( d <= bestd [ j ] ) { bestd [ j ] = d ; besti [ j ] = y ; return ; } if ( besti [ j ] == x || besti [ j ] == y ) { findBest ( size , scratch , bestd , besti , j ) ; } }
Update the cache .
34,336
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
34,337
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 = nul...
Try to automatically generate a title for this .
34,338
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 .
34,339
private static Class < ? > getRestrictionClass ( OptionID oid , final Parameter < ? > firstopt , Map < OptionID , List < Pair < Parameter < ? > , Class < ? > > > > byopt ) { Class < ? > superclass = getRestrictionClass ( firstopt ) ; for ( Pair < Parameter < ? > , Class < ? > > clinst : byopt . get ( oid ) ) { if ( cli...
Get the restriction class of an option .
34,340
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 .
34,341
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 .
34,342
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 .
34,343
public DoubleDBIDList reverseKNNQuery ( DBIDRef id , int k ) { ModifiableDoubleDBIDList result = DBIDUtil . newDistanceDBIDList ( ) ; final Heap < MTreeSearchCandidate > pq = new UpdatableHeap < > ( ) ; pq . add ( new MTreeSearchCandidate ( 0. , getRootID ( ) , null , Double . NaN ) ) ; while ( ! pq . isEmpty ( ) ) { M...
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 .
34,344
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 .
34,345
private PolynomialApproximation approximateKnnDistances ( double [ ] knnDistances ) { StringBuilder msg = new StringBuilder ( ) ; int k_0 = 0 ; if ( settings . log ) { for ( int i = 0 ; i < settings . kmax ; i ++ ) { double dist = knnDistances [ i ] ; if ( dist == 0 ) { k_0 ++ ; } else { break ; } } } double [ ] x = ne...
Computes the polynomial approximation of the specified knn - distances .
34,346
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 ) { final double dista = Math . abs ( getRX ( a , o ) ) + Math . abs ( getRY ( a , o ) ) ; final double distb = Math . abs ( getRX ( b ...
Test whether a point is left of the other wrt . the origin .
34,347
private double mdist ( double [ ] a , double [ ] b ) { return Math . abs ( a [ 0 ] - b [ 0 ] ) + Math . abs ( a [ 1 ] - b [ 1 ] ) ; }
Manhattan distance .
34,348
private boolean isConvex ( double [ ] a , double [ ] b , double [ ] c ) { 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 ) ? ( mdist ( b , c ) > mdist ( a , b ) + mdist ( a , c ) ) : ( area < 0 ) ; }
Simple convexity test .
34,349
private void grahamScan ( ) { if ( points . size ( ) < 3 ) { return ; } Iterator < double [ ] > iter = points . iterator ( ) ; Stack < double [ ] > stack = new Stack < > ( ) ; final double [ ] first = iter . next ( ) ; stack . add ( first ) ; while ( iter . hasNext ( ) ) { double [ ] n = iter . next ( ) ; if ( mdist ( ...
The actual graham scan main loop .
34,350
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 .
34,351
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 .
34,352
private static int [ ] mstPartition ( double [ ] [ ] matrix ) { final int n = matrix . length ; int [ ] edges = PrimsMinimumSpanningTree . processDense ( matrix ) ; double meanlength = thresholdLength ( matrix , edges ) ; int [ ] idx = new int [ n ] , best = new int [ n ] , sizes = new int [ n ] ; int bestsize = - 1 ; ...
Partition the data using the minimu spanning tree .
34,353
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 .
34,354
private static double edgelength ( double [ ] [ ] matrix , int [ ] edges , int i ) { i <<= 1 ; return matrix [ edges [ i ] ] [ edges [ i + 1 ] ] ; }
Length of edge i .
34,355
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 .
34,356
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 .
34,357
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 .
34,358
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 .
34,359
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 .
34,360
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 .
34,361
public static < O > RangeQuery < O > getLinearScanSimilarityRangeQuery ( SimilarityQuery < O > simQuery ) { if ( simQuery instanceof PrimitiveSimilarityQuery ) { final PrimitiveSimilarityQuery < O > pdq = ( PrimitiveSimilarityQuery < O > ) simQuery ; return new LinearScanPrimitiveSimilarityRangeQuery < > ( pdq ) ; } re...
Get a linear scan query for the given similarity query .
34,362
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 .
34,363
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 .
34,364
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 .
34,365
private static Class < ? > tryLoadClass ( String value ) { try { return CLASSLOADER . loadClass ( value ) ; } catch ( ClassNotFoundException e ) { return null ; } }
Attempt to load a class
34,366
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 .
34,367
public static List < Class < ? > > findAllImplementations ( Class < ? > c , boolean everything , boolean parameterizable ) { if ( c == null ) { return Collections . emptyList ( ) ; } if ( ! everything && parameterizable ) { return findAllImplementations ( c ) ; } List < Class < ? > > known = findAllImplementations ( c ...
Find all implementations of a given class in the classpath .
34,368
private static < C > Class < ? > tryAlternateNames ( Class < ? super C > restrictionClass , String value , Entry e ) { StringBuilder buf = new StringBuilder ( value . length ( ) + 100 ) ; Class < ? > clazz = tryLoadClass ( buf . append ( value ) . append ( FACTORY_POSTFIX ) . toString ( ) ) ; if ( clazz != null ) { ret...
Try loading alternative names .
34,369
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 .
34,370
protected SimpleTypeInformation < ? > convertedType ( SimpleTypeInformation < ? > in , NumberVector . Factory < V > factory ) { return new VectorFieldTypeInformation < > ( factory , tdim ) ; }
Get the output type from the input type after conversion .
34,371
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 .
34,372
public Curve makeCurve ( ) { Curve c = new Curve ( curves . size ( ) ) ; curves . add ( c ) ; return c ; }
Make a new curve .
34,373
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 .
34,374
protected synchronized void publish ( LogRecord record ) throws BadLocationException { final Formatter fmt ; final Style style ; if ( record . getLevel ( ) . intValue ( ) >= Level . WARNING . intValue ( ) ) { fmt = errformat ; style = errStyle ; } else if ( record . getLevel ( ) . intValue ( ) <= Level . FINE . intValu...
Publish a log record to the logging pane .
34,375
protected void optimizeSNE ( AffinityMatrix pij , double [ ] [ ] sol ) { final int size = pij . size ( ) ; if ( size * 3L * dim > 0x7FFF_FFFAL ) { throw new AbortException ( "Memory exceeds Java array size limit." ) ; } double [ ] meta = new double [ size * 3 * dim ] ; final int dim3 = dim * 3 ; for ( int off = 2 * dim...
Perform the actual tSNE optimization .
34,376
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 .
34,377
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 .
34,378
public OutlierResult run ( Database database , Relation < O > relation ) { DistanceFunction < ? super O > df = clusterer . getDistanceFunction ( ) ; DistanceQuery < O > dq = database . getDistanceQuery ( relation , df ) ; Clustering < ? > c = clusterer . run ( database , relation ) ; WritableDoubleDataStore scores = Da...
Run the outlier detection algorithm .
34,379
public FittingFunctionResult eval ( double x , double [ ] params ) { final int len = params . length ; assert ( len % 3 ) == 0 ; double y = 0.0 ; double [ ] gradients = new double [ len ] ; for ( int i = 2 ; i < params . length ; i += 3 ) { double stdpar = ( x - params [ i - 2 ] ) / params [ i - 1 ] ; double e = FastMa...
Compute the mixture of Gaussians at the given position
34,380
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 .
34,381
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 .
34,382
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 ) ; WritableDataStore < double [ ] > densities = Dat...
Run the KDEOS outlier detection algorithm .
34,383
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 ; for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { densities . put ( it...
Perform the kernel density estimation step .
34,384
private int dimensionality ( Relation < O > rel ) { if ( idim >= 0 ) { return idim ; } @ SuppressWarnings ( "unchecked" ) final Relation < NumberVector > frel = ( Relation < NumberVector > ) rel ; int dim = RelationUtil . dimensionality ( frel ) ; if ( dim < 1 ) { throw new AbortException ( "When using KDEOS with non-v...
Ugly hack to allow using this implementation without having a well - defined dimensionality .
34,385
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 .
34,386
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 .
34,387
private Relation < ParameterizationFunction > preprocess ( Relation < V > vrel ) { DBIDs ids = vrel . getDBIDs ( ) ; SimpleTypeInformation < ParameterizationFunction > type = new SimpleTypeInformation < > ( ParameterizationFunction . class ) ; WritableDataStore < ParameterizationFunction > prep = DataStoreUtil . makeSt...
Preprocess the dataset precomputing the parameterization functions .
34,388
private void initHeap ( ObjectHeap < CASHInterval > heap , Relation < ParameterizationFunction > relation , int dim , DBIDs ids ) { CASHIntervalSplit split = new CASHIntervalSplit ( relation , minPts ) ; double [ ] minMax = determineMinMaxDistance ( relation , dim ) ; double d_min = minMax [ 0 ] , d_max = minMax [ 1 ] ...
Initializes the heap with the root intervals .
34,389
private MaterializedRelation < ParameterizationFunction > buildDB ( int dim , double [ ] [ ] basis , DBIDs ids , Relation < ParameterizationFunction > relation ) { ProxyDatabase proxy = new ProxyDatabase ( ids ) ; SimpleTypeInformation < ParameterizationFunction > type = new SimpleTypeInformation < > ( Parameterization...
Builds a dim - 1 dimensional database where the objects are projected into the specified subspace .
34,390
private ParameterizationFunction project ( double [ ] [ ] basis , ParameterizationFunction f ) { 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 .
34,391
private double [ ] [ ] determineBasis ( double [ ] alpha ) { final int dim = alpha . length ; 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 , alpha ) * FastMath . c...
Determines a basis defining a subspace described by the specified alpha values .
34,392
private CASHInterval determineNextIntervalAtMaxLevel ( ObjectHeap < CASHInterval > heap ) { CASHInterval next = doDetermineNextIntervalAtMaxLevel ( heap ) ; 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 .
34,393
private CASHInterval doDetermineNextIntervalAtMaxLevel ( ObjectHeap < CASHInterval > heap ) { CASHInterval interval = heap . poll ( ) ; int dim = interval . getDimensionality ( ) ; while ( true ) { if ( interval . getLevel ( ) >= maxLevel && interval . getMaxSplitDimension ( ) == ( dim - 1 ) ) { return interval ; } if ...
Recursive helper method to determine the next best interval at maximum level i . e . the next interval containing the most unprocessed objects
34,394
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 .
34,395
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
34,396
public Clustering < M > run ( Database database , Relation < V > relation ) { if ( relation . size ( ) == 0 ) { throw new IllegalArgumentException ( "database empty: must contain elements" ) ; } List < ? extends EMClusterModel < M > > models = mfactory . buildInitialModels ( database , relation , k , SquaredEuclideanDi...
Performs the EM clustering algorithm on the given database .
34,397
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 .
34,398
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 .
34,399
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 .