Spaces:
Configuration error
Configuration error
|
Download README.md from DaneshSelwal/Classification-6Bands-Workspace: direct link, hf CLI and curl.
- Browser
- Download file 17 kB
-
https://huggingface.co/spaces/DaneshSelwal/Classification-6Bands-Workspace/resolve/main/README.md
- Command line
-
hf download hf://spaces/DaneshSelwal/Classification-6Bands-Workspace/README.md
-
curl -L -o README.md https://huggingface.co/spaces/DaneshSelwal/Classification-6Bands-Workspace/resolve/main/README.md
17 kB
| # Advanced Classification Uncertainty Quantification: Remote Sensing & Hyperspectral Analysis | |
| [](https://img.shields.io/badge/Python-3.9%2B-blue?style=for-the-badge&logo=python&logoColor=white) | |
| [](https://img.shields.io/badge/TensorFlow-2.10%2B-orange?style=for-the-badge&logo=tensorflow&logoColor=white) | |
| [](https://img.shields.io/badge/Uncertainty-Conformal%20%7C%20Ensemble%20%7C%20Bayesian-green?style=for-the-badge) | |
| [](https://img.shields.io/badge/Status-Active-success?style=for-the-badge) | |
| Welcome to the **Classification Uncertainty Quantification (UQ) Analysis** framework. This repository provides a comprehensive, modular pipeline for quantifying predictive uncertainty in complex classification tasks, specifically optimized for high-dimensional remote sensing and multispectral imagery. | |
| Beyond traditional point-wise accuracy, this framework implements state-of-the-art methods including **Conformal Prediction**, **Credal Deep Ensembles**, and **Deep Adaptive Predictive Modeling**, ensuring every classification decision is backed by a statistically valid measure of confidence. | |
| --- | |
| ## π Table of Contents | |
| 1. [π Project Overview](#-project-overview) | |
| 2. [π Repository Structure](#-repository-structure) | |
| 3. [π Dataset & Usage](#-dataset--usage) | |
| 4. [π οΈ Workflow & Methodology](#-workflow--methodology) | |
| * [Method 1: Baseline Uncertainty](#method-1-baseline-uncertainty) | |
| * [Method 2: CREDIT (Calibration-Aware)](#method-2-credit-calibration-aware) | |
| * [Method 3: DAPM (Deep Adaptive Modeling)](#method-3-dapm-deep-adaptive-modeling) | |
| * [Method 4: Ensemble (CreDE)](#method-4-ensemble-crede) | |
| * [Method 5: MultiCP (Multi-head Conformal)](#method-5-multicp-multi-head-conformal) | |
| * [Method 6: SACP (Self-Adaptive Conformal)](#method-6-sacp-self-adaptive-conformal) | |
| * [Method 7: SCMCP (Spatial MultiCP)](#method-7-scmcp-spatial-multicp) | |
| * [Method 8: Focal Loss & CB Focal Loss](#method-8-focal-loss--cb-focal-loss) | |
| * [Method 9: EDL (Evidential Deep Learning)](#method-9-edl-evidential-deep-learning) | |
| * [Method 10: CDL (Credal Deep Learning)](#method-10-cdl-credal-deep-learning) | |
| * [Method 11: MambaHSI](#method-11-mambahsi) | |
| 5. [π Getting Started](#-getting-started) | |
| 6. [π Resources & References](#-resources--references) | |
| 7. [π 6 Bands Data - Directory & Kaggle Links](#-6-bands-data---directory--kaggle-links) | |
| --- | |
| ## π Project Overview | |
| This framework addresses the critical need for reliability in machine learning models deployed for Earth Observation and spatial analysis. By integrating multiple UQ paradigms, it allows researchers to: | |
| * **Identify Out-of-Distribution (OOD) Pixels**: Detect areas where the model is likely to fail. | |
| * **Calibrate Probabilistic Outputs**: Ensure that a 90% confidence score actually corresponds to 90% accuracy. | |
| * **Generate Valid Prediction Sets**: Use Conformal Prediction to produce sets of classes that contain the true label with a user-specified probability (e.g., 95%). | |
| * **Analyze Spatial Uncertainty**: Visualize uncertainty maps across entire scenes (Hyperspectral/Multispectral). | |
| **Key Features:** | |
| * **Deep Architectures**: AlexNet CNN, GFNet (Global Filter Network), and ViT-UNet (Vision Transformer). | |
| * **Modular Design**: Each method is self-contained with its own training logic, detailed theory/summary logs in `.md` format, and result visualization. | |
| * **Remote Sensing Ready**: Built-in support for multispectral data structures. | |
| --- | |
| ## π Repository Structure | |
| The project is organized into a modular architecture optimized for portability and experimental reproducibility. The main source code is organized within the `Classification/` directory: | |
| ```text | |
| . | |
| βββ Classification/ # π Main Project Folder (Upload this to MyDrive/) | |
| β βββ baseline/ # π Standard UQ (MC Dropout, Temp Scaling) | |
| β βββ credit/ # π CREDIT: Calibration-aware training | |
| β βββ dapm/ # π DAPM: Deep Adaptive Predictive Modeling | |
| β βββ data/ # π Raw Datasets (data.csv, multispectral/) | |
| β βββ dofa/ # π DOFA: Dynamic Wavelength Tokenization | |
| β βββ ensemble/ # π CreDE: Credal Deep Ensembles | |
| β βββ georsclip/ # π GeoRSCLIP: Geospatial Vision-Language Foundation Model (New) | |
| β βββ mambahsi/ # π MambaHSI Architecture for classification | |
| β βββ multicp/ # π MultiCP: Multi-head Conformal Prediction | |
| β βββ multicp_sacp/ # π SCMCP: Spatial MultiCP | |
| β βββ sacp/ # π SACP: Self-Adaptive Conformal Prediction | |
| β βββ spatialgcn/ # π SpatialGCN: Spatial Graph Convolutional Networks (New) | |
| β βββ trials/ # π§ͺ Experimental Methods | |
| β βββ cb_focal_loss/ | |
| β βββ cdl/ | |
| β βββ conformal_reg/ | |
| β βββ edl/ | |
| β βββ edl_v2/ | |
| β βββ focal_loss/ | |
| βββ examples/ # π Example Dataset Suites (untouched) | |
| βββ README.md # π Documentation | |
| ``` | |
| --- | |
| ## π Dataset & Usage | |
| **This is a Template Pipeline.** | |
| To use this repository with your own classification data: | |
| 1. **Prepare Data**: Ensure your features and labels are in `.csv` or `.npy` format. | |
| 2. **Path Configuration**: | |
| * Place your data in the `Classification/data/` directory. | |
| * Notebooks use relative paths (e.g., `../data/data.csv`) for compatibility with Google Colab and local environments. | |
| 3. **Model Selection**: Choose from AlexNet, GFNet, or ViT-UNet by modifying the configuration in the respective notebooks. | |
| --- | |
| ## π οΈ Workflow & Methodology | |
| > **Note**: Each method subfolder in `Classification/` includes a comprehensive `.md` file detailing the mathematical framework, implementation logic, and experimental logs. | |
| --- | |
| ### Method 1: Baseline Uncertainty | |
| **Location**: `Classification/baseline` | |
| Establishes the performance and uncertainty floor using standard Bayesian approximations and Conformal Prediction. | |
| * **Techniques**: Monte Carlo Dropout, Temperature Scaling, Conformal Prediction (SplitCP, CcCP, RC3P, ClusteredCP, RAPS). | |
| * **Models**: AlexNet-CNN, GFNet, ViT-UNet. | |
| * **Trained Weights Artifacts**: `AlexNet_CNN_best.keras`, `GFNet_best.keras`, `ViT_UNet_best.keras` (Input: 9Γ9Γ6, Output: 7 classes). | |
| #### 6-Band Baseline Performance (100 Epochs, Kaggle GPU) | |
| | Model | Test Accuracy | Cohen's Kappa | Macro F1 | Weighted F1 | Test Brier | Test ECE (15-bin) | Status | | |
| |:---|:---:|:---:|:---:|:---:|:---:|:---:|:---:| | |
| | **AlexNet_CNN** | **99.70%** | **0.9959** | **0.9955** | **0.9970** | **0.0044** | **0.0013** | β Verified | | |
| | **GFNet** | 99.63% | 0.9950 | 0.9954 | 0.9963 | 0.0057 | 0.0089 | β Verified | | |
| | **ViT_UNet** | 99.28% | 0.9902 | 0.9904 | 0.9928 | 0.0136 | 0.0388 | β Verified | | |
| #### Conformal Prediction Evaluation Summary ($\alpha = 0.05$, Target Coverage = 95.0%) | |
| | Method | AlexNet Coverage | GFNet Coverage | ViT-UNet Coverage | Avg Set Size | Median Set Size | | |
| |:---|:---:|:---:|:---:|:---:|:---:| | |
| | **SplitCP** | 95.78% | 94.99% | 95.41% | 0.95 - 0.96 | 1.0 | | |
| | **CcCP (Class-Conditional)** | 96.47% | 96.19% | 95.59% | 0.96 | 1.0 | | |
| | **RC3P (Rank-Calibrated)** | 97.17% | 96.57% | 96.29% | 0.96 - 0.97 | 1.0 | | |
| | **ClusteredCP (K=4)** | 96.52% | 95.96% | 95.36% | 0.96 | 1.0 | | |
| | **RAPS** | 99.91% | 99.77% | 99.40% | 1.00 | 1.0 | | |
| ### Method 2: CREDIT | |
| **Location**: `Classification/credit` | |
| Confidence-Calibrated Robustness for Deep Image Classification. | |
| * **Focus**: Improving the alignment between model confidence and actual performance. | |
| * **Output**: Calibrated spatial uncertainty maps. | |
| ### Method 3: DAPM | |
| **Location**: `Classification/dapm` | |
| Deep Adaptive Predictive Modeling for classification under distribution shift. | |
| * **Architecture**: Includes Encoder, Diffusion, and Multi-head decoders. | |
| * **Result**: High-resolution p-value distributions and uncertainty masks. | |
| ### Method 4: Ensemble (CreDE) | |
| **Location**: `Classification/ensemble` | |
| Credal Deep Ensembles (CreDE) for robust uncertainty. | |
| * **Process**: Training multiple model instances to capture epistemic uncertainty. | |
| * **Metrics**: Credal entropy and variance-based measures. | |
| ### Method 5: MultiCP | |
| **Location**: `Classification/multicp` | |
| Multi-head Conformal Prediction. | |
| * **Goal**: Distribution-free uncertainty sets with finite-sample validity. | |
| * **Output**: Performance measures across different significance levels ($\alpha$). | |
| ### Method 6: SACP | |
| **Location**: `Classification/sacp` | |
| Self-Adaptive Conformal Prediction. | |
| * **Advantage**: Online calibration and adaptation across varying spatial windows (ws=3, 5, 7, 9). | |
| * **Summary**: Combined per-class coverage reports for all models. | |
| ### Method 7: SCMCP (Spatial MultiCP) | |
| **Location**: `Classification/multicp_sacp` | |
| Spatial Multi-Head Conformal Prediction. | |
| * **Core**: Combines spatial probability smoothing with multi-head conformal intersection. | |
| * **Feature**: Produces tight, spatially-coherent uncertainty regions by intersecting calibrated sets from $K$ heads after local smoothing. | |
| ### Method 8: Focal Loss & CB Focal Loss | |
| **Location**: `Classification/trials/focal_loss` & `Classification/trials/cb_focal_loss` | |
| * **Focus**: Addressing class imbalance using standard and Class-Balanced Focal Loss. | |
| * **Output**: Improved minority class prediction with respective uncertainty estimates. | |
| ### Method 9: EDL (Evidential Deep Learning) | |
| **Location**: `Classification/trials/edl` & `Classification/trials/edl_v2` | |
| * **Core**: Uses Subjective Logic to place a Dirichlet distribution over class probabilities. | |
| * **Goal**: Directly quantifies epistemic and aleatoric uncertainty without sampling. | |
| ### Method 10: CDL (Credal Deep Learning) | |
| **Location**: `Classification/trials/cdl` | |
| * **Goal**: Robust uncertainty quantification using imprecise probabilities and credal sets. | |
| ### Method 11: MambaHSI | |
| **Location**: `Classification/mambahsi` | |
| * **Architecture**: State-of-the-art Mamba state-space models adapted for Hyperspectral Imagery (HSI). | |
| * **Focus**: Efficient long-range spatial-spectral dependencies modeling. | |
| --- | |
| ### Method 12: DOFA | |
| **Location**: `Classification/dofa` | |
| Dynamic Wavelength Tokenization. | |
| * **Architecture**: DOFA Spectral and DOFA Hiera Fusion for robust multispectral tokenization. | |
| * **Focus**: Analyzing prediction stability across continuous spectral channels. | |
| --- | |
| ### Method 13: GeoRSCLIP | |
| **Location**: `Classification/georsclip` | |
| Geospatial Vision-Language Foundation Model. | |
| * **Architecture**: Text-head fine-tuning on GeoRSCLIP representations. | |
| * **Focus**: Leveraging multimodal pre-training for remote sensing tasks. | |
| ### Method 14: SpatialGCN | |
| **Location**: `Classification/spatialgcn` | |
| Spatial Graph Convolutional Networks. | |
| * **Architecture**: GCN processing on spatial grid topologies. | |
| * **Focus**: Capturing complex spatial dependencies in classification maps. | |
| --- | |
| ## π Getting Started (Colab-First) | |
| 1. **Clone the Repository**: | |
| ```bash | |
| git clone https://github.com/DaneshSelwal/Classification_Uncertainty_Quantification_Analysis | |
| ``` | |
| 2. **Upload to Google Drive**: | |
| Upload the `Classification/` folder to your `MyDrive/` directory. | |
| 3. **Run in Colab**: | |
| Navigate to any phase (e.g., `baseline/Model_training.ipynb`) and open with Google Colab. | |
| * Notebooks are pre-configured to mount `/content/drive` and find data in `/content/drive/MyDrive/Classification/data/`. | |
| 4. **Execution Order**: | |
| **Data Prep** $\rightarrow$ **Baseline Training** $\rightarrow$ **Advanced UQ Methods** $\rightarrow$ **Visualization**. | |
| --- | |
| ## π Resources & References | |
| This project leverages state-of-the-art research in Uncertainty Quantification and Remote Sensing. Below are the key resources and research papers utilized in this pipeline: | |
| ### π Research Papers | |
| * **Weighted Aggregation of Conformity Scores**: *Weighted Aggregation of Conformity Scores for Classification*. [ArXiv:2407.10230](https://arxiv.org/abs/2407.10230) | |
| * **Uncertainty Sets for Image Classifiers**: *Uncertainty Sets for Image Classifiers using Conformal Prediction*. [ArXiv:2009.14193](https://arxiv.org/abs/2009.14193) | |
| * **Conformal Prediction via Label Ranking**: *Conformal Prediction for Deep Classifier via Label Ranking*. [ArXiv:2310.06430](https://arxiv.org/abs/2310.06430) | |
| * **Credal Ensemble Distillation**: *Credal Ensemble Distillation for Uncertainty Quantification*. [ArXiv:2511.13766](https://arxiv.org/abs/2511.13766) | |
| * **Calibration of Modern Neural Networks**: *On Calibration of Modern Neural Networks*. [ICML 2017](https://arxiv.org/abs/1706.04599) | |
| * **Deep Ensembles**: Lakshminarayanan, B., et al. (2017). *Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles*. [NeurIPS 2017](https://arxiv.org/abs/1612.01474) | |
| ### π οΈ Libraries & Frameworks | |
| * **SACP (Self-Adaptive CP)**: [GitHub](https://github.com/J4ckLiu/SACP) | |
| * **TensorFlow / Keras**: Deep learning frameworks utilized for modeling architectures like AlexNet, GFNet, and ViT-UNet. | |
| --- | |
| _This repository is developed under the guidance of Dr. Mahesh Pal._ | |
| --- | |
| # 6 Bands Data - Directory & Kaggle Links | |
| Below is the directory structure mirroring our local repository, with direct links to the notebooks on Kaggle: | |
| * π **baseline/** | |
| * π [Model_training.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-baseline-k01) β `cuq6-baseline-k01` β **COMPLETE** (Fresh weights & metrics verified) | |
| * π [Model_uncertainty_comparison.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-uncertainty-k02) β `cuq6-uncertainty-k02` β **COMPLETE** (Conformal prediction evaluated) | |
| * π **credit/** | |
| * π [Model_training_credit.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-credit-k03) β `cuq6-credit-k03` β **COMPLETE** (CreDE Evidential distillation verified) | |
| * π **data/** | |
| * π **ensemble/** | |
| * π [Model_training_ensembles.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-ensemble-k04) β `cuq6-ensemble-k04` β οΈ **CANCELLED** (not re-run in this pass) | |
| * π [Model_uncertainty_CreDE.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-crede-k05) β `cuq6-crede-k05` β **COMPLETE** (Credal Deep Ensemble evaluation) | |
| * π **multicp/** | |
| * π [Model_training_multihead.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-multicp-k06) β `cuq6-multicp-k06` β οΈ **CANCELLED** (not re-run in this pass) | |
| * π [Model_uncertainty_multicp.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-multicp-uq-k07) β `cuq6-multicp-uq-k07` β **ERROR** (depends on multicp-k06) | |
| * π **multicp_sacp/** | |
| * π [Model_uncertainty_multicp_sacp.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-multicp-sacp-k08) β `cuq6-multicp-sacp-k08` β **ERROR** (depends on multicp-k06) | |
| * π **sacp/** | |
| * π [Model_sacp_comparison.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-sacp-k09) β `cuq6-sacp-k09` β **COMPLETE** (Multi-window SACP evaluated) | |
| * π **mambahsi/** | |
| * π [Model_training_mambahsi.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-mambahsi-k10) β `cuq6-mambahsi-k10` β **COMPLETE** (Fresh 6-band SSM weights trained) | |
| * π [Model_uncertainty_comparison_mambahsi.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-mambahsi-uq-k11) β `cuq6-mambahsi-uq-k11` β **COMPLETE** (SSM conformal prediction evaluated) | |
| * π **dofa/** | |
| * π [Model_training.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-dofa-k12) β `cuq6-dofa-k12` β **COMPLETE** (Fresh 6-band DOFA/Hiera weights trained) | |
| * π [Model_uncertainty_comparison.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-dofa-uq-k13) β `cuq6-dofa-uq-k13` β **COMPLETE** (DOFA conformal prediction evaluated) | |
| * π **georsclip/** | |
| * π [Model_training.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-georsclip-k14) β `cuq6-georsclip-k14` β **COMPLETE** (Vision-language text-head architecture) | |
| * π [Model_uncertainty_comparison.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-georsclip-uq-k15) β `cuq6-georsclip-uq-k15` β **COMPLETE** (GeoRSCLIP conformal prediction evaluated) | |
| * π **spatialgcn/** | |
| * π [Model_training.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-spatialgcn-k16) β `cuq6-spatialgcn-k16` β **COMPLETE** (Spatial graph convolution architecture) | |
| * π [Model_uncertainty_comparison.ipynb](https://www.kaggle.com/code/daneshselwal/cuq6-spatialgcn-uq-k17) β `cuq6-spatialgcn-uq-k17` β **COMPLETE** (SpatialGCN conformal prediction evaluated) | |