idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
157,800
public Element renderCheckBox ( SVGPlot svgp , double x , double y , double size ) { final Element checkmark = SVGEffects . makeCheckmark ( svgp ) ; checkmark . setAttribute ( SVGConstants . SVG_TRANSFORM_ATTRIBUTE , "scale(" + ( size / 12 ) + ") translate(" + x + " " + y + ")" ) ; if ( ! checked ) { checkmark . setAtt...
Render the SVG checkbox to a plot
157,801
protected void fireSwitchEvent ( ChangeEvent evt ) { Object [ ] listeners = listenerList . getListenerList ( ) ; for ( int i = 1 ; i < listeners . length ; i += 2 ) { if ( listeners [ i - 1 ] == ChangeListener . class ) { ( ( ChangeListener ) listeners [ i ] ) . stateChanged ( evt ) ; } } }
Fire the event to listeners
157,802
protected static void calculateSelectivityCoeffs ( List < DoubleObjPair < DAFile > > daFiles , NumberVector query , double epsilon ) { final int dimensions = query . getDimensionality ( ) ; double [ ] lowerVals = new double [ dimensions ] ; double [ ] upperVals = new double [ dimensions ] ; VectorApproximation queryApp...
Calculate selectivity coefficients .
157,803
protected static VectorApproximation calculatePartialApproximation ( DBID id , NumberVector dv , List < DoubleObjPair < DAFile > > daFiles ) { int [ ] approximation = new int [ dv . getDimensionality ( ) ] ; for ( int i = 0 ; i < daFiles . size ( ) ; i ++ ) { double val = dv . doubleValue ( i ) ; double [ ] borders = d...
Calculate partial vector approximation .
157,804
public String solutionToString ( int fractionDigits ) { if ( ! isSolvable ( ) ) { throw new IllegalStateException ( "System is not solvable!" ) ; } DecimalFormat nf = new DecimalFormat ( ) ; nf . setMinimumFractionDigits ( fractionDigits ) ; nf . setMaximumFractionDigits ( fractionDigits ) ; nf . setDecimalFormatSymbol...
Returns a string representation of the solution of this equation system .
157,805
private void reducedRowEchelonForm ( int method ) { final int rows = coeff . length ; final int cols = coeff [ 0 ] . length ; int k = - 1 ; int pivotRow ; int pivotCol ; double pivot ; boolean exitLoop = false ; while ( ! exitLoop ) { k ++ ; IntIntPair pivotPos = new IntIntPair ( 0 , 0 ) ; IntIntPair currPos = new IntI...
Brings this linear equation system into reduced row echelon form with choice of pivot method .
157,806
private IntIntPair nonZeroPivotSearch ( int k ) { int i , j ; double absValue ; for ( i = k ; i < coeff . length ; i ++ ) { for ( j = k ; j < coeff [ 0 ] . length ; j ++ ) { absValue = Math . abs ( coeff [ row [ i ] ] [ col [ j ] ] ) ; if ( absValue > 0 ) { return new IntIntPair ( i , j ) ; } } } return new IntIntPair ...
Method for trivial pivot search searches for non - zero entry .
157,807
private void permutePivot ( IntIntPair pos1 , IntIntPair pos2 ) { int r1 = pos1 . first ; int c1 = pos1 . second ; int r2 = pos2 . first ; int c2 = pos2 . second ; int index ; index = row [ r2 ] ; row [ r2 ] = row [ r1 ] ; row [ r1 ] = index ; index = col [ c2 ] ; col [ c2 ] = col [ c1 ] ; col [ c1 ] = index ; }
permutes two matrix rows and two matrix columns
157,808
private void pivotOperation ( int k ) { double pivot = coeff [ row [ k ] ] [ col [ k ] ] ; coeff [ row [ k ] ] [ col [ k ] ] = 1 ; for ( int i = k + 1 ; i < coeff [ k ] . length ; i ++ ) { coeff [ row [ k ] ] [ col [ i ] ] /= pivot ; } rhs [ row [ k ] ] /= pivot ; if ( LOG . isDebugging ( ) ) { StringBuilder msg = new ...
performs a pivot operation
157,809
private void solve ( int method ) throws NullPointerException { if ( solved ) { return ; } if ( ! reducedRowEchelonForm ) { reducedRowEchelonForm ( method ) ; } if ( ! isSolvable ( method ) ) { if ( LOG . isDebugging ( ) ) { LOG . debugFine ( "Equation system is not solvable!" ) ; } return ; } final int cols = coeff [ ...
solves linear system with the chosen method
157,810
private boolean isSolvable ( int method ) throws NullPointerException { if ( solved ) { return solvable ; } if ( ! reducedRowEchelonForm ) { reducedRowEchelonForm ( method ) ; } for ( int i = rank ; i < rhs . length ; i ++ ) { if ( Math . abs ( rhs [ row [ i ] ] ) > DELTA ) { solvable = false ; return false ; } } solva...
Checks solvability of this linear equation system with the chosen method .
157,811
private int [ ] maxIntegerDigits ( double [ ] [ ] values ) { int [ ] digits = new int [ values [ 0 ] . length ] ; for ( int j = 0 ; j < values [ 0 ] . length ; j ++ ) { for ( double [ ] value : values ) { digits [ j ] = Math . max ( digits [ j ] , integerDigits ( value [ j ] ) ) ; } } return digits ; }
Returns the maximum integer digits in each column of the specified values .
157,812
private int maxIntegerDigits ( double [ ] values ) { int digits = 0 ; for ( double value : values ) { digits = Math . max ( digits , integerDigits ( value ) ) ; } return digits ; }
Returns the maximum integer digits of the specified values .
157,813
private int integerDigits ( double d ) { double value = Math . abs ( d ) ; if ( value < 10 ) { return 1 ; } return ( int ) FastMath . log10 ( value ) + 1 ; }
Returns the integer digits of the specified double value .
157,814
private void format ( NumberFormat nf , StringBuilder buffer , double value , int maxIntegerDigits ) { if ( value >= 0 ) { buffer . append ( " + " ) ; } else { buffer . append ( " - " ) ; } int digits = maxIntegerDigits - integerDigits ( value ) ; for ( int d = 0 ; d < digits ; d ++ ) { buffer . append ( ' ' ) ; } buff...
Helper method for output of equations and solution . Appends the specified double value to the given string buffer according the number format and the maximum number of integer digits .
157,815
protected ArrayModifiableDBIDs initialMedoids ( DistanceQuery < V > distQ , DBIDs ids ) { if ( getLogger ( ) . isStatistics ( ) ) { getLogger ( ) . statistics ( new StringStatistic ( getClass ( ) . getName ( ) + ".initialization" , initializer . toString ( ) ) ) ; } Duration initd = getLogger ( ) . newDuration ( getCla...
Choose the initial medoids .
157,816
public int getTotalClusterCount ( ) { int clusterCount = 0 ; for ( int i = 0 ; i < numclusters . length ; i ++ ) { clusterCount += numclusters [ i ] ; } return clusterCount ; }
Return the sum of all clusters
157,817
public int getHighestClusterCount ( ) { int maxClusters = 0 ; for ( int i = 0 ; i < numclusters . length ; i ++ ) { maxClusters = Math . max ( maxClusters , numclusters [ i ] ) ; } return maxClusters ; }
Returns the highest number of Clusters in the clusterings
157,818
protected static double getMinDist ( DBIDArrayIter j , DistanceQuery < ? > distQ , DBIDArrayIter mi , WritableDoubleDataStore mindist ) { double prev = mindist . doubleValue ( j ) ; if ( Double . isNaN ( prev ) ) { prev = Double . POSITIVE_INFINITY ; for ( mi . seek ( 0 ) ; mi . valid ( ) ; mi . advance ( ) ) { double ...
Get the minimum distance to previous medoids .
157,819
private static void shuffle ( ArrayModifiableDBIDs ids , int ssize , int end , Random random ) { ssize = ssize < end ? ssize : end ; for ( int i = 1 ; i < ssize ; i ++ ) { ids . swap ( i - 1 , i + random . nextInt ( end - i ) ) ; } }
Partial Fisher - Yates shuffle .
157,820
public static LinearScale [ ] calcScales ( Relation < ? extends SpatialComparable > rel ) { int dim = RelationUtil . dimensionality ( rel ) ; DoubleMinMax [ ] minmax = DoubleMinMax . newArray ( dim ) ; LinearScale [ ] scales = new LinearScale [ dim ] ; for ( DBIDIter iditer = rel . iterDBIDs ( ) ; iditer . valid ( ) ; ...
Compute a linear scale for each dimension .
157,821
public FrequentItemsetsResult run ( Database db , final Relation < BitVector > relation ) { final int dim = RelationUtil . dimensionality ( relation ) ; final VectorFieldTypeInformation < BitVector > meta = RelationUtil . assumeVectorField ( relation ) ; final int minsupp = getMinimumSupport ( relation . size ( ) ) ; L...
Run the Eclat algorithm
157,822
public static TreeNode build ( List < Class < ? > > choices , String rootpkg ) { MutableTreeNode root = new PackageNode ( rootpkg , rootpkg ) ; HashMap < String , MutableTreeNode > lookup = new HashMap < > ( ) ; if ( rootpkg != null ) { lookup . put ( rootpkg , root ) ; } lookup . put ( "de.lmu.ifi.dbs.elki" , root ) ;...
Build the class tree for a given set of choices .
157,823
private static MutableTreeNode simplifyTree ( MutableTreeNode cur , String prefix ) { if ( cur instanceof PackageNode ) { PackageNode node = ( PackageNode ) cur ; if ( node . getChildCount ( ) == 1 ) { String newprefix = ( prefix != null ) ? prefix + "." + ( String ) node . getUserObject ( ) : ( String ) node . getUser...
Simplify the tree .
157,824
protected String formatValue ( List < Class < ? extends C > > val ) { StringBuilder buf = new StringBuilder ( 50 + val . size ( ) * 25 ) ; String pkgname = restrictionClass . getPackage ( ) . getName ( ) ; for ( Class < ? extends C > c : val ) { if ( buf . length ( ) > 0 ) { buf . append ( LIST_SEP ) ; } String name = ...
Format as string .
157,825
protected void publish ( final LogRecord record ) { if ( record instanceof ProgressLogRecord ) { ProgressLogRecord preg = ( ProgressLogRecord ) record ; Progress prog = preg . getProgress ( ) ; JProgressBar pbar = getOrCreateProgressBar ( prog ) ; updateProgressBar ( prog , pbar ) ; if ( prog . isComplete ( ) ) { remov...
Publish a logging record .
157,826
private void publishTextRecord ( final LogRecord record ) { try { logpane . publish ( record ) ; } catch ( Exception e ) { throw new RuntimeException ( "Error writing a log-like message." , e ) ; } }
Publish a text record to the pane
157,827
private JProgressBar getOrCreateProgressBar ( Progress prog ) { JProgressBar pbar = pbarmap . get ( prog ) ; if ( pbar == null ) { synchronized ( pbarmap ) { if ( prog instanceof FiniteProgress ) { pbar = new JProgressBar ( 0 , ( ( FiniteProgress ) prog ) . getTotal ( ) ) ; pbar . setStringPainted ( true ) ; } else if ...
Get an existing or create a new progress bar .
157,828
private void updateProgressBar ( Progress prog , JProgressBar pbar ) { if ( prog instanceof FiniteProgress ) { pbar . setValue ( ( ( FiniteProgress ) prog ) . getProcessed ( ) ) ; pbar . setString ( ( ( FiniteProgress ) prog ) . toString ( ) ) ; } else if ( prog instanceof IndefiniteProgress ) { pbar . setValue ( ( ( I...
Update a progress bar
157,829
private void removeProgressBar ( Progress prog , JProgressBar pbar ) { synchronized ( pbarmap ) { pbarmap . remove ( prog ) ; SwingUtilities . invokeLater ( ( ) -> removeProgressBar ( pbar ) ) ; } }
Remove a progress bar
157,830
public void clear ( ) { logpane . clear ( ) ; synchronized ( pbarmap ) { for ( Entry < Progress , JProgressBar > ent : pbarmap . entrySet ( ) ) { super . remove ( ent . getValue ( ) ) ; pbarmap . remove ( ent . getKey ( ) ) ; } } }
Clear the current contents .
157,831
public void componentResized ( ComponentEvent e ) { if ( e . getComponent ( ) == component ) { double newRatio = getCurrentRatio ( ) ; if ( Math . abs ( newRatio - activeRatio ) > threshold ) { activeRatio = newRatio ; executeResize ( newRatio ) ; } } }
React to a component resize event .
157,832
public String format ( LogRecord record ) { String msg = record . getMessage ( ) ; if ( msg . length ( ) > 0 ) { if ( record instanceof ProgressLogRecord ) { return msg ; } if ( msg . endsWith ( OutputStreamLogger . NEWLINE ) ) { return msg ; } } return msg + OutputStreamLogger . NEWLINE ; }
Retrieves the message as it is set in the given LogRecord .
157,833
protected double [ ] alignLabels ( List < ClassLabel > l1 , double [ ] d1 , Collection < ClassLabel > l2 ) { assert ( l1 . size ( ) == d1 . length ) ; if ( l1 == l2 ) { return d1 . clone ( ) ; } double [ ] d2 = new double [ l2 . size ( ) ] ; Iterator < ClassLabel > i2 = l2 . iterator ( ) ; for ( int i = 0 ; i2 . hasNex...
Align the labels for a label query .
157,834
public void setInitialClusters ( List < ? extends Cluster < ? extends MeanModel > > initialMeans ) { double [ ] [ ] vecs = new double [ initialMeans . size ( ) ] [ ] ; for ( int i = 0 ; i < vecs . length ; i ++ ) { vecs [ i ] = initialMeans . get ( i ) . getModel ( ) . getMean ( ) ; } this . initialMeans = vecs ; }
Set the initial means .
157,835
public static void exception ( String message , Throwable e ) { if ( message == null && e != null ) { message = e . getMessage ( ) ; } logExpensive ( Level . SEVERE , message , e ) ; }
Static version to log a severe exception .
157,836
public static void warning ( String message , Throwable e ) { if ( message == null && e != null ) { message = e . getMessage ( ) ; } logExpensive ( Level . WARNING , message , e ) ; }
Static version to log a warning message .
157,837
public static void message ( String message , Throwable e ) { if ( message == null && e != null ) { message = e . getMessage ( ) ; } logExpensive ( Level . INFO , message , e ) ; }
Static version to log a info message .
157,838
private static final String [ ] inferCaller ( ) { StackTraceElement [ ] stack = ( new Throwable ( ) ) . getStackTrace ( ) ; int ix = 0 ; while ( ix < stack . length ) { StackTraceElement frame = stack [ ix ] ; if ( ! frame . getClassName ( ) . equals ( LoggingUtil . class . getCanonicalName ( ) ) ) { return new String ...
Infer which class has called the logging helper .
157,839
public static long binomialCoefficient ( long n , long k ) { final long m = Math . max ( k , n - k ) ; double temp = 1 ; for ( long i = n , j = 1 ; i > m ; i -- , j ++ ) { temp = temp * i / j ; } return ( long ) temp ; }
Binomial coefficient also known as n choose k .
157,840
public static double approximateBinomialCoefficient ( int n , int k ) { final int m = max ( k , n - k ) ; long temp = 1 ; for ( int i = n , j = 1 ; i > m ; i -- , j ++ ) { temp = temp * i / j ; } return temp ; }
Binomial coefficent also known as n choose k ) .
157,841
public static int [ ] sequence ( int start , int end ) { if ( start >= end ) { return EMPTY_INTS ; } int [ ] ret = new int [ end - start ] ; for ( int j = 0 ; start < end ; start ++ , j ++ ) { ret [ j ] = start ; } return ret ; }
Generate an array of integers .
157,842
public KNNDistanceOrderResult run ( Database database , Relation < O > relation ) { final DistanceQuery < O > distanceQuery = database . getDistanceQuery ( relation , getDistanceFunction ( ) ) ; final KNNQuery < O > knnQuery = database . getKNNQuery ( distanceQuery , k + 1 ) ; final int size = ( int ) ( ( sample <= 1. ...
Provides an order of the kNN - distances for all objects within the specified database .
157,843
public DataStore < M > preprocess ( Class < ? super M > modelcls , Relation < O > relation , RangeQuery < O > query ) { WritableDataStore < M > storage = DataStoreUtil . makeStorage ( relation . getDBIDs ( ) , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP , modelcls ) ; Duration time = getLogger ( ) . newD...
Perform the preprocessing step .
157,844
public < NV extends NumberVector > NV projectScaledToDataSpace ( double [ ] v , NumberVector . Factory < NV > factory ) { final int dim = v . length ; double [ ] vec = new double [ dim ] ; for ( int d = 0 ; d < dim ; d ++ ) { vec [ d ] = scales [ d ] . getUnscaled ( v [ d ] ) ; } return factory . newNumberVector ( vec ...
Project a vector from scaled space to data space .
157,845
public < NV extends NumberVector > NV projectRenderToDataSpace ( double [ ] v , NumberVector . Factory < NV > prototype ) { final int dim = v . length ; double [ ] vec = projectRenderToScaled ( v ) ; for ( int d = 0 ; d < dim ; d ++ ) { vec [ d ] = scales [ d ] . getUnscaled ( vec [ d ] ) ; } return prototype . newNumb...
Project a vector from rendering space to data space .
157,846
public < NV extends NumberVector > NV projectRelativeScaledToDataSpace ( double [ ] v , NumberVector . Factory < NV > prototype ) { final int dim = v . length ; double [ ] vec = new double [ dim ] ; for ( int d = 0 ; d < dim ; d ++ ) { vec [ d ] = scales [ d ] . getRelativeUnscaled ( v [ d ] ) ; } return prototype . ne...
Project a relative vector from scaled space to data space .
157,847
public PointerHierarchyRepresentationResult complete ( ) { if ( csize != null ) { csize . destroy ( ) ; csize = null ; } if ( mergecount != ids . size ( ) - 1 ) { LOG . warning ( mergecount + " merges were added to the hierarchy, expected " + ( ids . size ( ) - 1 ) ) ; } if ( prototypes != null ) { return new PointerPr...
Finalize the result .
157,848
public int getSize ( DBIDRef id ) { if ( csize == null ) { csize = DataStoreUtil . makeIntegerStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP , 1 ) ; } return csize . intValue ( id ) ; }
Get the cluster size of the current object .
157,849
public void setSize ( DBIDRef id , int size ) { if ( csize == null ) { csize = DataStoreUtil . makeIntegerStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP , 1 ) ; } csize . putInt ( id , size ) ; }
Set the cluster size of an object .
157,850
public OutlierResult run ( Database database , Relation < N > spatial , Relation < O > relation ) { final NeighborSetPredicate npred = getNeighborSetPredicateFactory ( ) . instantiate ( database , spatial ) ; DistanceQuery < O > distFunc = getNonSpatialDistanceFunction ( ) . instantiate ( relation ) ; WritableDoubleDat...
The main run method
157,851
public void insertHandler ( Class < ? > restrictionClass , H handler ) { handlers . add ( new Pair < Class < ? > , H > ( restrictionClass , handler ) ) ; }
Insert a handler to the beginning of the stack .
157,852
public H getHandler ( Object o ) { if ( o == null ) { return null ; } ListIterator < Pair < Class < ? > , H > > iter = handlers . listIterator ( handlers . size ( ) ) ; while ( iter . hasPrevious ( ) ) { Pair < Class < ? > , H > pair = iter . previous ( ) ; try { pair . getFirst ( ) . cast ( o ) ; return pair . getSeco...
Find a matching handler for the given object
157,853
public synchronized static Logging getLogger ( final String name ) { Logging logger = loggers . get ( name ) ; if ( logger == null ) { logger = new Logging ( Logger . getLogger ( name ) ) ; loggers . put ( name , logger ) ; } return logger ; }
Retrieve logging utility for a particular class .
157,854
public void log ( java . util . logging . Level level , CharSequence message ) { LogRecord rec = new ELKILogRecord ( level , message ) ; logger . log ( rec ) ; }
Log a log message at the given level .
157,855
public void error ( CharSequence message , Throwable e ) { log ( Level . SEVERE , message , e ) ; }
Log a message at the severe level .
157,856
public void warning ( CharSequence message , Throwable e ) { log ( Level . WARNING , message , e ) ; }
Log a message at the warning level .
157,857
public void statistics ( CharSequence message , Throwable e ) { log ( Level . STATISTICS , message , e ) ; }
Log a message at the STATISTICS level .
157,858
public void veryverbose ( CharSequence message , Throwable e ) { log ( Level . VERYVERBOSE , message , e ) ; }
Log a message at the veryverbose level .
157,859
public void exception ( CharSequence message , Throwable e ) { log ( Level . SEVERE , message , e ) ; }
Log a message with exception at the severe level .
157,860
public void exception ( Throwable e ) { final String msg = e . getMessage ( ) ; log ( Level . SEVERE , msg != null ? msg : "An exception occurred." , e ) ; }
Log an exception at the severe level .
157,861
public void statistics ( Statistic stats ) { if ( stats != null ) { log ( Level . STATISTICS , stats . getKey ( ) + ": " + stats . formatValue ( ) ) ; } }
Log a statistics object .
157,862
public MultipleObjectsBundle generate ( ) { if ( generators . isEmpty ( ) ) { throw new AbortException ( "No clusters specified." ) ; } final int dim = generators . get ( 0 ) . getDim ( ) ; for ( GeneratorInterface c : generators ) { if ( c . getDim ( ) != dim ) { throw new AbortException ( "Cluster dimensions do not a...
Main loop to generate data set .
157,863
private void initLabelsAndModels ( ArrayList < GeneratorInterface > generators , ClassLabel [ ] labels , Model [ ] models , Pattern reassign ) { int existingclusters = 0 ; if ( reassign != null ) { for ( int i = 0 ; i < labels . length ; i ++ ) { final GeneratorInterface curclus = generators . get ( i ) ; if ( ! reassi...
Initialize cluster labels and models .
157,864
public static < V extends FeatureVector < ? > > VectorFieldTypeInformation < V > assumeVectorField ( Relation < V > relation ) { try { return ( ( VectorFieldTypeInformation < V > ) relation . getDataTypeInformation ( ) ) ; } catch ( Exception e ) { throw new UnsupportedOperationException ( "Expected a vector field, got...
Get the vector field type information from a relation .
157,865
public static < V extends NumberVector > NumberVector . Factory < V > getNumberVectorFactory ( Relation < V > relation ) { final VectorFieldTypeInformation < V > type = assumeVectorField ( relation ) ; @ SuppressWarnings ( "unchecked" ) final NumberVector . Factory < V > factory = ( NumberVector . Factory < V > ) type ...
Get the number vector factory of a database relation .
157,866
public static int dimensionality ( Relation < ? extends SpatialComparable > relation ) { final SimpleTypeInformation < ? extends SpatialComparable > type = relation . getDataTypeInformation ( ) ; if ( type instanceof FieldTypeInformation ) { return ( ( FieldTypeInformation ) type ) . getDimensionality ( ) ; } return - ...
Get the dimensionality of a database relation .
157,867
public static double [ ] [ ] computeMinMax ( Relation < ? extends NumberVector > relation ) { int dim = RelationUtil . dimensionality ( relation ) ; double [ ] mins = new double [ dim ] , maxs = new double [ dim ] ; for ( int i = 0 ; i < dim ; i ++ ) { mins [ i ] = Double . MAX_VALUE ; maxs [ i ] = - Double . MAX_VALUE...
Determines the minimum and maximum values in each dimension of all objects stored in the given database .
157,868
public static < V extends SpatialComparable > String getColumnLabel ( Relation < ? extends V > rel , int col ) { SimpleTypeInformation < ? extends V > type = rel . getDataTypeInformation ( ) ; if ( ! ( type instanceof VectorFieldTypeInformation ) ) { return "Column " + col ; } final VectorFieldTypeInformation < ? > vty...
Get the column name or produce a generic label Column XY .
157,869
@ SuppressWarnings ( "unchecked" ) public static < V extends NumberVector , T extends NumberVector > Relation < V > relationUglyVectorCast ( Relation < T > database ) { return ( Relation < V > ) database ; }
An ugly vector type cast unavoidable in some situations due to Generics .
157,870
public KNNList get ( DBIDRef id ) { if ( storage == null ) { if ( getLogger ( ) . isDebugging ( ) ) { getLogger ( ) . debug ( "Running kNN preprocessor: " + this . getClass ( ) ) ; } preprocess ( ) ; } return storage . get ( id ) ; }
Get the k nearest neighbors .
157,871
public Clustering < DimensionModel > run ( Database database , Relation < V > relation ) { COPACNeighborPredicate . Instance npred = new COPACNeighborPredicate < V > ( settings ) . instantiate ( database , relation ) ; CorePredicate . Instance < DBIDs > cpred = new MinPtsCorePredicate ( settings . minpts ) . instantiat...
Run the COPAC algorithm .
157,872
public int getUnpairedClusteringIndex ( ) { for ( int index = 0 ; index < clusterIds . length ; index ++ ) { if ( clusterIds [ index ] == UNCLUSTERED ) { return index ; } } return - 1 ; }
Returns the index of the first clustering having an unpaired cluster or - 1 no unpaired cluster exists .
157,873
protected static boolean isNull ( Object val ) { return ( val == null ) || STRING_NULL . equals ( val ) || DOUBLE_NULL . equals ( val ) || INTEGER_NULL . equals ( val ) ; }
Test a value for null .
157,874
private static String formatCause ( Throwable cause ) { if ( cause == null ) { return "" ; } String message = cause . getMessage ( ) ; return "\n" + ( message != null ? message : cause . toString ( ) ) ; }
Format the error cause .
157,875
public TextWriterWriterInterface < ? > getWriterFor ( Object o ) { if ( o == null ) { return null ; } TextWriterWriterInterface < ? > writer = writers . getHandler ( o ) ; if ( writer != null ) { return writer ; } try { final Class < ? > decl = o . getClass ( ) . getMethod ( "toString" ) . getDeclaringClass ( ) ; if ( ...
Retrieve an appropriate writer from the handler list .
157,876
protected Cluster < BiclusterModel > defineBicluster ( BitSet rows , BitSet cols ) { ArrayDBIDs rowIDs = rowsBitsetToIDs ( rows ) ; int [ ] colIDs = colsBitsetToIDs ( cols ) ; return new Cluster < > ( rowIDs , new BiclusterModel ( colIDs ) ) ; }
Defines a Bicluster as given by the included rows and columns .
157,877
public double getSampleSkewness ( ) { if ( ! ( m2 > 0 ) || ! ( n > 2 ) ) { throw new ArithmeticException ( "Skewness not defined when variance is 0 or weight <= 2.0!" ) ; } return ( m3 * n / ( n - 1 ) / ( n - 2 ) ) / FastMath . pow ( getSampleVariance ( ) , 1.5 ) ; }
Get the skewness using sample variance .
157,878
public static double cosineOrHaversineDeg ( double lat1 , double lon1 , double lat2 , double lon2 ) { return cosineOrHaversineRad ( deg2rad ( lat1 ) , deg2rad ( lon1 ) , deg2rad ( lat2 ) , deg2rad ( lon2 ) ) ; }
Use cosine or haversine dynamically .
157,879
public static double crossTrackDistanceRad ( double lat1 , double lon1 , double lat2 , double lon2 , double latQ , double lonQ , double dist1Q ) { final double dlon12 = lon2 - lon1 ; final double dlon1Q = lonQ - lon1 ; final DoubleWrapper tmp = new DoubleWrapper ( ) ; final double slat1 = sinAndCos ( lat1 , tmp ) , cla...
Compute the cross - track distance .
157,880
public static double alongTrackDistanceRad ( double lat1 , double lon1 , double lat2 , double lon2 , double latQ , double lonQ , double dist1Q , double ctd ) { int sign = Math . abs ( bearingRad ( lat1 , lon1 , lat2 , lon2 ) - bearingRad ( lat1 , lon1 , latQ , lonQ ) ) < HALFPI ? + 1 : - 1 ; return sign * acos ( cos ( ...
The along track distance is the distance from S to Q along the track S to E .
157,881
private static double [ ] reversed ( double [ ] a ) { Arrays . sort ( a ) ; for ( int i = 0 , j = a . length - 1 ; i < j ; i ++ , j -- ) { double tmp = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = tmp ; } return a ; }
Sort an array of doubles in descending order .
157,882
private double computeExplainedVariance ( double [ ] eigenValues , int filteredEigenPairs ) { double strongsum = 0. , weaksum = 0. ; for ( int i = 0 ; i < filteredEigenPairs ; i ++ ) { strongsum += eigenValues [ i ] ; } for ( int i = filteredEigenPairs ; i < eigenValues . length ; i ++ ) { weaksum += eigenValues [ i ] ...
Compute the explained variance for a filtered EigenPairs .
157,883
private void assertSortedByDistance ( DoubleDBIDList results ) { double dist = - 1.0 ; boolean sorted = true ; for ( DoubleDBIDListIter it = results . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { double qr = it . doubleValue ( ) ; if ( qr < dist ) { sorted = false ; } dist = qr ; } if ( ! sorted ) { try { Modifiabl...
Ensure that the results are sorted by distance .
157,884
public static String prefixParameterToMessage ( Parameter < ? > p , String message ) { return new StringBuilder ( 100 + message . length ( ) ) . append ( p instanceof Flag ? "Flag '" : "Parameter '" ) . append ( p . getOptionID ( ) . getName ( ) ) . append ( "' " ) . append ( message ) . toString ( ) ; }
Prefix parameter information to error message .
157,885
public static String prefixParametersToMessage ( Parameter < ? > p , String mid , Parameter < ? > p2 , String message ) { return new StringBuilder ( 200 + mid . length ( ) + message . length ( ) ) . append ( p instanceof Flag ? "Flag '" : "Parameter '" ) . append ( p . getOptionID ( ) . getName ( ) ) . append ( "' " ) ...
Prefix parameters to error message .
157,886
protected int computeHeight ( ) { N node = getRoot ( ) ; int height = 1 ; while ( ! node . isLeaf ( ) && node . getNumEntries ( ) != 0 ) { E entry = node . getEntry ( 0 ) ; node = getNode ( entry ) ; height ++ ; } return height ; }
Computes the height of this RTree . Is called by the constructor . and should be overwritten by subclasses if necessary .
157,887
private List < E > createBulkDirectoryNodes ( List < E > nodes ) { int minEntries = dirMinimum ; int maxEntries = dirCapacity - 1 ; ArrayList < E > result = new ArrayList < > ( ) ; List < List < E > > partitions = settings . bulkSplitter . partition ( nodes , minEntries , maxEntries ) ; for ( List < E > partition : par...
Creates and returns the directory nodes for bulk load .
157,888
private N createRoot ( N root , List < E > objects ) { for ( E entry : objects ) { if ( entry instanceof LeafEntry ) { root . addLeafEntry ( entry ) ; } else { root . addDirectoryEntry ( entry ) ; } } ( ( SpatialDirectoryEntry ) getRootEntry ( ) ) . setMBR ( root . computeMBR ( ) ) ; writeNode ( root ) ; if ( getLogger...
Returns a root node for bulk load . If the objects are data objects a leaf node will be returned if the objects are nodes a directory node will be returned .
157,889
private int tailingNonNewline ( char [ ] cbuf , int off , int len ) { for ( int cnt = 0 ; cnt < len ; cnt ++ ) { final int pos = off + ( len - 1 ) - cnt ; if ( cbuf [ pos ] == UNIX_NEWLINE ) { return cnt ; } if ( cbuf [ pos ] == CARRIAGE_RETURN ) { return cnt ; } } return len ; }
Count the tailing non - newline characters .
157,890
public void write ( char [ ] cbuf , int off , int len ) throws IOException { if ( len <= 0 ) { return ; } if ( charsSinceNewline > 0 ) { if ( cbuf [ off ] != CARRIAGE_RETURN ) { super . write ( NEWLINEC , 0 , NEWLINEC . length ) ; charsSinceNewline = 0 ; } else { int nonnl = countNonNewline ( cbuf , off + 1 , len - 1 )...
Writer that keeps track of when it hasn t seen a newline yet will auto - insert newlines except when lines start with a carriage return .
157,891
protected DoubleDataStore computeIDs ( DBIDs ids , KNNQuery < O > knnQ ) { WritableDoubleDataStore intDims = DataStoreUtil . makeDoubleStorage ( ids , DataStoreFactory . HINT_HOT | DataStoreFactory . HINT_TEMP ) ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Intrinsic dimensionality" , ids . size (...
Computes all IDs
157,892
protected DoubleDataStore computeIDOS ( DBIDs ids , KNNQuery < O > knnQ , DoubleDataStore intDims , DoubleMinMax idosminmax ) { WritableDoubleDataStore ldms = DataStoreUtil . makeDoubleStorage ( ids , DataStoreFactory . HINT_STATIC ) ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "ID Outlier Scores ...
Computes all IDOS scores .
157,893
public OutlierResult run ( Database database , Relation < V > relation ) { final int dbsize = relation . size ( ) ; ArrayList < ArrayList < DBIDs > > ranges = buildRanges ( relation ) ; Heap < Individuum > . UnorderedIter individuums = ( new EvolutionarySearch ( relation , ranges , m , rnd . getSingleThreadedRandom ( )...
Performs the evolutionary algorithm on the given database .
157,894
protected double [ ] [ ] buildDistanceMatrix ( ArrayDBIDs ids , DistanceQuery < ? > dq ) { final int size = ids . size ( ) ; double [ ] [ ] dmat = new double [ size ] [ size ] ; final boolean square = ! dq . getDistanceFunction ( ) . isSquared ( ) ; FiniteProgress prog = LOG . isVerbose ( ) ? new FiniteProgress ( "Comp...
Build a distance matrix of squared distances .
157,895
public Clustering < M > run ( Database database , Relation < V > relation ) { MutableProgress prog = LOG . isVerbose ( ) ? new MutableProgress ( "X-means number of clusters" , k_max , LOG ) : null ; innerKMeans . setK ( k_min ) ; LOG . statistics ( new StringStatistic ( KEY + ".initialization" , initializer . toString ...
Run the algorithm on a database and relation .
157,896
protected List < Cluster < M > > splitCluster ( Cluster < M > parentCluster , Database database , Relation < V > relation ) { ArrayList < Cluster < M > > parentClusterList = new ArrayList < Cluster < M > > ( 1 ) ; parentClusterList . add ( parentCluster ) ; if ( parentCluster . size ( ) <= 1 ) { return parentClusterLis...
Conditionally splits the clusters based on the information criterion .
157,897
protected double [ ] [ ] splitCentroid ( Cluster < ? extends MeanModel > parentCluster , Relation < V > relation ) { double [ ] parentCentroid = parentCluster . getModel ( ) . getMean ( ) ; double radius = 0. ; for ( DBIDIter it = parentCluster . getIDs ( ) . iter ( ) ; it . valid ( ) ; it . advance ( ) ) { double d = ...
Split an existing centroid into two initial centers .
157,898
private void scan ( HilbertFeatures hf , int k0 ) { final int mink0 = Math . min ( 2 * k0 , capital_n - 1 ) ; if ( LOG . isDebuggingFine ( ) ) { LOG . debugFine ( "Scanning with k0=" + k0 + " (" + mink0 + ")" + " N*=" + capital_n_star ) ; } for ( int i = 0 ; i < hf . pf . length ; i ++ ) { if ( hf . pf [ i ] . ubound <...
Scan function performs a squential scan over the data .
157,899
private void trueOutliers ( HilbertFeatures h ) { n_star = 0 ; for ( ObjectHeap . UnsortedIter < HilFeature > iter = h . out . unsortedIter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { HilFeature entry = iter . get ( ) ; if ( entry . ubound >= omega_star && ( entry . ubound - entry . lbound < 1E-10 ) ) { n_star ++ ;...
trueOutliers function updates n_star