Skip to content

Commit

Permalink
Deactivate smile demos and unit tests
Browse files Browse the repository at this point in the history
* The current version of smile 4.0.0 is not in sync with the latest developments of the library
  • Loading branch information
stefanhahmann committed Dec 17, 2024
1 parent 3c97be5 commit 0be6d3f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public class UmapSmileDemo
{
/*
public static void main( final String[] args )
{
int numCluster1 = 50;
Expand All @@ -19,12 +20,14 @@ public static void main( final String[] args )
double[][] result = Arrays.stream( umapResult ).map( row -> Arrays.stream( row ).toArray() ).toArray( double[][]::new );
PlotPoints.plot( sampleData, result, resultValues -> resultValues[ 0 ] > 1 );
}

static double[][] setUpUmap( final double[][] sampleData )
{
int iterations = sampleData.length < 10_000 ? 500 : 200; // https://github.com/lmcinnes/umap/blob/a012b9d8751d98b94935ca21f278a54b3c3e1b7f/umap/umap_.py#L1073
double minDist = 0.1;
int nNeighbors = 15;
return UMAP.of( sampleData, MathEx::distance, nNeighbors, 2, iterations, 1, minDist, 1.0, 5, 1 );
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UmapSmileDemoIris

private static final Logger logger = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

/*
public static void main( String[] args ) throws IOException, CsvValidationException
{
File file = new File( "src/test/resources/org/mastodon/mamut/feature/dimensionalityreduction/iris.tsv" );
Expand All @@ -47,18 +48,20 @@ public static void main( String[] args ) throws IOException, CsvValidationExcept
long t0 = System.currentTimeMillis();
double[][] result = setUpUmap( inputData );
logger.info( "UMAP took {} ms", System.currentTimeMillis() - t0 );

result = Arrays.stream( result ).map( row -> Arrays.stream( row ).map( value -> value * 10d ).toArray() ) // scale up
.toArray( double[][]::new );
PlotPoints.plot( null, result, null );
}
}

static double[][] setUpUmap( double[][] data )
{
int iterations = data.length < 10_000 ? 500 : 200; // https://github.com/lmcinnes/umap/blob/a012b9d8751d98b94935ca21f278a54b3c3e1b7f/umap/umap_.py#L1073
double minDist = 0.1;
int nNeighbors = 15;
return UMAP.of( data, MathEx::distance, nNeighbors, 2, iterations, 1, minDist, 1.0, 5, 1 );
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class UmapSmileDemoTgmmMini

private static final Logger logger = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

/*
public static void main( String[] args ) throws IOException, CsvValidationException
{
File file = new File( "src/test/resources/org/mastodon/mamut/feature/dimensionalityreduction/tgmm-mini-spot.csv" );
Expand All @@ -47,18 +48,20 @@ public static void main( String[] args ) throws IOException, CsvValidationExcept
long t0 = System.currentTimeMillis();
double[][] result = setUpUmap( inputData );
logger.info( "UMAP took {} ms", System.currentTimeMillis() - t0 );

double[][] resultScaled = Arrays.stream( result ).map( row -> Arrays.stream( row ).map( value -> value * 10d ).toArray() )
.toArray( double[][]::new );
PlotPoints.plot( null, resultScaled, null );
}
}

static double[][] setUpUmap( double[][] data )
{
int iterations = data.length < 10_000 ? 500 : 200; // https://github.com/lmcinnes/umap/blob/a012b9d8751d98b94935ca21f278a54b3c3e1b7f/umap/umap_.py#L1073
double minDist = 0.1;
int nNeighbors = 15;
return UMAP.of( data, MathEx::distance, nNeighbors, 2, iterations, 1, minDist, 1.0, 5, 1 );
}
*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,31 @@ class UmapSmileTest
{
private static final Logger logger = LoggerFactory.getLogger( MethodHandles.lookup().lookupClass() );

/*
@Test
void test()
{
int numCluster1 = 50;
int numCluster2 = 100;
// create two distinct clusters of points in 3D space, one having 50 points and the other 100 points
double[][] sampleData = RandomDataTools.generateSampleData( numCluster1, numCluster2 );

// Recommendations for UMAP defaults: https://github.com/lmcinnes/umap/blob/a012b9d8751d98b94935ca21f278a54b3c3e1b7f/umap/umap_.py#L1073
int iterations = sampleData.length < 10_000 ? 500 : 200;
double minDist = 0.1;
int nNeighbors = 15;
long t0 = System.currentTimeMillis();
double[][] umapResult = UMAP.of( sampleData, MathEx::distance, nNeighbors, 2, iterations, 1, minDist, 1.0, 5, 1 );
logger.info( "UMAP took {} ms", System.currentTimeMillis() - t0 );

assertEquals( 2, umapResult[ 0 ].length );
assertEquals( umapResult.length, sampleData.length ); // fails, because only the largest connected component is used inside the algorithm

double[][] umapResult1 = Arrays.copyOfRange( umapResult, 0, numCluster1 );
double[][] umapResult2 = Arrays.copyOfRange( umapResult, numCluster1, numCluster1 + numCluster2 );

DimensionalityReductionTestUtils.testNonOverlappingClusters( umapResult1, umapResult2 ); // should pass
}
*/
}

0 comments on commit 0be6d3f

Please sign in to comment.