idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
157,600 | public static ArrayDBIDs ensureArray ( DBIDs ids ) { return ids instanceof ArrayDBIDs ? ( ArrayDBIDs ) ids : newArray ( ids ) ; } | Ensure that the given DBIDs are array - indexable . | 39 | 13 |
157,601 | public static SetDBIDs ensureSet ( DBIDs ids ) { return ids instanceof SetDBIDs ? ( SetDBIDs ) ids : newHashSet ( ids ) ; } | Ensure that the given DBIDs support fast contains operations . | 40 | 12 |
157,602 | public static ModifiableDBIDs ensureModifiable ( DBIDs ids ) { return ids instanceof ModifiableDBIDs ? ( ModifiableDBIDs ) ids : // ids instanceof HashSetDBIDs ? newHashSet ( ids ) : newArray ( ids ) ; } | Ensure modifiable . | 61 | 5 |
157,603 | public static DBIDPair newPair ( DBIDRef id1 , DBIDRef id2 ) { return DBIDFactory . FACTORY . newPair ( id1 , id2 ) ; } | Make a DBID pair . | 44 | 6 |
157,604 | public static DoubleDBIDPair newPair ( double val , DBIDRef id ) { return DBIDFactory . FACTORY . newPair ( val , id ) ; } | Make a DoubleDBIDPair . | 39 | 8 |
157,605 | public static void sort ( int [ ] data , Comparator < ? super DBIDRef > comp ) { sort ( data , 0 , data . length , comp ) ; } | Sort the full array using the given comparator . | 36 | 10 |
157,606 | private static int compare ( IntegerDBIDVar i1 , int p1 , IntegerDBIDVar i2 , int p2 , Comparator < ? super DBIDRef > comp ) { i1 . internalSetIndex ( p1 ) ; i2 . internalSetIndex ( p2 ) ; return comp . compare ( i1 , i2 ) ; } | Compare two elements . | 74 | 4 |
157,607 | @ Override protected int computeHeight ( ) { N node = getRoot ( ) ; int tHeight = 1 ; // compute height while ( ! node . isLeaf ( ) && node . getNumEntries ( ) != 0 ) { SpatialEntry entry = node . getEntry ( 0 ) ; node = getNode ( entry ) ; tHeight ++ ; } return tHeight ; } | Computes the height of this XTree . Is called by the constructor . and should be overwritten by subclasses if necessary . | 81 | 26 |
157,608 | public long commit ( ) throws IOException { final PageFile < N > file = super . getFile ( ) ; if ( ! ( file instanceof PersistentPageFile ) ) { throw new IllegalStateException ( "Trying to commit a non-persistent XTree" ) ; } long npid = file . getNextPageID ( ) ; XTreeHeader ph = ( XTreeHeader ) ( ( PersistentPageFile... | Writes all supernodes to the end of the file . This is only supposed to be used for a final saving of an XTree . If another page is added to this tree the supernodes written to file by this operation are over - written . | 485 | 52 |
157,609 | public void setExpanded ( SpatialEntry entry1 , SpatialEntry entry2 ) { IntSet exp1 = expanded . get ( getPageID ( entry1 ) ) ; if ( exp1 == null ) { exp1 = new IntOpenHashSet ( ) ; expanded . put ( getPageID ( entry1 ) , exp1 ) ; } exp1 . add ( getPageID ( entry2 ) ) ; } | Marks the nodes with the specified ids as expanded . | 88 | 12 |
157,610 | public IntSet getExpanded ( SpatialEntry entry ) { IntSet exp = expanded . get ( getPageID ( entry ) ) ; return ( exp != null ) ? exp : IntSets . EMPTY_SET ; } | Returns the nodes which are already expanded with the specified node . | 48 | 12 |
157,611 | public void increment ( double coord , double val ) { int bin = getBinNr ( coord ) ; if ( bin < 0 ) { if ( size - bin > data . length ) { // Reallocate. TODO: use an arraylist-like grow strategy! double [ ] tmpdata = new double [ growSize ( data . length , size - bin ) ] ; System . arraycopy ( data , 0 , tmpdata , - bi... | Increment the value of a bin . | 338 | 8 |
157,612 | public double get ( double coord ) { int bin = getBinNr ( coord ) ; return ( bin < 0 || bin >= size ) ? 0 : data [ bin ] ; } | Get the value at a particular position . | 39 | 8 |
157,613 | public Assignment update ( Border border ) { Arrays . sort ( cs ) ; int j = 1 ; boolean found = ( cs [ 0 ] . core == border . core ) ; for ( int i = 1 ; i < cs . length ; i ++ ) { if ( cs [ i ] . core != cs [ i - 1 ] . core ) { cs [ j ++ ] = cs [ i ] ; } found |= ( cs [ i ] . core == border . core ) ; } if ( found ) { ... | Add a new border to the existing borders . | 199 | 9 |
157,614 | public Core getCore ( ) { Core a = cs [ 0 ] . core ; for ( int i = 1 ; i < cs . length ; i ++ ) { Core v = cs [ i ] . core ; a = a . num > v . num ? a : v ; // max, of negative values } return a ; } | Get the core this is assigned to . | 69 | 8 |
157,615 | protected int currentCluster ( List < ? extends ModifiableDBIDs > clusters , DBIDRef id ) { for ( int i = 0 ; i < k ; i ++ ) { if ( clusters . get ( i ) . contains ( id ) ) { return i ; } } return - 1 ; } | Find the current cluster assignment . | 63 | 6 |
157,616 | protected void computeINFLO ( Relation < O > relation , ModifiableDBIDs pruned , KNNQuery < O > knnq , WritableDataStore < ModifiableDBIDs > rNNminuskNNs , WritableDoubleDataStore inflos , DoubleMinMax inflominmax ) { FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Computing INFLOs" , relation . size ... | Compute the final INFLO scores . | 514 | 9 |
157,617 | public OutlierResult run ( Database database , Relation < O > relation ) { // Get the query functions: DistanceQuery < O > dq = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; KNNQuery < O > knnq = database . getKNNQuery ( dq , k ) ; // Get the objects to process, and a data storage for counting an... | Run the ODIN algorithm | 479 | 5 |
157,618 | public static Icon getStockIcon ( String name ) { SoftReference < Icon > ref = iconcache . get ( name ) ; if ( ref != null ) { Icon icon = ref . get ( ) ; if ( icon != null ) { return icon ; } } java . net . URL imgURL = StockIcon . class . getResource ( name + ".png" ) ; if ( imgURL != null ) { Icon icon = new ImageIc... | Get a particular stock icon . | 140 | 6 |
157,619 | @ Override public void initializeFromFile ( TreeIndexHeader header , PageFile < FlatRStarTreeNode > file ) { super . initializeFromFile ( header , file ) ; // reconstruct root int nextPageID = file . getNextPageID ( ) ; dirCapacity = nextPageID ; root = createNewDirectoryNode ( ) ; for ( int i = 1 ; i < nextPageID ; i ... | Initializes the flat RTree from an existing persistent file . | 157 | 12 |
157,620 | protected Node bulkConstruct ( DBIDRef cur , int maxScale , double parentDist , ModifiableDoubleDBIDList elems ) { assert ( ! elems . contains ( cur ) ) ; final double max = maxDistance ( elems ) ; final int scale = Math . min ( distToScale ( max ) - 1 , maxScale ) ; final int nextScale = scale - 1 ; // Leaf node, beca... | Bulk - load the cover tree . | 640 | 8 |
157,621 | @ Override public double getWeight ( double distance , double max , double stddev ) { if ( max <= 0 ) { return 1.0 ; } double relativedistance = distance / max ; return 1.0 - 0.9 * relativedistance * relativedistance ; } | Evaluate quadratic weight . stddev is ignored . | 60 | 14 |
157,622 | public double maxDist ( SpatialComparable mbr1 , SpatialComparable mbr2 ) { final int dim1 = mbr1 . getDimensionality ( ) , dim2 = mbr2 . getDimensionality ( ) ; final int mindim = dim1 < dim2 ? dim1 : dim2 ; double agg = 0. ; for ( int d = 0 ; d < mindim ; d ++ ) { double d1 = mbr1 . getMax ( d ) - mbr2 . getMin ( d )... | Maximum distance of two objects . | 324 | 6 |
157,623 | public synchronized void updateFromTrackParameters ( TrackParameters track ) { parameters . clear ( ) ; for ( TrackedParameter p : track . getAllParameters ( ) ) { Parameter < ? > option = p . getParameter ( ) ; String value = null ; if ( option . isDefined ( ) ) { if ( option . tookDefaultValue ( ) ) { value = Dynamic... | Update the Parameter list from the collected options of an ELKI context | 369 | 14 |
157,624 | public synchronized void addParameter ( Parameter < ? > option , String value , int bits , int depth ) { parameters . add ( new Node ( option , value , bits , depth ) ) ; } | Add a single parameter to the list | 41 | 7 |
157,625 | public static List < Clustering < ? extends Model > > getClusteringResults ( Result r ) { if ( r instanceof Clustering < ? > ) { List < Clustering < ? > > crs = new ArrayList <> ( 1 ) ; crs . add ( ( Clustering < ? > ) r ) ; return crs ; } if ( r instanceof HierarchicalResult ) { return ResultUtil . filterResults ( ( (... | Collect all clustering results from a Result | 133 | 8 |
157,626 | private static double [ ] randomLatitudeLongitude ( Random r ) { // Make marginally more realistic looking data by non-uniformly sampling // latitude, since Earth is a sphere, and there is not much at the poles double lat = Math . pow ( 1. - r . nextDouble ( ) * 2. , 2 ) / 2. * 180 ; double lng = ( .5 - r . nextDouble ... | Generate random coordinates . | 106 | 5 |
157,627 | @ Override public double distance ( NumberVector v1 , NumberVector v2 ) { return 1 - Math . abs ( PearsonCorrelation . coefficient ( v1 , v2 ) ) ; } | Computes the absolute Pearson correlation distance for two given feature vectors . | 40 | 13 |
157,628 | private long inverse ( double current ) { // Represent to base b. short [ ] digits = new short [ maxi ] ; for ( int j = 0 ; j < maxi ; j ++ ) { current *= base ; digits [ j ] = ( short ) current ; current -= digits [ j ] ; if ( current <= 1e-10 ) { break ; } } long inv = 0 ; for ( int j = maxi - 1 ; j >= 0 ; j -- ) { i... | Compute the inverse with respect to the given base . | 117 | 11 |
157,629 | private double radicalInverse ( long i ) { double digit = 1.0 / ( double ) base ; double radical = digit ; double inverse = 0.0 ; while ( i > 0 ) { inverse += digit * ( double ) ( i % base ) ; digit *= radical ; i /= base ; } return inverse ; } | Compute the radical inverse of i . | 69 | 8 |
157,630 | private double nextRadicalInverse ( ) { counter ++ ; // Do at most MAXFAST appromate steps if ( counter >= MAXFAST ) { counter = 0 ; inverse += MAXFAST ; current = radicalInverse ( inverse ) ; return current ; } // Fast approximation: double nextInverse = current + invbase ; if ( nextInverse < ALMOST_ONE ) { current = ... | Compute the next radical inverse . | 158 | 7 |
157,631 | public String dimensonsToString ( String sep ) { StringBuilder result = new StringBuilder ( 100 ) . append ( ' ' ) ; for ( int dim = BitsUtil . nextSetBit ( dimensions , 0 ) ; dim >= 0 ; dim = BitsUtil . nextSetBit ( dimensions , dim + 1 ) ) { result . append ( dim + 1 ) . append ( sep ) ; } if ( result . length ( ) > ... | Returns a string representation of the dimensions of this subspace . | 140 | 12 |
157,632 | public boolean isSubspace ( Subspace subspace ) { return this . dimensionality <= subspace . dimensionality && // BitsUtil . intersectionSize ( dimensions , subspace . dimensions ) == dimensionality ; } | Returns true if this subspace is a subspace of the specified subspace i . e . if the set of dimensions building this subspace are contained in the set of dimensions building the specified subspace . | 44 | 41 |
157,633 | protected < E extends SpatialComparable , A > double computeOverlap ( A entries , ArrayAdapter < E , A > getter , long [ ] assign ) { ModifiableHyperBoundingBox mbr1 = null , mbr2 = null ; for ( int i = 0 ; i < getter . size ( entries ) ; i ++ ) { E e = getter . get ( entries , i ) ; if ( BitsUtil . get ( assign , i ) ... | Compute overlap of assignment | 235 | 5 |
157,634 | private void binarySplitSort ( List < ? extends SpatialComparable > objs , final int start , final int end , int depth , final int numdim , int [ ] dims , Sorter comp ) { final int mid = start + ( ( end - start ) >>> 1 ) ; // Make invariant comp . setDimension ( dims != null ? dims [ depth ] : depth ) ; QuickSelect . q... | Sort the array using a binary split in dimension curdim then recurse with the next dimension . | 189 | 19 |
157,635 | public static Element svgElement ( Document document , String name ) { return document . createElementNS ( SVGConstants . SVG_NAMESPACE_URI , name ) ; } | Create a SVG element in appropriate namespace | 38 | 7 |
157,636 | public static void setStyle ( Element el , String d ) { el . setAttribute ( SVGConstants . SVG_STYLE_ATTRIBUTE , d ) ; } | Set a SVG style attribute | 37 | 5 |
157,637 | public static void addCSSClass ( Element e , String cssclass ) { String oldval = e . getAttribute ( SVGConstants . SVG_CLASS_ATTRIBUTE ) ; if ( oldval == null || oldval . length ( ) == 0 ) { setAtt ( e , SVGConstants . SVG_CLASS_ATTRIBUTE , cssclass ) ; return ; } String [ ] classes = oldval . split ( " " ) ; for ( Str... | Add a CSS class to an Element . | 150 | 8 |
157,638 | public static void removeCSSClass ( Element e , String cssclass ) { String oldval = e . getAttribute ( SVGConstants . SVG_CLASS_ATTRIBUTE ) ; if ( oldval == null ) { return ; } String [ ] classes = oldval . split ( " " ) ; if ( classes . length == 1 ) { if ( cssclass . equals ( classes [ 0 ] ) ) { e . removeAttribute (... | Remove a CSS class from an Element . | 329 | 8 |
157,639 | public static Element makeStyleElement ( Document document ) { Element style = SVGUtil . svgElement ( document , SVGConstants . SVG_STYLE_TAG ) ; style . setAttribute ( SVGConstants . SVG_TYPE_ATTRIBUTE , SVGConstants . CSS_MIME_TYPE ) ; return style ; } | Make a new CSS style element for the given Document . | 71 | 11 |
157,640 | public static Element svgRect ( Document document , double x , double y , double w , double h ) { Element rect = SVGUtil . svgElement ( document , SVGConstants . SVG_RECT_TAG ) ; SVGUtil . setAtt ( rect , SVGConstants . SVG_X_ATTRIBUTE , x ) ; SVGUtil . setAtt ( rect , SVGConstants . SVG_Y_ATTRIBUTE , y ) ; SVGUtil . s... | Create a SVG rectangle element . | 154 | 6 |
157,641 | public static Element svgCircle ( Document document , double cx , double cy , double r ) { Element circ = SVGUtil . svgElement ( document , SVGConstants . SVG_CIRCLE_TAG ) ; SVGUtil . setAtt ( circ , SVGConstants . SVG_CX_ATTRIBUTE , cx ) ; SVGUtil . setAtt ( circ , SVGConstants . SVG_CY_ATTRIBUTE , cy ) ; SVGUtil . se... | Create a SVG circle element . | 128 | 6 |
157,642 | public static Element svgLine ( Document document , double x1 , double y1 , double x2 , double y2 ) { Element line = SVGUtil . svgElement ( document , SVGConstants . SVG_LINE_TAG ) ; SVGUtil . setAtt ( line , SVGConstants . SVG_X1_ATTRIBUTE , x1 ) ; SVGUtil . setAtt ( line , SVGConstants . SVG_Y1_ATTRIBUTE , y1 ) ; SVG... | Create a SVG line element . Do not confuse this with path elements . | 163 | 14 |
157,643 | public static Color stringToColor ( String str ) { int icol = SVG_COLOR_NAMES . getInt ( str . toLowerCase ( ) ) ; if ( icol != NO_VALUE ) { return new Color ( icol , false ) ; } return colorLookupStylesheet . stringToColor ( str ) ; } | Convert a color name from SVG syntax to an AWT color object . | 71 | 15 |
157,644 | public static String colorToString ( int col ) { final char [ ] buf = new char [ ] { ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' } ; for ( int i = 6 ; i > 0 ; i -- ) { final int v = ( col & 0xF ) ; buf [ i ] = ( char ) ( ( v < 10 ) ? ( ' ' + v ) : ( ' ' + v - 10 ) ) ; col >>>= 4 ; } return new String ( buf ) ; } | Convert a color name from an integer RGB color to CSS syntax | 117 | 13 |
157,645 | public static SVGPoint elementCoordinatesFromEvent ( Document doc , Element tag , Event evt ) { try { DOMMouseEvent gnme = ( DOMMouseEvent ) evt ; SVGMatrix mat = ( ( SVGLocatable ) tag ) . getScreenCTM ( ) ; SVGMatrix imat = mat . inverse ( ) ; SVGPoint cPt = ( ( SVGDocument ) doc ) . getRootElement ( ) . createSVGPoi... | Convert the coordinates of an DOM Event from screen into element coordinates . | 178 | 14 |
157,646 | public static void removeLastChild ( Element tag ) { final Node last = tag . getLastChild ( ) ; if ( last != null ) { tag . removeChild ( last ) ; } } | Remove last child of an element when present | 40 | 8 |
157,647 | public static void removeFromParent ( Element elem ) { if ( elem != null && elem . getParentNode ( ) != null ) { elem . getParentNode ( ) . removeChild ( elem ) ; } } | Remove an element from its parent if defined . | 49 | 9 |
157,648 | public static Element svgCircleSegment ( SVGPlot svgp , double centerx , double centery , double angleStart , double angleDelta , double innerRadius , double outerRadius ) { final DoubleWrapper tmp = new DoubleWrapper ( ) ; // To return cosine double sin1st = FastMath . sinAndCos ( angleStart , tmp ) ; double cos1st = ... | Create a circle segment . | 418 | 5 |
157,649 | protected WritableDoubleDataStore computeCoreDists ( DBIDs ids , KNNQuery < O > knnQ , int minPts ) { final Logging LOG = getLogger ( ) ; final WritableDoubleDataStore coredists = DataStoreUtil . makeDoubleStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_DB ) ; FiniteProgress cprog = LOG . isVerbos... | Compute the core distances for all objects . | 214 | 9 |
157,650 | protected void convertToPointerRepresentation ( ArrayDBIDs ids , DoubleLongHeap heap , WritableDBIDDataStore pi , WritableDoubleDataStore lambda ) { final Logging LOG = getLogger ( ) ; // Initialize parent array: for ( DBIDArrayIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { pi . put ( iter , ite... | Convert spanning tree to a pointer representation . | 693 | 9 |
157,651 | private void updateHeap ( final double distance , final int iid ) { final double prevdist = kdist ; final int previd = heap . peekValue ( ) ; heap . replaceTopElement ( distance , iid ) ; kdist = heap . peekKey ( ) ; // If the kdist improved, zap ties. if ( kdist < prevdist ) { numties = 0 ; } else { addToTies ( previd... | Do a full update for the heap . | 97 | 8 |
157,652 | private void addToTies ( int id ) { if ( ties . length == numties ) { ties = Arrays . copyOf ( ties , ( ties . length << 1 ) + 1 ) ; // grow. } ties [ numties ] = id ; ++ numties ; } | Ensure the ties array has capacity for at least one more element . | 59 | 14 |
157,653 | public static int numberOfFreeParameters ( Relation < ? extends NumberVector > relation , Clustering < ? extends MeanModel > clustering ) { // number of clusters int m = clustering . getAllClusters ( ) . size ( ) ; // num_ctrs // dimensionality of data points int dim = RelationUtil . dimensionality ( relation ) ; // nu... | Compute the number of free parameters . | 101 | 8 |
157,654 | protected void dumpClusteringOutput ( PrintStream writer , ResultHierarchy hierarchy , Clustering < ? > c ) { DBIDRange ids = null ; for ( It < Relation < ? > > iter = hierarchy . iterParents ( c ) . filter ( Relation . class ) ; iter . valid ( ) ; iter . advance ( ) ) { DBIDs pids = iter . get ( ) . getDBIDs ( ) ; if ... | Dump a single clustering result . | 593 | 8 |
157,655 | public < F extends NumberVector > F getMeanVector ( Relation < ? extends F > relation ) { return RelationUtil . getNumberVectorFactory ( relation ) . newNumberVector ( mean ) ; } | Get the mean as vector . | 45 | 6 |
157,656 | public void reset ( ) { Arrays . fill ( mean , 0. ) ; Arrays . fill ( nmea , 0. ) ; if ( elements != null ) { for ( int i = 0 ; i < elements . length ; i ++ ) { Arrays . fill ( elements [ i ] , 0. ) ; } } else { elements = new double [ mean . length ] [ mean . length ] ; } wsum = 0. ; } | Reset the covariance matrix . | 95 | 7 |
157,657 | public static CovarianceMatrix make ( Relation < ? extends NumberVector > relation ) { int dim = RelationUtil . dimensionality ( relation ) ; CovarianceMatrix c = new CovarianceMatrix ( dim ) ; double [ ] mean = c . mean ; int count = 0 ; // Compute mean first: for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer ... | Static Constructor from a full relation . | 428 | 8 |
157,658 | @ Override public StringBuilder appendToBuffer ( StringBuilder buf ) { String processedString = Integer . toString ( getProcessed ( ) ) ; int percentage = ( int ) ( getProcessed ( ) * 100.0 / total ) ; buf . append ( getTask ( ) ) ; buf . append ( ": " ) ; for ( int i = 0 ; i < totalLength - processedString . length ( ... | Append a string representation of the progress to the given string buffer . | 279 | 14 |
157,659 | public void ensureCompleted ( Logging logger ) { if ( ! isComplete ( ) ) { logger . warning ( "Progress had not completed automatically as expected: " + getProcessed ( ) + "/" + total , new Throwable ( ) ) ; setProcessed ( getTotal ( ) ) ; logger . progress ( this ) ; } } | Ensure that the progress was completed to make progress bars disappear | 71 | 12 |
157,660 | private void clusterData ( DBIDs ids , RangeQuery < O > rnnQuery , WritableDoubleDataStore radii , WritableDataStore < ModifiableDBIDs > labels ) { FiniteProgress clustProg = LOG . isVerbose ( ) ? new FiniteProgress ( "Density-Based Clustering" , ids . size ( ) , LOG ) : null ; // Iterate over all objects for ( DBIDIte... | This method applies a density based clustering algorithm . | 532 | 10 |
157,661 | private int updateSizes ( DBIDs ids , WritableDataStore < ModifiableDBIDs > labels , WritableIntegerDataStore newSizes ) { // to count the unclustered all over int countUnmerged = 0 ; for ( DBIDIter iter = ids . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { // checking the point's new cluster size after the clus... | This method updates each object s cluster size after the clustering step . | 162 | 14 |
157,662 | public PointerHierarchyRepresentationResult run ( Database database , Relation < O > relation ) { DBIDs ids = relation . getDBIDs ( ) ; WritableDBIDDataStore pi = DataStoreUtil . makeDBIDStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_STATIC ) ; WritableDoubleDataStore lambda = DataStoreUtil . mak... | Performs the SLINK algorithm on the given database . | 652 | 11 |
157,663 | protected void process ( DBIDRef id , ArrayDBIDs ids , DBIDArrayIter it , int n , WritableDBIDDataStore pi , WritableDoubleDataStore lambda , WritableDoubleDataStore m ) { slinkstep3 ( id , it , n , pi , lambda , m ) ; slinkstep4 ( id , it , n , pi , lambda ) ; } | SLINK main loop . | 82 | 5 |
157,664 | public void add ( DBIDRef id , double reach , DBIDRef pre ) { ids . add ( id ) ; reachability . putDouble ( id , reach ) ; if ( pre == null || pre instanceof DBIDVar && ! ( ( DBIDVar ) pre ) . isSet ( ) ) { return ; } predecessor . putDBID ( id , pre ) ; } | Add an object to the cluster order . | 81 | 8 |
157,665 | @ Override public ArrayModifiableDBIDs order ( DBIDs ids ) { ArrayModifiableDBIDs res = DBIDUtil . newArray ( ids . size ( ) ) ; for ( DBIDIter it = this . ids . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { if ( ids . contains ( it ) ) { res . add ( it ) ; } } return res ; } | Use the cluster order to sort the given collection ids . | 93 | 12 |
157,666 | public void getPredecessor ( DBIDRef id , DBIDVar out ) { if ( predecessor == null ) { out . unset ( ) ; return ; } predecessor . assignVar ( id , out ) ; } | Get the predecessor . | 46 | 4 |
157,667 | public OutlierResult run ( Database database , Relation < O > relation ) { StepProgress stepprog = LOG . isVerbose ( ) ? new StepProgress ( "COF" , 3 ) : null ; DistanceQuery < O > dq = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; LOG . beginStep ( stepprog , 1 , "Materializing COF neighborhoods... | Runs the COF algorithm on the given database . | 463 | 11 |
157,668 | private void computeCOFScores ( KNNQuery < O > knnq , DBIDs ids , DoubleDataStore acds , WritableDoubleDataStore cofs , DoubleMinMax cofminmax ) { FiniteProgress progressCOFs = LOG . isVerbose ( ) ? new FiniteProgress ( "COF for objects" , ids . size ( ) , LOG ) : null ; for ( DBIDIter iter = ids . iter ( ) ; iter . va... | Compute Connectivity outlier factors . | 319 | 8 |
157,669 | public void invokeLater ( Runnable r ) { queue . add ( r ) ; synchronized ( this ) { if ( synchronizer == null ) { runQueue ( ) ; } else { synchronizer . activate ( ) ; } } } | Add a new update to run at any appropriate time . | 49 | 11 |
157,670 | public void runQueue ( ) { synchronized ( sync ) { while ( ! queue . isEmpty ( ) ) { Runnable r = queue . poll ( ) ; if ( r != null ) { try { r . run ( ) ; } catch ( Exception e ) { // Alternatively, we could allow the specification of exception // handlers for each runnable in the API. For now we'll just log. // TODO:... | Run the processing queue now . This should usually be only invoked by the UpdateSynchronizer | 131 | 18 |
157,671 | public synchronized void synchronizeWith ( UpdateSynchronizer newsync ) { // LoggingUtil.warning("Synchronizing: " + sync + " " + newsync, new // Throwable()); if ( synchronizer == newsync ) { LoggingUtil . warning ( "Double-synced to the same plot!" , new Throwable ( ) ) ; return ; } if ( synchronizer != null ) { Logg... | Set a new update synchronizer . | 129 | 7 |
157,672 | public synchronized void unsynchronizeWith ( UpdateSynchronizer oldsync ) { if ( synchronizer == null ) { LoggingUtil . warning ( "Warning: was not synchronized." ) ; return ; } if ( synchronizer != oldsync ) { LoggingUtil . warning ( "Warning: was synchronized differently!" ) ; return ; } // LoggingUtil.warning("Unsyn... | Remove an update synchronizer | 106 | 5 |
157,673 | protected static double estimateInitialBeta ( double [ ] dist_i , double perplexity ) { double sum = 0. ; for ( double d : dist_i ) { double d2 = d * d ; sum += d2 < Double . POSITIVE_INFINITY ? d2 : 0. ; } return sum > 0 && sum < Double . POSITIVE_INFINITY ? .5 / sum * perplexity * ( dist_i . length - 1. ) : 1. ; } | Estimate beta from the distances in a row . | 105 | 10 |
157,674 | public static List < Relation < ? > > getRelations ( Result r ) { if ( r instanceof Relation < ? > ) { List < Relation < ? > > anns = new ArrayList <> ( 1 ) ; anns . add ( ( Relation < ? > ) r ) ; return anns ; } if ( r instanceof HierarchicalResult ) { return filterResults ( ( ( HierarchicalResult ) r ) . getHierarchy... | Collect all Annotation results from a Result | 119 | 8 |
157,675 | public static List < OrderingResult > getOrderingResults ( Result r ) { if ( r instanceof OrderingResult ) { List < OrderingResult > ors = new ArrayList <> ( 1 ) ; ors . add ( ( OrderingResult ) r ) ; return ors ; } if ( r instanceof HierarchicalResult ) { return filterResults ( ( ( HierarchicalResult ) r ) . getHierar... | Collect all ordering results from a Result | 114 | 7 |
157,676 | 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 ( ( ( Hi... | Collect all collection results from a Result | 120 | 7 |
157,677 | 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 ( ( ( Hierarchical... | Return all Iterable results | 126 | 5 |
157,678 | 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 | 86 | 8 |
157,679 | public static void addChildResult ( HierarchicalResult parent , Result child ) { parent . getHierarchy ( ) . add ( parent , child ) ; } | Add a child result . | 34 | 5 |
157,680 | 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 . | 61 | 9 |
157,681 | 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 . | 104 | 10 |
157,682 | 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 . | 282 | 15 |
157,683 | 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 ; } } // Standardize: final double s = 1. / FastMath . sqrt ( l2 ) ; for ( int d = 0 ;... | Choose a random vector of unit norm for power iterations . | 127 | 11 |
157,684 | 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 ; // Reduce flipping vectors double diff = 0. ; for ( int d = 0 ; d < in . length ; d ++ ) { in [ d ] *= s ; // Scale to unit length // Compute change f... | Compute the change in the eigenvector and normalize the output vector while doing so . | 150 | 19 |
157,685 | 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 . | 104 | 13 |
157,686 | 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 | 200 | 5 |
157,687 | 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 { // Gumbel case: return FastMath . exp ( -... | CDF of GEV distribution | 119 | 6 |
157,688 | 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 | 173 | 7 |
157,689 | 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 | 58 | 6 |
157,690 | 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 | 100 | 7 |
157,691 | public OutlierResult run ( Database db , Relation < V > relation ) { ArrayDBIDs ids = DBIDUtil . ensureArray ( relation . getDBIDs ( ) ) ; // Build a kernel matrix, to make O(n^3) slightly less bad. SimilarityQuery < V > sq = db . getSimilarityQuery ( relation , kernelFunction ) ; KernelMatrix kernelMatrix = new Kernel... | Run ABOD on the data set . | 370 | 8 |
157,692 | protected double computeABOF ( KernelMatrix kernelMatrix , DBIDRef pA , DBIDArrayIter pB , DBIDArrayIter pC , MeanVariance s ) { s . reset ( ) ; // Reused double simAA = kernelMatrix . getSimilarity ( pA , pA ) ; for ( pB . seek ( 0 ) ; pB . valid ( ) ; pB . advance ( ) ) { if ( DBIDUtil . equal ( pB , pA ) ) { continu... | Compute the exact ABOF value . | 466 | 9 |
157,693 | 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 . | 434 | 10 |
157,694 | public Clustering < ? > run ( final Database database , final Relation < DiscreteUncertainObject > relation ) { if ( relation . size ( ) <= 0 ) { return new Clustering <> ( "Uk-Means Clustering" , "ukmeans-clustering" ) ; } // Choose initial means randomly DBIDs sampleids = DBIDUtil . randomSample ( relation . getDBIDs... | Run the clustering . | 651 | 5 |
157,695 | 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 . | 115 | 5 |
157,696 | 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 | 112 | 10 |
157,697 | 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 . | 58 | 7 |
157,698 | 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 . | 110 | 9 |
157,699 | 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 ( ) ; // skip comments if ( line . startsWith ( C... | Read the current file | 215 | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.