idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
157,100 | public static StringBuilder appendSpace ( StringBuilder buf , int spaces ) { for ( int i = spaces ; i > 0 ; i -= SPACEPADDING . length ) { buf . append ( SPACEPADDING , 0 , i < SPACEPADDING . length ? i : SPACEPADDING . length ) ; } return buf ; } | Append whitespace to a buffer . | 75 | 8 |
157,101 | protected void makeLayerElement ( ) { plotwidth = StyleLibrary . SCALE ; plotheight = StyleLibrary . SCALE / optics . getOPTICSPlot ( context ) . getRatio ( ) ; final double margin = context . getStyleLibrary ( ) . getSize ( StyleLibrary . MARGIN ) ; layer = SVGUtil . svgElement ( svgp . getDocument ( ) , SVGConstants ... | Produce a new layer element . | 174 | 7 |
157,102 | protected List < Centroid > computeCentroids ( int dim , List < V > vectorcolumn , List < ClassLabel > keys , Map < ClassLabel , IntList > classes ) { final int numc = keys . size ( ) ; List < Centroid > centroids = new ArrayList <> ( numc ) ; for ( int i = 0 ; i < numc ; i ++ ) { Centroid c = new Centroid ( dim ) ; fo... | Compute the centroid for each class . | 162 | 9 |
157,103 | protected double kNNDistance ( ) { double knnDist = 0. ; for ( int i = 0 ; i < getNumEntries ( ) ; i ++ ) { MkMaxEntry entry = getEntry ( i ) ; knnDist = Math . max ( knnDist , entry . getKnnDistance ( ) ) ; } return knnDist ; } | Determines and returns the k - nearest neighbor distance of this node as the maximum of the k - nearest neighbor distances of all entries . | 76 | 28 |
157,104 | @ Override public boolean adjustEntry ( MkMaxEntry entry , DBID routingObjectID , double parentDistance , AbstractMTree < O , MkMaxTreeNode < O > , MkMaxEntry , ? > mTree ) { super . adjustEntry ( entry , routingObjectID , parentDistance , mTree ) ; // adjust knn distance entry . setKnnDistance ( kNNDistance ( ) ) ; re... | Calls the super method and adjust additionally the k - nearest neighbor distance of this node as the maximum of the k - nearest neighbor distances of all its entries . | 93 | 32 |
157,105 | @ Override protected void integrityCheckParameters ( MkMaxEntry parentEntry , MkMaxTreeNode < O > parent , int index , AbstractMTree < O , MkMaxTreeNode < O > , MkMaxEntry , ? > mTree ) { super . integrityCheckParameters ( parentEntry , parent , index , mTree ) ; // test if knn distance is correctly set MkMaxEntry entr... | Calls the super method and tests if the k - nearest neighbor distance of this node is correctly set . | 195 | 21 |
157,106 | @ Override public void initialize ( ) { if ( databaseConnection == null ) { return ; // Supposedly we initialized already. } if ( LOG . isDebugging ( ) ) { LOG . debugFine ( "Loading data from database connection." ) ; } MultipleObjectsBundle bundle = databaseConnection . loadData ( ) ; // Run at most once. databaseCon... | Initialize the database by getting the initial data from the database connection . | 693 | 14 |
157,107 | protected void zSort ( List < ? extends SpatialComparable > objs , int start , int end , double [ ] mms , int [ ] dims , int depth ) { final int numdim = ( dims != null ) ? dims . length : ( mms . length >> 1 ) ; final int edim = ( dims != null ) ? dims [ depth ] : depth ; // Find the splitting points. final double min... | The actual Z sorting function | 428 | 5 |
157,108 | public StringBuilder appendTo ( StringBuilder buf ) { return buf . append ( DBIDUtil . toString ( ( DBIDRef ) id ) ) . append ( " " ) . append ( column ) . append ( " " ) . append ( score ) ; } | Append to a text buffer . | 56 | 7 |
157,109 | protected Cluster < SubspaceModel > runDOC ( Database database , Relation < V > relation , ArrayModifiableDBIDs S , final int d , int n , int m , int r , int minClusterSize ) { // Best cluster for the current run. DBIDs C = null ; // Relevant attributes for the best cluster. long [ ] D = null ; // Quality of the best c... | Performs a single run of DOC finding a single cluster . | 690 | 12 |
157,110 | protected DBIDs findNeighbors ( DBIDRef q , long [ ] nD , ArrayModifiableDBIDs S , Relation < V > relation ) { // Weights for distance (= rectangle query) DistanceQuery < V > dq = relation . getDistanceQuery ( new SubspaceMaximumDistanceFunction ( nD ) ) ; // TODO: add filtering capabilities into query API! // Until th... | Find the neighbors of point q in the given subspace | 194 | 11 |
157,111 | protected Cluster < SubspaceModel > makeCluster ( Relation < V > relation , DBIDs C , long [ ] D ) { DBIDs ids = DBIDUtil . newHashSet ( C ) ; // copy, also to lose distance values! Cluster < SubspaceModel > cluster = new Cluster <> ( ids ) ; cluster . setModel ( new SubspaceModel ( new Subspace ( D ) , Centroid . make... | Utility method to create a subspace cluster from a list of DBIDs and the relevant attributes . | 111 | 20 |
157,112 | protected static < M extends Model > int [ ] findDepth ( Clustering < M > c ) { final Hierarchy < Cluster < M > > hier = c . getClusterHierarchy ( ) ; int [ ] size = { 0 , 0 } ; for ( It < Cluster < M > > iter = c . iterToplevelClusters ( ) ; iter . valid ( ) ; iter . advance ( ) ) { findDepth ( hier , iter . get ( ) ,... | Compute the size of the clustering . | 109 | 9 |
157,113 | private static < M extends Model > void findDepth ( Hierarchy < Cluster < M > > hier , Cluster < M > cluster , int [ ] size ) { if ( hier . numChildren ( cluster ) > 0 ) { for ( It < Cluster < M > > iter = hier . iterChildren ( cluster ) ; iter . valid ( ) ; iter . advance ( ) ) { findDepth ( hier , iter . get ( ) , si... | Recursive depth computation . | 116 | 5 |
157,114 | protected static int getPreferredColumns ( double width , double height , int numc , double maxwidth ) { // Maximum width (compared to height) of labels - guess. // FIXME: do we really need to do this three-step computation? // Number of rows we'd use in a squared layout: final double rows = Math . ceil ( FastMath . po... | Compute the preferred number of columns . | 133 | 8 |
157,115 | public ELKIBuilder < T > with ( String opt , Object value ) { p . addParameter ( opt , value ) ; return this ; } | Add an option to the builder . | 32 | 7 |
157,116 | @ SuppressWarnings ( "unchecked" ) public < C extends T > C build ( ) { if ( p == null ) { throw new AbortException ( "build() may be called only once." ) ; } final T obj = ClassGenericsUtil . parameterizeOrAbort ( clazz , p ) ; if ( p . hasUnusedParameters ( ) ) { LOG . warning ( "Unused parameters: " + p . getRemaini... | Instantiate consuming the parameter list . | 124 | 7 |
157,117 | protected static double [ ] [ ] randomInitialSolution ( final int size , final int dim , Random random ) { double [ ] [ ] sol = new double [ size ] [ dim ] ; for ( int i = 0 ; i < size ; i ++ ) { for ( int j = 0 ; j < dim ; j ++ ) { sol [ i ] [ j ] = random . nextGaussian ( ) * INITIAL_SOLUTION_SCALE ; } } return sol ;... | Generate a random initial solution . | 102 | 7 |
157,118 | protected double sqDist ( double [ ] v1 , double [ ] v2 ) { assert ( v1 . length == v2 . length ) : "Lengths do not agree: " + v1 . length + " " + v2 . length ; double sum = 0 ; for ( int i = 0 ; i < v1 . length ; i ++ ) { final double diff = v1 [ i ] - v2 [ i ] ; sum += diff * diff ; } ++ projectedDistances ; return s... | Squared distance in projection space . | 108 | 7 |
157,119 | protected void updateSolution ( double [ ] [ ] sol , double [ ] meta , int it ) { final double mom = ( it < momentumSwitch && initialMomentum < finalMomentum ) ? initialMomentum : finalMomentum ; final int dim3 = dim * 3 ; for ( int i = 0 , off = 0 ; i < sol . length ; i ++ , off += dim3 ) { final double [ ] sol_i = so... | Update the current solution on iteration . | 270 | 7 |
157,120 | private int getOffset ( int x , int y ) { return ( y < x ) ? ( triangleSize ( x ) + y ) : ( triangleSize ( y ) + x ) ; } | Array offset computation . | 40 | 4 |
157,121 | @ Override public double getWeight ( double distance , double max , double stddev ) { if ( stddev <= 0 ) { return 1 ; } double scaleddistance = distance / ( scaling * stddev ) ; // After this, the result would be negative. if ( scaleddistance >= 1.0 ) { return 0.0 ; } return 1.0 - scaleddistance * scaleddistance ; } | Evaluate weight function at given parameters . max is ignored . | 85 | 13 |
157,122 | public OPTICSPlot getOPTICSPlot ( VisualizerContext context ) { if ( plot == null ) { plot = OPTICSPlot . plotForClusterOrder ( clusterOrder , context ) ; } return plot ; } | Get or produce the actual OPTICS plot . | 46 | 9 |
157,123 | public void setValue ( boolean val ) { try { super . setValue ( Boolean . valueOf ( val ) ) ; } catch ( ParameterException e ) { // We're pretty sure that any Boolean is okay, so this should never be // reached. throw new AbortException ( "Flag did not accept boolean value!" , e ) ; } } | Convenience function using a native boolean that doesn t require error handling . | 73 | 15 |
157,124 | public OutlierResult run ( Database database , Relation < O > relation ) { StepProgress stepprog = LOG . isVerbose ( ) ? new StepProgress ( 5 ) : null ; Pair < KNNQuery < O > , KNNQuery < O > > pair = getKNNQueries ( database , relation , stepprog ) ; KNNQuery < O > knnComp = pair . getFirst ( ) ; KNNQuery < O > knnRea... | Performs the LoOP algorithm on the given database . | 692 | 11 |
157,125 | protected void computePDists ( Relation < O > relation , KNNQuery < O > knn , WritableDoubleDataStore pdists ) { // computing PRDs FiniteProgress prdsProgress = LOG . isVerbose ( ) ? new FiniteProgress ( "pdists" , relation . size ( ) , LOG ) : null ; for ( DBIDIter iditer = relation . iterDBIDs ( ) ; iditer . valid ( ... | Compute the probabilistic distances used by LoOP . | 295 | 12 |
157,126 | protected double computePLOFs ( Relation < O > relation , KNNQuery < O > knn , WritableDoubleDataStore pdists , WritableDoubleDataStore plofs ) { FiniteProgress progressPLOFs = LOG . isVerbose ( ) ? new FiniteProgress ( "PLOFs for objects" , relation . size ( ) , LOG ) : null ; double nplof = 0. ; for ( DBIDIter iditer... | Compute the LOF values using the pdist distances . | 436 | 12 |
157,127 | @ SuppressWarnings ( "unchecked" ) public final void writeObject ( TextWriterStream out , String label , Object object ) throws IOException { write ( out , label , ( O ) object ) ; } | Non - type - checking version . | 46 | 7 |
157,128 | @ Override public int filter ( double [ ] eigenValues ) { // determine sum of eigenvalues double totalSum = 0 ; for ( int i = 0 ; i < eigenValues . length ; i ++ ) { totalSum += eigenValues [ i ] ; } double expectedVariance = totalSum / eigenValues . length * walpha ; // determine strong and weak eigenpairs double curr... | Filter eigenpairs . | 244 | 6 |
157,129 | public static List < OutlierResult > getOutlierResults ( Result r ) { if ( r instanceof OutlierResult ) { List < OutlierResult > ors = new ArrayList <> ( 1 ) ; ors . add ( ( OutlierResult ) r ) ; return ors ; } if ( r instanceof HierarchicalResult ) { return ResultUtil . filterResults ( ( ( HierarchicalResult ) r ) . g... | Collect all outlier results from a Result | 118 | 8 |
157,130 | double evaluateBy ( ScoreEvaluation eval ) { return eval . evaluate ( new DBIDsTest ( DBIDUtil . ensureSet ( scores . getDBIDs ( ) ) ) , new OutlierScoreAdapter ( this ) ) ; } | Evaluate given a set of positives and a scoring . | 50 | 12 |
157,131 | public double distance ( double [ ] v1 , double [ ] v2 ) { final int dim1 = v1 . length , dim2 = v2 . length ; final int mindim = dim1 < dim2 ? dim1 : dim2 ; double agg = preDistance ( v1 , v2 , 0 , mindim ) ; if ( dim1 > mindim ) { agg += preNorm ( v1 , mindim , dim1 ) ; } else if ( dim2 > mindim ) { agg += preNorm ( ... | Special version for double arrays . | 125 | 6 |
157,132 | private void computeWeights ( Node node ) { int wsum = 0 ; for ( Node child : node . children ) { computeWeights ( child ) ; wsum += child . weight ; } node . weight = Math . max ( 1 , wsum ) ; } | Recursively assign node weights . | 56 | 7 |
157,133 | @ Override public void processNewResult ( ResultHierarchy hier , Result result ) { // Get all new clusterings // TODO: handle clusterings added later, too. Can we update the result? List < Clustering < ? > > clusterings = Clustering . getClusteringResults ( result ) ; // Abort if not enough clusterings to compare if ( ... | Perform clusterings evaluation | 118 | 5 |
157,134 | public double getPartialMinDist ( int dimension , int vp ) { final int qp = queryApprox . getApproximation ( dimension ) ; if ( vp < qp ) { return lookup [ dimension ] [ vp + 1 ] ; } else if ( vp > qp ) { return lookup [ dimension ] [ vp ] ; } else { return 0.0 ; } } | Get the minimum distance contribution of a single dimension . | 85 | 10 |
157,135 | public double getMinDist ( VectorApproximation vec ) { final int dim = lookup . length ; double minDist = 0 ; for ( int d = 0 ; d < dim ; d ++ ) { final int vp = vec . getApproximation ( d ) ; minDist += getPartialMinDist ( d , vp ) ; } return FastMath . pow ( minDist , onebyp ) ; } | Get the minimum distance to approximated vector vec . | 88 | 10 |
157,136 | public double getPartialMaxDist ( int dimension , int vp ) { final int qp = queryApprox . getApproximation ( dimension ) ; if ( vp < qp ) { return lookup [ dimension ] [ vp ] ; } else if ( vp > qp ) { return lookup [ dimension ] [ vp + 1 ] ; } else { return Math . max ( lookup [ dimension ] [ vp ] , lookup [ dimension ... | Get the maximum distance contribution of a single dimension . | 106 | 10 |
157,137 | private void initializeLookupTable ( double [ ] [ ] splitPositions , NumberVector query , double p ) { final int dimensions = splitPositions . length ; final int bordercount = splitPositions [ 0 ] . length ; lookup = new double [ dimensions ] [ bordercount ] ; for ( int d = 0 ; d < dimensions ; d ++ ) { final double va... | Initialize the lookup table . | 140 | 6 |
157,138 | protected void makeStyleResult ( StyleLibrary stylelib ) { final Database db = ResultUtil . findDatabase ( hier ) ; stylelibrary = stylelib ; List < Clustering < ? extends Model > > clusterings = Clustering . getClusteringResults ( db ) ; if ( ! clusterings . isEmpty ( ) ) { stylepolicy = new ClusterStylingPolicy ( clu... | Generate a new style result for the given style library . | 128 | 12 |
157,139 | @ Override public void contentChanged ( DataStoreEvent e ) { for ( int i = 0 ; i < listenerList . size ( ) ; i ++ ) { listenerList . get ( i ) . contentChanged ( e ) ; } } | Proxy datastore event to child listeners . | 50 | 9 |
157,140 | private void notifyFactories ( Object item ) { for ( VisualizationProcessor f : factories ) { try { f . processNewResult ( this , item ) ; } catch ( Throwable e ) { LOG . warning ( "VisFactory " + f . getClass ( ) . getCanonicalName ( ) + " failed:" , e ) ; } } } | Notify factories of a change . | 76 | 7 |
157,141 | protected int chooseBulkSplitPoint ( int numEntries , int minEntries , int maxEntries ) { if ( numEntries < minEntries ) { throw new IllegalArgumentException ( "numEntries < minEntries!" ) ; } if ( numEntries <= maxEntries ) { return numEntries ; } else if ( numEntries < maxEntries + minEntries ) { return ( numEntries ... | Computes and returns the best split point . | 108 | 9 |
157,142 | protected < T > List < List < T > > trivialPartition ( List < T > objects , int minEntries , int maxEntries ) { // build partitions final int size = objects . size ( ) ; final int numberPartitions = ( int ) Math . ceil ( ( ( double ) size ) / maxEntries ) ; List < List < T > > partitions = new ArrayList <> ( numberPart... | Perform the trivial partitioning of the given list . | 202 | 11 |
157,143 | protected Relation < ? > [ ] alignColumns ( ObjectBundle pack ) { // align representations. Relation < ? > [ ] targets = new Relation < ? > [ pack . metaLength ( ) ] ; long [ ] used = BitsUtil . zero ( relations . size ( ) ) ; for ( int i = 0 ; i < targets . length ; i ++ ) { SimpleTypeInformation < ? > meta = pack . m... | Find a mapping from package columns to database columns eventually adding new database columns when needed . | 270 | 17 |
157,144 | private Relation < ? > addNewRelation ( SimpleTypeInformation < ? > meta ) { @ SuppressWarnings ( "unchecked" ) SimpleTypeInformation < Object > ometa = ( SimpleTypeInformation < Object > ) meta ; Relation < ? > relation = new MaterializedRelation <> ( ometa , ids ) ; relations . add ( relation ) ; getHierarchy ( ) . a... | Add a new representation for the given meta . | 237 | 9 |
157,145 | private void doDelete ( DBIDRef id ) { // Remove id ids . remove ( id ) ; // Remove from all representations. for ( Relation < ? > relation : relations ) { // ID has already been removed, and this would loop... if ( relation == idrep ) { continue ; } if ( ! ( relation instanceof ModifiableRelation ) ) { throw new Abort... | Removes the object with the specified id from this database . | 137 | 12 |
157,146 | private ArrayDBIDs greedy ( DistanceQuery < V > distFunc , DBIDs sampleSet , int m , Random random ) { ArrayModifiableDBIDs medoids = DBIDUtil . newArray ( m ) ; ArrayModifiableDBIDs s = DBIDUtil . newArray ( sampleSet ) ; DBIDArrayIter iter = s . iter ( ) ; DBIDVar m_i = DBIDUtil . newVar ( ) ; int size = s . size ( )... | Returns a piercing set of k medoids from the specified sample set . | 568 | 14 |
157,147 | private ArrayDBIDs initialSet ( DBIDs sampleSet , int k , Random random ) { return DBIDUtil . ensureArray ( DBIDUtil . randomSample ( sampleSet , k , random ) ) ; } | Returns a set of k elements from the specified sample set . | 46 | 12 |
157,148 | private ArrayDBIDs computeM_current ( DBIDs m , DBIDs m_best , DBIDs m_bad , Random random ) { ArrayModifiableDBIDs m_list = DBIDUtil . newArray ( m ) ; m_list . removeDBIDs ( m_best ) ; DBIDArrayMIter it = m_list . iter ( ) ; ArrayModifiableDBIDs m_current = DBIDUtil . newArray ( ) ; for ( DBIDIter iter = m_best . ite... | Computes the set of medoids in current iteration . | 215 | 11 |
157,149 | private long [ ] [ ] findDimensions ( ArrayDBIDs medoids , Relation < V > database , DistanceQuery < V > distFunc , RangeQuery < V > rangeQuery ) { // get localities DataStore < DBIDs > localities = getLocalities ( medoids , distFunc , rangeQuery ) ; // compute x_ij = avg distance from points in l_i to medoid m_i final... | Determines the set of correlated dimensions for each medoid in the specified medoid set . | 382 | 19 |
157,150 | private List < Pair < double [ ] , long [ ] > > findDimensions ( ArrayList < PROCLUSCluster > clusters , Relation < V > database ) { // compute x_ij = avg distance from points in c_i to c_i.centroid final int dim = RelationUtil . dimensionality ( database ) ; final int numc = clusters . size ( ) ; double [ ] [ ] averag... | Refinement step that determines the set of correlated dimensions for each cluster centroid . | 433 | 16 |
157,151 | private List < DoubleIntInt > computeZijs ( double [ ] [ ] averageDistances , final int dim ) { List < DoubleIntInt > z_ijs = new ArrayList <> ( averageDistances . length * dim ) ; for ( int i = 0 ; i < averageDistances . length ; i ++ ) { double [ ] x_i = averageDistances [ i ] ; // y_i double y_i = 0 ; for ( int j = ... | Compute the z_ij values . | 281 | 8 |
157,152 | private long [ ] [ ] computeDimensionMap ( List < DoubleIntInt > z_ijs , final int dim , final int numc ) { // mapping cluster index -> dimensions long [ ] [ ] dimensionMap = new long [ numc ] [ ( ( dim - 1 ) >> 6 ) + 1 ] ; int max = Math . max ( k * l , 2 ) ; for ( int m = 0 ; m < max ; m ++ ) { DoubleIntInt z_ij = z_... | Compute the dimension map . | 235 | 6 |
157,153 | private ArrayList < PROCLUSCluster > assignPoints ( ArrayDBIDs m_current , long [ ] [ ] dimensions , Relation < V > database ) { ModifiableDBIDs [ ] clusterIDs = new ModifiableDBIDs [ dimensions . length ] ; for ( int i = 0 ; i < m_current . size ( ) ; i ++ ) { clusterIDs [ i ] = DBIDUtil . newHashSet ( ) ; } DBIDArray... | Assigns the objects to the clusters . | 463 | 9 |
157,154 | private List < PROCLUSCluster > finalAssignment ( List < Pair < double [ ] , long [ ] > > dimensions , Relation < V > database ) { Map < Integer , ModifiableDBIDs > clusterIDs = new HashMap <> ( ) ; for ( int i = 0 ; i < dimensions . size ( ) ; i ++ ) { clusterIDs . put ( i , DBIDUtil . newHashSet ( ) ) ; } for ( DBIDI... | Refinement step to assign the objects to the final clusters . | 446 | 12 |
157,155 | private double manhattanSegmentalDistance ( NumberVector o1 , double [ ] o2 , long [ ] dimensions ) { double result = 0 ; int card = 0 ; for ( int d = BitsUtil . nextSetBit ( dimensions , 0 ) ; d >= 0 ; d = BitsUtil . nextSetBit ( dimensions , d + 1 ) ) { result += Math . abs ( o1 . doubleValue ( d ) - o2 [ d ] ) ; ++ ... | Returns the Manhattan segmental distance between o1 and o2 relative to the specified dimensions . | 107 | 18 |
157,156 | private double evaluateClusters ( ArrayList < PROCLUSCluster > clusters , long [ ] [ ] dimensions , Relation < V > database ) { double result = 0 ; for ( int i = 0 ; i < dimensions . length ; i ++ ) { PROCLUSCluster c_i = clusters . get ( i ) ; double [ ] centroid_i = c_i . centroid ; long [ ] dims_i = dimensions [ i ]... | Evaluates the quality of the clusters . | 213 | 9 |
157,157 | private double avgDistance ( double [ ] centroid , DBIDs objectIDs , Relation < V > database , int dimension ) { Mean avg = new Mean ( ) ; for ( DBIDIter iter = objectIDs . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { V o = database . get ( iter ) ; avg . put ( Math . abs ( centroid [ dimension ] - o . doubleVa... | Computes the average distance of the objects to the centroid along the specified dimension . | 107 | 17 |
157,158 | private DBIDs computeBadMedoids ( ArrayDBIDs m_current , ArrayList < PROCLUSCluster > clusters , int threshold ) { ModifiableDBIDs badMedoids = DBIDUtil . newHashSet ( m_current . size ( ) ) ; int i = 0 ; for ( DBIDIter it = m_current . iter ( ) ; it . valid ( ) ; it . advance ( ) , i ++ ) { PROCLUSCluster c_i = cluste... | Computes the bad medoids where the medoid of a cluster with less than the specified threshold of objects is bad . | 147 | 24 |
157,159 | public static Bit valueOf ( String bit ) throws NumberFormatException { final int i = ParseUtil . parseIntBase10 ( bit ) ; if ( i != 0 && i != 1 ) { throw new NumberFormatException ( "Input \"" + bit + "\" must be 0 or 1." ) ; } return ( i > 0 ) ? TRUE : FALSE ; } | Method to construct a Bit for a given String expression . | 78 | 11 |
157,160 | public ChangePoints run ( Relation < DoubleVector > relation ) { if ( ! ( relation . getDBIDs ( ) instanceof ArrayDBIDs ) ) { throw new AbortException ( "This implementation may only be used on static databases, with ArrayDBIDs to provide a clear order." ) ; } return new Instance ( rnd . getSingleThreadedRandom ( ) ) .... | Executes multiple change point detection for given relation | 86 | 9 |
157,161 | public static void cusum ( double [ ] data , double [ ] out , int begin , int end ) { assert ( out . length >= data . length ) ; // Use Kahan summation for better precision! // FIXME: this should be unit tested. double m = 0. , carry = 0. ; for ( int i = begin ; i < end ; i ++ ) { double v = data [ i ] - carry ; // Com... | Compute the incremental sum of an array i . e . the sum of all points up to the given index . | 135 | 23 |
157,162 | public static DoubleIntPair bestChangeInMean ( double [ ] sums , int begin , int end ) { final int len = end - begin , last = end - 1 ; final double suml = begin > 0 ? sums [ begin - 1 ] : 0. ; final double sumr = sums [ last ] ; int bestpos = begin ; double bestscore = Double . NEGATIVE_INFINITY ; // Iterate elements ... | Find the best position to assume a change in mean . | 299 | 11 |
157,163 | public static void shuffle ( double [ ] bstrap , int len , Random rnd ) { int i = len ; while ( i > 0 ) { final int r = rnd . nextInt ( i ) ; -- i ; // Swap double tmp = bstrap [ r ] ; bstrap [ r ] = bstrap [ i ] ; bstrap [ i ] = tmp ; } } | Fisher - Yates shuffle of a partial array | 80 | 9 |
157,164 | @ SuppressWarnings ( "unchecked" ) public T get ( double coord ) { if ( coord == Double . NEGATIVE_INFINITY ) { return getSpecial ( 0 ) ; } if ( coord == Double . POSITIVE_INFINITY ) { return getSpecial ( 1 ) ; } if ( Double . isNaN ( coord ) ) { return getSpecial ( 2 ) ; } int bin = getBinNr ( coord ) ; if ( bin < 0 )... | Access the value of a bin with new data . | 441 | 10 |
157,165 | protected void loadCache ( int size , InputStream in ) throws IOException { // Expect a sparse matrix here cache = new Long2FloatOpenHashMap ( size * 20 ) ; cache . defaultReturnValue ( Float . POSITIVE_INFINITY ) ; min = Integer . MAX_VALUE ; max = Integer . MIN_VALUE ; parser . parse ( in , new DistanceCacheWriter ( ... | Fill cache from an input stream . | 254 | 7 |
157,166 | public Element svgElement ( String name , String cssclass ) { Element elem = SVGUtil . svgElement ( document , name ) ; if ( cssclass != null ) { elem . setAttribute ( SVGConstants . SVG_CLASS_ATTRIBUTE , cssclass ) ; } return elem ; } | Create a SVG element in the SVG namespace . Non - static version . | 71 | 14 |
157,167 | public Element svgRect ( double x , double y , double w , double h ) { return SVGUtil . svgRect ( document , x , y , w , h ) ; } | Create a SVG rectangle | 40 | 4 |
157,168 | public Element svgCircle ( double cx , double cy , double r ) { return SVGUtil . svgCircle ( document , cx , cy , r ) ; } | Create a SVG circle | 37 | 4 |
157,169 | public Element svgLine ( double x1 , double y1 , double x2 , double y2 ) { return SVGUtil . svgLine ( document , x1 , y1 , x2 , y2 ) ; } | Create a SVG line element | 48 | 5 |
157,170 | public SVGPoint elementCoordinatesFromEvent ( Element tag , Event evt ) { return SVGUtil . elementCoordinatesFromEvent ( document , tag , evt ) ; } | Convert screen coordinates to element coordinates . | 39 | 8 |
157,171 | public void addCSSClassOrLogError ( CSSClass cls ) { try { cssman . addClass ( cls ) ; } catch ( CSSNamingConflict e ) { LoggingUtil . exception ( e ) ; } } | Convenience method to add a CSS class or log an error . | 51 | 14 |
157,172 | public void updateStyleElement ( ) { // TODO: this should be sufficient - why does Batik occasionally not pick up // the changes unless we actually replace the style element itself? // cssman.updateStyleElement(document, style); Element newstyle = cssman . makeStyleElement ( document ) ; style . getParentNode ( ) . rep... | Update style element - invoke this appropriately after any change to the CSS styles . | 88 | 15 |
157,173 | public void saveAsSVG ( File file ) throws IOException , TransformerFactoryConfigurationError , TransformerException { OutputStream out = new BufferedOutputStream ( new FileOutputStream ( file ) ) ; // TODO embed linked images. javax . xml . transform . Result result = new StreamResult ( out ) ; SVGDocument doc = clone... | Save document into a SVG file . | 150 | 7 |
157,174 | protected void transcode ( File file , Transcoder transcoder ) throws IOException , TranscoderException { // Disable validation, performance is more important here (thumbnails!) transcoder . addTranscodingHint ( XMLAbstractTranscoder . KEY_XML_PARSER_VALIDATING , Boolean . FALSE ) ; SVGDocument doc = cloneDocument ( ) ... | Transcode a document into a file using the given transcoder . | 150 | 13 |
157,175 | protected SVGDocument cloneDocument ( ) { return ( SVGDocument ) new CloneInlineImages ( ) { @ Override public Node cloneNode ( Document doc , Node eold ) { // Skip elements with noexport attribute set if ( eold instanceof Element ) { Element eeold = ( Element ) eold ; String vis = eeold . getAttribute ( NO_EXPORT_ATTR... | Clone the SVGPlot document for transcoding . | 134 | 10 |
157,176 | public void saveAsPDF ( File file ) throws IOException , TranscoderException , ClassNotFoundException { try { Object t = Class . forName ( "org.apache.fop.svg.PDFTranscoder" ) . newInstance ( ) ; transcode ( file , ( Transcoder ) t ) ; } catch ( InstantiationException | IllegalAccessException e ) { throw new ClassNotFo... | Transcode file to PDF . | 110 | 6 |
157,177 | public void saveAsPNG ( File file , int width , int height ) throws IOException , TranscoderException { PNGTranscoder t = new PNGTranscoder ( ) ; t . addTranscodingHint ( PNGTranscoder . KEY_WIDTH , new Float ( width ) ) ; t . addTranscodingHint ( PNGTranscoder . KEY_HEIGHT , new Float ( height ) ) ; transcode ( file ,... | Transcode file to PNG . | 101 | 6 |
157,178 | public void saveAsANY ( File file , int width , int height , float quality ) throws IOException , TranscoderException , TransformerFactoryConfigurationError , TransformerException , ClassNotFoundException { String extension = FileUtil . getFilenameExtension ( file ) ; if ( "svg" . equals ( extension ) ) { saveAsSVG ( f... | Save a file trying to auto - guess the file type . | 226 | 12 |
157,179 | public BufferedImage makeAWTImage ( int width , int height ) throws TranscoderException { ThumbnailTranscoder t = new ThumbnailTranscoder ( ) ; t . addTranscodingHint ( PNGTranscoder . KEY_WIDTH , new Float ( width ) ) ; t . addTranscodingHint ( PNGTranscoder . KEY_HEIGHT , new Float ( height ) ) ; // Don't clone. Assu... | Convert the SVG to a thumbnail image . | 137 | 9 |
157,180 | public void dumpDebugFile ( ) { try { File f = File . createTempFile ( "elki-debug" , ".svg" ) ; f . deleteOnExit ( ) ; this . saveAsSVG ( f ) ; LoggingUtil . warning ( "Saved debug file to: " + f . getAbsolutePath ( ) ) ; } catch ( Throwable err ) { // Ignore. } } | Dump the SVG plot to a debug file . | 89 | 10 |
157,181 | public void putIdElement ( String id , Element obj ) { objWithId . put ( id , new WeakReference <> ( obj ) ) ; } | Add an object id . | 32 | 5 |
157,182 | public Element getIdElement ( String id ) { WeakReference < Element > ref = objWithId . get ( id ) ; return ( ref != null ) ? ref . get ( ) : null ; } | Get an element by its id . | 42 | 7 |
157,183 | protected ScoreResult computeScore ( DBIDs ids , DBIDs outlierIds , OutlierResult or ) throws IllegalStateException { if ( scaling instanceof OutlierScaling ) { OutlierScaling oscaling = ( OutlierScaling ) scaling ; oscaling . prepare ( or ) ; } final ScalingFunction innerScaling ; // If we have useful (finite) min/max... | Evaluate a single outlier score result . | 552 | 10 |
157,184 | @ Override protected Cluster < SubspaceModel > runDOC ( Database database , Relation < V > relation , ArrayModifiableDBIDs S , int d , int n , int m , int r , int minClusterSize ) { // Relevant attributes of highest cardinality. long [ ] D = null ; // The seed point for the best dimensions. DBIDVar dV = DBIDUtil . newV... | Performs a single run of FastDOC finding a single cluster . | 540 | 13 |
157,185 | public static SVGPath drawDelaunay ( Projection2D proj , List < SweepHullDelaunay2D . Triangle > delaunay , List < double [ ] > means ) { final SVGPath path = new SVGPath ( ) ; for ( SweepHullDelaunay2D . Triangle del : delaunay ) { path . moveTo ( proj . fastProjectDataToRenderSpace ( means . get ( del . a ) ) ) ; pat... | Draw the Delaunay triangulation . | 161 | 9 |
157,186 | public static SVGPath drawFakeVoronoi ( Projection2D proj , List < double [ ] > means ) { CanvasSize viewport = proj . estimateViewport ( ) ; final SVGPath path = new SVGPath ( ) ; // Difference final double [ ] dirv = VMath . minus ( means . get ( 1 ) , means . get ( 0 ) ) ; VMath . rotate90Equals ( dirv ) ; double [ ... | Fake Voronoi diagram . For two means only | 307 | 10 |
157,187 | public void select ( Segment segment , boolean addToSelection ) { // abort if segment represents pairs inNone. Would select all segments... if ( segment . isNone ( ) ) { return ; } if ( ! addToSelection ) { deselectAllSegments ( ) ; } // get selected segments if ( segment . isUnpaired ( ) ) { // check if all segments a... | Adds or removes the given segment to the selection . Depending on the clustering and cluster selected and the addToSelection option given the current selection will be modified . This method is called by clicking on a segment and ring and the CTRL - button status . | 240 | 51 |
157,188 | protected void deselectSegment ( Segment segment ) { if ( segment . isUnpaired ( ) ) { ArrayList < Segment > remove = new ArrayList <> ( ) ; // remove all object segments associated with unpaired segment from // selection list for ( Entry < Segment , Segment > entry : indirectSelections . entrySet ( ) ) { if ( entry . ... | Deselect a segment | 224 | 5 |
157,189 | protected void selectSegment ( Segment segment ) { if ( segment . isUnpaired ( ) ) { // remember selected unpaired segment for ( Segment other : segments . getPairedSegments ( segment ) ) { indirectSelections . put ( other , segment ) ; selectSegment ( other ) ; } } else { if ( ! selectedSegments . contains ( segment )... | Select a segment | 126 | 3 |
157,190 | private boolean checkSupertypes ( Class < ? > cls ) { for ( Class < ? > c : knownParameterizables ) { if ( c . isAssignableFrom ( cls ) ) { return true ; } } return false ; } | Check all supertypes of a class . | 53 | 8 |
157,191 | private State checkV3Parameterization ( Class < ? > cls , State state ) throws NoClassDefFoundError { // check for a V3 Parameterizer class for ( Class < ? > inner : cls . getDeclaredClasses ( ) ) { if ( AbstractParameterizer . class . isAssignableFrom ( inner ) ) { try { Class < ? extends AbstractParameterizer > pcls ... | Check for a V3 constructor . | 228 | 7 |
157,192 | private State checkDefaultConstructor ( Class < ? > cls , State state ) throws NoClassDefFoundError { try { cls . getConstructor ( ) ; return State . DEFAULT_INSTANTIABLE ; } catch ( Exception e ) { // do nothing. } return state ; } | Check for a default constructor . | 62 | 6 |
157,193 | public static double logpdf ( double x , double k , double theta , double shift ) { x = ( x - shift ) ; if ( x <= 0. ) { return Double . NEGATIVE_INFINITY ; } final double log1px = FastMath . log1p ( x ) ; return k * FastMath . log ( theta ) - GammaDistribution . logGamma ( k ) - ( theta + 1. ) * log1px + ( k - 1 ) * F... | LogGamma distribution logPDF | 116 | 6 |
157,194 | protected void plotGray ( SVGPlot plot , Element parent , double x , double y , double size ) { Element marker = plot . svgCircle ( x , y , size * .5 ) ; SVGUtil . setStyle ( marker , SVGConstants . CSS_FILL_PROPERTY + ":" + greycolor ) ; parent . appendChild ( marker ) ; } | Plot a replacement marker when an object is to be plotted as disabled usually gray . | 80 | 16 |
157,195 | protected void plotUncolored ( SVGPlot plot , Element parent , double x , double y , double size ) { Element marker = plot . svgCircle ( x , y , size * .5 ) ; SVGUtil . setStyle ( marker , SVGConstants . CSS_FILL_PROPERTY + ":" + dotcolor ) ; parent . appendChild ( marker ) ; } | Plot a replacement marker when no color is set ; usually black | 81 | 12 |
157,196 | public int truePositives ( ) { int tp = 0 ; for ( int i = 0 ; i < confusion . length ; i ++ ) { tp += truePositives ( i ) ; } return tp ; } | The number of correctly classified instances . | 49 | 7 |
157,197 | public int trueNegatives ( int classindex ) { int tn = 0 ; for ( int i = 0 ; i < confusion . length ; i ++ ) { for ( int j = 0 ; j < confusion [ i ] . length ; j ++ ) { if ( i != classindex && j != classindex ) { tn += confusion [ i ] [ j ] ; } } } return tn ; } | The number of true negatives of the specified class . | 86 | 10 |
157,198 | public int falsePositives ( int classindex ) { int fp = 0 ; for ( int i = 0 ; i < confusion [ classindex ] . length ; i ++ ) { if ( i != classindex ) { fp += confusion [ classindex ] [ i ] ; } } return fp ; } | The false positives for the specified class . | 66 | 8 |
157,199 | public int falseNegatives ( int classindex ) { int fn = 0 ; for ( int i = 0 ; i < confusion . length ; i ++ ) { if ( i != classindex ) { fn += confusion [ i ] [ classindex ] ; } } return fn ; } | The false negatives for the specified class . | 58 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.