Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TDA Lab: Interactive Topological Data Analysis for Android

TDA Lab is a mobile-first platform for exploring the "shape" of data through Topological Data Analysis (TDA). By combining modern Android development with high-performance Kotlin data science libraries, it enables researchers, students, and data scientists to compute and visualize persistent homology directly on their devices.


🔬 Understanding the Science: A Simple Guide

Topological Data Analysis (TDA) is based on a powerful premise: Data has a shape, and that shape has meaning. Instead of just looking at individual coordinates, TDA looks at how data points are organized across different scales.

1. What is "Connectedness"? ($H_0$)

In topology, we measure connectedness using the 0th Homology Group ($H_0$).

  • The Island Analogy: Imagine every data point is an individual island in the ocean. Initially, with no bridges, every point is isolated.
  • The Process: As we increase our "connection radius" (the filtration scale $\epsilon$), we start building bridges between islands that are close to each other. When two islands are joined by a bridge, they merge into a single "connected component."
  • The Goal: We track how many separate "islands" exist at any given time. If $\beta_0 = 1$, it means every point in your dataset can reach every other point—the data is fully connected.

2. The Building Blocks: Simplices

To understand how data forms a shape, we use Simplices—the "lego bricks" of topology.

  • 0-Simplex (Point): This is just a single vertex. In our app, these are the red dots in your scatter plot.
  • 1-Simplex (Edge): A line connecting two points. In TDA, an edge forms when the distance between two points is small enough (controlled by your $\epsilon$ slider).
  • 2-Simplex (Triangle): A solid triangular face. This forms when three points are all within $\epsilon$ distance of each other, creating a "filled" surface.
  • Simplicial Complex: By "gluing" these points, edges, and triangles together, we create a mathematical skeleton of the data. TDA analyzes how this skeleton grows and changes.

3. What are Homology Groups? ($H_n$)

Homology groups are mathematical "detectors" that identify different types of holes in a shape:

  • $H_0$ (Connectedness): Detects 0-dimensional gaps (the spaces between components).
  • $H_1$ (Loops): Detects 1-dimensional holes (like the hole in a circle, a doughnut, or a straw).
  • $H_2$ (Voids): Detects 2-dimensional "bubbles" (like the empty space inside a soccer ball or a balloon).

4. What are Betti Numbers? ($\beta_n$)

While Homology Groups describe the type of structure, Betti Numbers are the count of those structures:

  • $\beta_0$: The number of independent clusters or connected components.
  • $\beta_1$: The number of circular loops or "tunnels."
  • $\beta_2$: The number of enclosed voids or "air pockets."

Real-world Example: A coffee mug and a doughnut are "topologically equivalent" because they both have $\beta_0 = 1$ (one solid piece) and $\beta_1 = 1$ (one handle/hole).


🌟 Feature Showcase

1. Interactive Vietoris-Rips Filtration

The heart of the app. This feature allows you to "grow" balls around every data point. When the balls of two points overlap, an edge forms. This creates a Simplicial Complex.

  • Real-time Feedback: Use the slider to watch edges snap into place instantly.
  • Scale Exploration: Discover how structures appearing at a small scale might disappear or merge at a larger scale.

2. Persistent Homology & Persistence Barcodes

Not all topological features are important; some are just "noise."

  • The Barcode: Every topological feature (a component or a loop) is assigned a "bar" on a graph. The bar starts when the feature is born and ends when it dies (fills in).
  • Persistence: Long bars represent "persistent" features that likely represent the true underlying shape of the data. Short bars represent "topological noise."

3. Automated Mathematical Notation

The app automatically translates complex computations into standard mathematical language:

  • Displays isomorphisms like $H_1 \cong \mathbb{Z} \oplus \mathbb{Z}$ for a dataset with two distinct loops.
  • Live-updating Betti numbers $(\beta_0, \beta_1)$ as you move the slider.

4. Transparency & Logic Engine

A dedicated screen that pulls back the curtain on the math. It breaks down:

  • Distance Matrices: How we convert $(x,y)$ points into a web of distances.
  • Boundary Matrices ($\partial_n$): The "DNA" of the shape that tells us how vertices make edges, and edges make triangles.
  • Ripser Algorithm: How the app efficiently reduces these massive matrices to find the "holes."

🧪 Data Science & Mathematics Engine

TDA Lab leverages a sophisticated stack of Kotlin-native data science libraries:

  • Kotlin Dataframe: Robust, type-safe ingestion of CSV datasets. It handles complex data schema parsing and ensures coordinates are valid.
  • Multik: Kotlin's multidimensional array library. We use Multik for high-performance distance matrix manipulation, providing a "NumPy-like" experience on Android.
  • Apache Commons Math: Provides the numerical foundations for Euclidean distance calculations and complex mathematical functions.
  • Kotlin Statistics: Advanced statistical utilities for point cloud preprocessing and normalization.
  • KMath: Abstract mathematical interfaces supporting potential future extensions into higher-dimensional homology.

🧠 Algorithm Deep Dive

Connected Components ($H_0$)

We utilize a Union-Find (Disjoint Set Union) algorithm with path compression. This allows the app to determine near-instantaneously when two clusters merge as $\epsilon$ grows.

One-Dimensional Homology ($H_1$)

To detect loops, the engine analyzes the edge formation sequence. $H_1$ features are identified when an edge connects two points already in the same component, creating a cycle. We then apply a heuristic to estimate when that cycle is "filled" by higher-dimensional shapes (triangles).


🏗 Architecture & Data Flow

graph TD
    A[CSV File] -->|Kotlin Dataframe| B(Point Cloud)
    B -->|Apache Commons Math| C(Distance Matrix)
    C -->|Multik| D{TDA Engine}
    D -->|Union-Find| E(H0 Persistence)
    D -->|Cycle Detection| F(H1 Persistence)
    E & F --> G(Persistence Diagram)
    G --> H[Jetpack Compose UI]
    H -->|User Input ε| I(Simplicial Complex Plot)
    H -->|User Input ε| J(Betti Number Calculation)
Loading

🛠 Tech Stack

  • UI: Jetpack Compose (Material 3) with custom Canvas rendering.
  • Concurrency: Kotlin Coroutines for non-blocking topological processing on Dispatchers.Default.
  • State Management: Reactive UI updates using Compose state patterns.
  • Packaging: Optimized resource handling to manage scientific metadata.

📖 Getting Started

  1. Prepare Data: Create a CSV file with two columns representing $(x, y)$ coordinates.
  2. Analyze: Tap "Analyze Data" and select your file from your Android storage.
  3. Filtration: Slide the $\epsilon$ slider to grow connections.
  4. Interpret: Look for long bars in the Persistence Barcode to find the "true" shape of your data.

📂 Project Structure

  • com.example.tdaproject.math: Core TDA algorithms and mathematical logic.
  • com.example.tdaproject.ui.plots: Custom visualization components for high-performance rendering.
  • com.example.tdaproject.model: Immutable data models for topological features.
  • com.example.tdaproject.ui: Material 3 screen implementations.

🔮 Roadmap

  • Support for $H_2$: Visualization of 2D voids in 3D point clouds.
  • Ripser Integration: Transition to a full Ripser-based engine for exact $H_n$ computation.
  • Persistence Landscapes: Alternative visualizations for persistent homology.
  • Real-time Camera TDA: Analyze point clouds captured directly from device sensors.

📜 License

Distributed under the MIT License. See LICENSE for more information.

About

TDA Lab is an Android app for visualizing Topological Data Analysis on 2D point data.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages