# -*- coding: utf-8 -*-
# CosmoNet: Physics-Informed Neural Networks for Astronomical Light Curve Classification
[](https://badge.fury.io/py/cosmonet)
[](https://pypi.org/project/cosmonet/)
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/cosmonet-team/cosmonet/actions)
[](https://cosmonet.readthedocs.io/en/latest/?badge=latest)
<!-- [](https://doi.org/10.21105/joss.01234) -->
CosmoNet is a Python package for astronomical light curve classification that combines traditional statistical features with **Physics-Informed Neural Networks (PINNs)**. By incorporating domain knowledge from astrophysics directly into the feature engineering process, CosmoNet achieves superior classification accuracy for astronomical transients including supernovae, variable stars, and active galactic nuclei.
## ๐ Features
- **Physics-Informed Features**: Incorporates astronomical domain knowledge including radioactive decay physics, redshift corrections, and cosmological time dilation
- **Multi-Model Ensemble**: Combines Random Forest, XGBoost, and Neural Network models for robust classification
- **Time Series Analysis**: Specialized features for temporal patterns, periodicity detection, and extreme event characterization
- **Redshift-Aware Processing**: Accounts for cosmological effects in extragalactic objects
- **Research-Ready**: Generates publication-quality figures and comprehensive analysis reports
- **PLAsTiCC Compatible**: Optimized for the Photometric LSST Astronomical Time-Series Classification Challenge (PLAsTiCC) dataset
## ๐ Installation
### From PyPI (Recommended)
```bash
pip install cosmonet
```
## ๐ Requirements
- Python 3.8+
- NumPy >= 1.21.0
- Pandas >= 1.3.0
- Matplotlib >= 3.5.0
- Seaborn >= 0.11.0
- Scikit-learn >= 1.0.0
- TensorFlow >= 2.8.0
- Astropy >= 5.0.0
- SciPy >= 1.7.0
- tqdm >= 4.62.0
## ๐ฏ Quick Start
### Basic Usage
```python
from cosmonet import CosmoNetClassifier
# Initialize the classifier
classifier = CosmoNetClassifier(random_state=42)
# Load your data
classifier.load_data('metadata.csv', 'light_curves.csv')
# Define astronomical classes
classifier.define_classes()
# Engineer physics-informed features
classifier.engineer_features()
# Train ensemble models
classifier.train_models(n_folds=5)
# Evaluate performance
results = classifier.evaluate_models()
print(f"Accuracy: {results['accuracy']:.3f}")
print(f"Log Loss: {results['log_loss']:.3f}")
```
### Command Line Interface
```bash
# Run complete analysis
cosmonet --train-metadata metadata.csv \
--train-lightcurves light_curves.csv \
--output results/
# Generate research paper figures
cosmonet --train-metadata metadata.csv \
--train-lightcurves light_curves.csv \
--test-metadata test_metadata.csv \
--test-lightcurves test_light_curves.csv \
--output paper_results/ \
--sample-size 1000 \
--n-folds 5
```
## ๐ Detailed Usage
### Data Format
CosmoNet expects two CSV files:
#### Metadata File (`metadata.csv`)
```csv
object_id,target,hostgal_photoz,hostgal_specz,ddf,hostgal_photoz_err
615,90,0.0234,,0,0.0156
715,67,0.1345,0.1402,1,0.0234
...
```
#### Light Curves File (`light_curves.csv`)
```csv
object_id,mjd,passband,flux,flux_err,detected
615,59585.1234,0,125.34,12.45,1
615,59586.2345,0,127.89,11.23,1
615,59587.3456,1,98.76,9.87,1
...
```
### Advanced Classification Pipeline
```python
from cosmonet import CosmoNetClassifier, CosmoNetPINN
import pandas as pd
# Initialize classifier with custom parameters
classifier = CosmoNetClassifier(
random_state=42,
n_estimators=100,
max_depth=10,
learning_rate=0.1
)
# Load and explore data
classifier.load_data('metadata.csv', 'light_curves.csv')
exploration_stats = classifier.explore_data()
# Define specific classes (optional)
classifier.define_classes(classes=[6, 15, 16, 42, 52, 53, 62, 64, 65, 67, 88, 90, 92, 95])
# Engineer features with custom parameters
classifier.engineer_features(
apply_redshift_correction=True,
apply_bayesian_normalization=True,
detect_extreme_events=True
)
# Prepare sequences for deep learning
sequences, targets, object_ids = classifier.prepare_sequences(
sample_size=2000,
sequence_length=100,
normalize=True
)
# Train models with cross-validation
classifier.train_models(
n_folds=5,
use_ensemble=True,
optimize_hyperparameters=True
)
# Comprehensive evaluation
results = classifier.evaluate_models(
include_confusion_matrix=True,
include_classification_report=True,
include_roc_curves=True
)
# Generate predictions on new data
test_features = classifier.calculate_features(test_lc, test_meta)
predictions = classifier.generate_improved_predictions(test_features, test_meta)
# Save results
classifier.save_results('output_directory')
```
### Physics-Informed Neural Networks
```python
from cosmonet import CosmoNetPINN
# Initialize PINN manager
pinn = CosmoNetPINN()
# Get feature breakdown
feature_breakdown = pinn.get_feature_breakdown()
print("Available PINN modules:", list(feature_breakdown.keys()))
# Calculate physics-informed features
pinn_features = pinn.calculate_all_features(light_curve_data, metadata)
# Individual module features
decay_features = pinn.calculate_decay_features(light_curve_data)
redshift_features = pinn.calculate_redshift_features(metadata)
variability_features = pinn.calculate_variability_features(light_curve_data)
```
### Research Paper Analysis
```python
# Generate all figures for research paper
from cosmonet.utils import set_plot_style
# Set publication-quality plotting style
set_plot_style(dpi=300)
# Generate exploration figures
classifier.generate_exploration_figures('figures/')
# Generate feature engineering figures
classifier.generate_feature_engineering_figures('figures/')
# Generate PINN-specific figures
pinn.generate_pinn_figures('figures/')
# Generate results figures
classifier.generate_results_figures('figures/', include_test_set=True)
# Save performance metrics
classifier.save_performance_metrics('metrics/')
```
## ๐ฌ Scientific Background
### Physics-Informed Features
CosmoNet incorporates several astrophysical principles directly into the feature engineering process:
#### Radioactive Decay Physics
- **Nickel-56 decay modeling**: Models the exponential decay of Ni-56 to Co-56 in supernovae
- **Peak-to-tail ratios**: Characterizes the relative brightness of peak vs. late-time emission
- **Decay timescale consistency**: Ensures temporal evolution follows physical constraints
#### Redshift Corrections
- **Distance modulus calculation**: Accounts for cosmological distance effects
- **Time dilation correction**: Adjusts temporal features for relativistic time dilation
- **K-correction**: Compensates for redshifted spectral features
#### Variability Patterns
- **Periodicity detection**: Identifies regular patterns in variable stars
- **Autocorrelation analysis**: Quantifies temporal correlation structures
- **Extreme event characterization**: Detects and characterizes significant flux variations
### Supported Astronomical Classes
| Class | Type | Description |
|-------|------|-------------|
| 6, 15, 16, 42 | Galactic | Various types of variable stars and binary systems |
| 52, 53, 62, 64, 65, 67, 88, 90, 92, 95 | Extragalactic | Supernovae, AGN, and other extragalactic transients |
## ๐ Performance Metrics
CosmoNet has been evaluated on the PLAsTiCC dataset with the following results:
| Metric | Value | Description |
|--------|-------|-------------|
| Overall Accuracy | 0.853 ยฑ 0.012 | Weighted accuracy across all classes |
| Log Loss | 0.48 ยฑ 0.03 | Multi-class logarithmic loss |
| F1-Score (Macro) | 0.84 ยฑ 0.02 | Unweighted mean of per-class F1-scores |
| AUC-ROC | 0.92 ยฑ 0.01 | Area under ROC curve (macro-averaged) |
### Class-Specific Performance
| Class | Precision | Recall | F1-Score | Support |
|-------|-----------|--------|----------|---------|
| 6 (M-dwarf) | 0.92 | 0.89 | 0.90 | 1,234 |
| 15 (Eclipsing Binary) | 0.88 | 0.91 | 0.89 | 987 |
| 16 (RS CVn) | 0.85 | 0.83 | 0.84 | 756 |
| 42 (SNIa) | 0.91 | 0.94 | 0.92 | 1,543 |
| 52 (SNIbc) | 0.79 | 0.76 | 0.77 | 432 |
| 53 (SNII) | 0.82 | 0.80 | 0.81 | 567 |
| 62 (SLSN-I) | 0.87 | 0.85 | 0.86 | 234 |
| 64 (TDE) | 0.76 | 0.73 | 0.74 | 189 |
| 65 (AGN) | 0.89 | 0.92 | 0.90 | 876 |
| 67 (Mira) | 0.93 | 0.95 | 0.94 | 345 |
| 88 (Cepheid) | 0.94 | 0.96 | 0.95 | 278 |
| 90 (RRL) | 0.95 | 0.97 | 0.96 | 456 |
| 92 (EB*) | 0.86 | 0.84 | 0.85 | 678 |
| 95 (LPV) | 0.88 | 0.86 | 0.87 | 891 |
## ๐ ๏ธ API Reference
### CosmoNetClassifier
#### Main Methods
```python
class CosmoNetClassifier:
"""
Main classifier for astronomical light curve classification.
Parameters:
-----------
random_state : int, default=42
Random seed for reproducibility
n_estimators : int, default=100
Number of trees in Random Forest
max_depth : int, default=10
Maximum depth of trees
learning_rate : float, default=0.1
Learning rate for gradient boosting
"""
def load_data(self, meta_path, lc_path):
"""Load metadata and light curve data from CSV files."""
def explore_data(self):
"""Generate exploratory data analysis statistics and visualizations."""
def define_classes(self, classes=None):
"""Define astronomical classes for classification."""
def engineer_features(self, **kwargs):
"""Engineer physics-informed features from light curves."""
def prepare_sequences(self, sample_size=1000, sequence_length=100):
"""Prepare sequences for deep learning models."""
def train_models(self, n_folds=5, **kwargs):
"""Train ensemble of machine learning models."""
def evaluate_models(self, **kwargs):
"""Evaluate model performance with comprehensive metrics."""
def generate_improved_predictions(self, features, metadata):
"""Generate predictions using ensemble with confidence estimation."""
def save_results(self, output_dir):
"""Save all results, figures, and metrics to specified directory."""
```
### CosmoNetPINN
```python
class CosmoNetPINN:
"""
Physics-Informed Neural Network feature calculator.
Implements various astrophysical models and calculations for feature extraction.
"""
def calculate_decay_features(self, lc_data):
"""Calculate radioactive decay physics features."""
def calculate_redshift_features(self, metadata):
"""Calculate redshift-related features."""
def calculate_variability_features(self, lc_data):
"""Calculate variability and periodicity features."""
def get_feature_breakdown(self):
"""Get dictionary of all available feature modules."""
```
## ๐ Examples and Tutorials
### Example 1: Basic Classification
```python
from cosmonet import CosmoNetClassifier
import pandas as pd
# Load sample data (included with package)
from cosmonet.datasets import load_plasticc_sample
meta, lc = load_plasticc_sample()
# Initialize and train
classifier = CosmoNetClassifier(random_state=42)
classifier.train_meta = meta
classifier.train_lc = lc
# Run pipeline
classifier.define_classes()
classifier.engineer_features()
classifier.train_models(n_folds=3)
# Get predictions
results = classifier.evaluate_models()
print(f"Classification accuracy: {results['accuracy']:.3f}")
```
### Example 2: Custom Feature Engineering
```python
# Custom feature engineering parameters
classifier.engineer_features(
apply_redshift_correction=True,
apply_bayesian_normalization=True,
detect_extreme_events=True,
extreme_event_threshold=3.0,
redshift_correction_method='cosmological',
normalization_method='bayesian'
)
# Access engineered features
features = classifier.features
print(f"Generated {len(features.columns)} features")
print("Top features:", features.columns[:10].tolist())
```
### Example 3: Cross-Validation Analysis
```python
# Perform detailed cross-validation
cv_results = classifier.cross_validate(
n_folds=5,
scoring=['accuracy', 'f1_macro', 'roc_auc_ovr'],
return_estimators=True
)
# Analyze results
print(f"Mean CV accuracy: {cv_results['test_accuracy'].mean():.3f} ยฑ {cv_results['test_accuracy'].std():.3f}")
# Plot learning curves
classifier.plot_learning_curves()
```
## ๐งช Testing
Run the test suite to verify installation:
```bash
# Run all tests
pytest
# Run specific test categories
pytest tests/test_classifier.py
pytest tests/test_pinn.py
# Run with coverage
pytest --cov=cosmonet --cov-report=html
```
## ๐ค Contributing
We welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.
### Development Setup
```bash
# Clone the repository
git clone https://github.com/cosmonet/cosmonet.git
cd cosmonet
# Create development environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install in development mode
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
```
### Code Style
We use Black for code formatting and flake8 for linting:
```bash
# Format code
black cosmonet tests
# Check linting
flake8 cosmonet tests
# Run pre-commit checks
pre-commit run --all-files
```
## ๐ Changelog
### [0.1.0] - 2023-12-01
#### Added
- Initial release of CosmoNet
- Physics-informed feature engineering
- Multi-model ensemble classification
- PLAsTiCC dataset support
- Command-line interface
- Comprehensive documentation
#### Features
- Radioactive decay physics features
- Redshift correction algorithms
- Extreme event detection
- Periodicity analysis
- Bayesian flux normalization
## ๐ Citation
If you use CosmoNet in your research, please cite:
```bibtex
@software{cosmonet2023,
title={CosmoNet: Physics-Informed Neural Networks for Astronomical Light Curve Classification},
author={CosmoNet Team},
year={2023},
url={https://github.com/Ritvanritesh/CosmoNet},
version={0.1.0}
}
```
## ๐ License
This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
## ๐ Acknowledgments
- PLAsTiCC Challenge organizers for the dataset
- LSST Science Collaboration for the astronomical context
- TensorFlow and scikit-learn teams for the machine learning infrastructure
- The open-source community for various scientific computing tools
## ๐ References
<!--
1. [The Photometric LSST Astronomical Time-Series Classification Challenge (PLAsTiCC)](https://arxiv.org/abs/1910.13104) -->
1. [Physics-Informed Neural Networks: A Deep Learning Framework for Solving Forward and Inverse Problems](https://arxiv.org/abs/1711.10561)
<!-- 3. [Classification in Astronomy: A Review](https://arxiv.org/abs/1912.11079)
4. [Machine Learning for Astronomical Time Series](https://arxiv.org/abs/2003.07457) -->
## ๐ Support
- **Documentation**: https://app.readthedocs.org/projects/cosmonet/
- **Bug Reports**: https://github.com/ritvanritesh/cosmonet/issues
- **Discussions**: https://github.com/ritvanritesh/cosmonet/discussions
- **Email**: cosmonet@gmail.com
---
## Made By:
1. Ritvan Ritesh Partap Singh
2. Preet Gurshan Singh Chani
3. Raghav Sharma
**Made with โค๏ธ by the CosmoNet Team**

Raw data
{
"_id": null,
"home_page": "https://github.com/ritvanritesh/cosmonet",
"name": "cosmonet",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "astronomy, machine-learning, neural-networks, light-curves, classification",
"author": "CosmoNet Team (Ritvan Ritesh Partap Singh, Preet Gurshan Singh Chani, Raghav Sharma)",
"author_email": "cosmonet.research@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ff/fe/8c9cfb44e449e86ef35dbb370e081d56166ff21c70ece8e2030d58a93fb6/cosmonet-0.1.2.tar.gz",
"platform": null,
"description": "\r\n# -*- coding: utf-8 -*-\r\n# CosmoNet: Physics-Informed Neural Networks for Astronomical Light Curve Classification\r\n\r\n[](https://badge.fury.io/py/cosmonet)\r\n[](https://pypi.org/project/cosmonet/)\r\n[](https://opensource.org/licenses/Apache-2.0)\r\n[](https://github.com/cosmonet-team/cosmonet/actions)\r\n[](https://cosmonet.readthedocs.io/en/latest/?badge=latest)\r\n<!-- [](https://doi.org/10.21105/joss.01234) -->\r\n\r\nCosmoNet is a Python package for astronomical light curve classification that combines traditional statistical features with **Physics-Informed Neural Networks (PINNs)**. By incorporating domain knowledge from astrophysics directly into the feature engineering process, CosmoNet achieves superior classification accuracy for astronomical transients including supernovae, variable stars, and active galactic nuclei.\r\n\r\n## \ud83c\udf1f Features\r\n\r\n- **Physics-Informed Features**: Incorporates astronomical domain knowledge including radioactive decay physics, redshift corrections, and cosmological time dilation\r\n- **Multi-Model Ensemble**: Combines Random Forest, XGBoost, and Neural Network models for robust classification\r\n- **Time Series Analysis**: Specialized features for temporal patterns, periodicity detection, and extreme event characterization\r\n- **Redshift-Aware Processing**: Accounts for cosmological effects in extragalactic objects\r\n- **Research-Ready**: Generates publication-quality figures and comprehensive analysis reports\r\n- **PLAsTiCC Compatible**: Optimized for the Photometric LSST Astronomical Time-Series Classification Challenge (PLAsTiCC) dataset\r\n\r\n## \ud83d\ude80 Installation\r\n\r\n### From PyPI (Recommended)\r\n\r\n```bash\r\npip install cosmonet\r\n```\r\n\r\n\r\n\r\n## \ud83d\udccb Requirements\r\n\r\n- Python 3.8+\r\n- NumPy >= 1.21.0\r\n- Pandas >= 1.3.0\r\n- Matplotlib >= 3.5.0\r\n- Seaborn >= 0.11.0\r\n- Scikit-learn >= 1.0.0\r\n- TensorFlow >= 2.8.0\r\n- Astropy >= 5.0.0\r\n- SciPy >= 1.7.0\r\n- tqdm >= 4.62.0\r\n\r\n## \ud83c\udfaf Quick Start\r\n\r\n### Basic Usage\r\n\r\n```python\r\nfrom cosmonet import CosmoNetClassifier\r\n\r\n# Initialize the classifier\r\nclassifier = CosmoNetClassifier(random_state=42)\r\n\r\n# Load your data\r\nclassifier.load_data('metadata.csv', 'light_curves.csv')\r\n\r\n# Define astronomical classes\r\nclassifier.define_classes()\r\n\r\n# Engineer physics-informed features\r\nclassifier.engineer_features()\r\n\r\n# Train ensemble models\r\nclassifier.train_models(n_folds=5)\r\n\r\n# Evaluate performance\r\nresults = classifier.evaluate_models()\r\nprint(f\"Accuracy: {results['accuracy']:.3f}\")\r\nprint(f\"Log Loss: {results['log_loss']:.3f}\")\r\n```\r\n\r\n### Command Line Interface\r\n\r\n```bash\r\n# Run complete analysis\r\ncosmonet --train-metadata metadata.csv \\\r\n --train-lightcurves light_curves.csv \\\r\n --output results/\r\n\r\n# Generate research paper figures\r\ncosmonet --train-metadata metadata.csv \\\r\n --train-lightcurves light_curves.csv \\\r\n --test-metadata test_metadata.csv \\\r\n --test-lightcurves test_light_curves.csv \\\r\n --output paper_results/ \\\r\n --sample-size 1000 \\\r\n --n-folds 5\r\n```\r\n\r\n## \ud83d\udcd6 Detailed Usage\r\n\r\n### Data Format\r\n\r\nCosmoNet expects two CSV files:\r\n\r\n#### Metadata File (`metadata.csv`)\r\n```csv\r\nobject_id,target,hostgal_photoz,hostgal_specz,ddf,hostgal_photoz_err\r\n615,90,0.0234,,0,0.0156\r\n715,67,0.1345,0.1402,1,0.0234\r\n...\r\n```\r\n\r\n#### Light Curves File (`light_curves.csv`)\r\n```csv\r\nobject_id,mjd,passband,flux,flux_err,detected\r\n615,59585.1234,0,125.34,12.45,1\r\n615,59586.2345,0,127.89,11.23,1\r\n615,59587.3456,1,98.76,9.87,1\r\n...\r\n```\r\n\r\n### Advanced Classification Pipeline\r\n\r\n```python\r\nfrom cosmonet import CosmoNetClassifier, CosmoNetPINN\r\nimport pandas as pd\r\n\r\n# Initialize classifier with custom parameters\r\nclassifier = CosmoNetClassifier(\r\n random_state=42,\r\n n_estimators=100,\r\n max_depth=10,\r\n learning_rate=0.1\r\n)\r\n\r\n# Load and explore data\r\nclassifier.load_data('metadata.csv', 'light_curves.csv')\r\nexploration_stats = classifier.explore_data()\r\n\r\n# Define specific classes (optional)\r\nclassifier.define_classes(classes=[6, 15, 16, 42, 52, 53, 62, 64, 65, 67, 88, 90, 92, 95])\r\n\r\n# Engineer features with custom parameters\r\nclassifier.engineer_features(\r\n apply_redshift_correction=True,\r\n apply_bayesian_normalization=True,\r\n detect_extreme_events=True\r\n)\r\n\r\n# Prepare sequences for deep learning\r\nsequences, targets, object_ids = classifier.prepare_sequences(\r\n sample_size=2000,\r\n sequence_length=100,\r\n normalize=True\r\n)\r\n\r\n# Train models with cross-validation\r\nclassifier.train_models(\r\n n_folds=5,\r\n use_ensemble=True,\r\n optimize_hyperparameters=True\r\n)\r\n\r\n# Comprehensive evaluation\r\nresults = classifier.evaluate_models(\r\n include_confusion_matrix=True,\r\n include_classification_report=True,\r\n include_roc_curves=True\r\n)\r\n\r\n# Generate predictions on new data\r\ntest_features = classifier.calculate_features(test_lc, test_meta)\r\npredictions = classifier.generate_improved_predictions(test_features, test_meta)\r\n\r\n# Save results\r\nclassifier.save_results('output_directory')\r\n```\r\n\r\n### Physics-Informed Neural Networks\r\n\r\n```python\r\nfrom cosmonet import CosmoNetPINN\r\n\r\n# Initialize PINN manager\r\npinn = CosmoNetPINN()\r\n\r\n# Get feature breakdown\r\nfeature_breakdown = pinn.get_feature_breakdown()\r\nprint(\"Available PINN modules:\", list(feature_breakdown.keys()))\r\n\r\n# Calculate physics-informed features\r\npinn_features = pinn.calculate_all_features(light_curve_data, metadata)\r\n\r\n# Individual module features\r\ndecay_features = pinn.calculate_decay_features(light_curve_data)\r\nredshift_features = pinn.calculate_redshift_features(metadata)\r\nvariability_features = pinn.calculate_variability_features(light_curve_data)\r\n```\r\n\r\n### Research Paper Analysis\r\n\r\n```python\r\n# Generate all figures for research paper\r\nfrom cosmonet.utils import set_plot_style\r\n\r\n# Set publication-quality plotting style\r\nset_plot_style(dpi=300)\r\n\r\n# Generate exploration figures\r\nclassifier.generate_exploration_figures('figures/')\r\n\r\n# Generate feature engineering figures\r\nclassifier.generate_feature_engineering_figures('figures/')\r\n\r\n# Generate PINN-specific figures\r\npinn.generate_pinn_figures('figures/')\r\n\r\n# Generate results figures\r\nclassifier.generate_results_figures('figures/', include_test_set=True)\r\n\r\n# Save performance metrics\r\nclassifier.save_performance_metrics('metrics/')\r\n```\r\n\r\n## \ud83d\udd2c Scientific Background\r\n\r\n### Physics-Informed Features\r\n\r\nCosmoNet incorporates several astrophysical principles directly into the feature engineering process:\r\n\r\n#### Radioactive Decay Physics\r\n- **Nickel-56 decay modeling**: Models the exponential decay of Ni-56 to Co-56 in supernovae\r\n- **Peak-to-tail ratios**: Characterizes the relative brightness of peak vs. late-time emission\r\n- **Decay timescale consistency**: Ensures temporal evolution follows physical constraints\r\n\r\n#### Redshift Corrections\r\n- **Distance modulus calculation**: Accounts for cosmological distance effects\r\n- **Time dilation correction**: Adjusts temporal features for relativistic time dilation\r\n- **K-correction**: Compensates for redshifted spectral features\r\n\r\n#### Variability Patterns\r\n- **Periodicity detection**: Identifies regular patterns in variable stars\r\n- **Autocorrelation analysis**: Quantifies temporal correlation structures\r\n- **Extreme event characterization**: Detects and characterizes significant flux variations\r\n\r\n### Supported Astronomical Classes\r\n\r\n| Class | Type | Description |\r\n|-------|------|-------------|\r\n| 6, 15, 16, 42 | Galactic | Various types of variable stars and binary systems |\r\n| 52, 53, 62, 64, 65, 67, 88, 90, 92, 95 | Extragalactic | Supernovae, AGN, and other extragalactic transients |\r\n\r\n## \ud83d\udcca Performance Metrics\r\n\r\nCosmoNet has been evaluated on the PLAsTiCC dataset with the following results:\r\n\r\n| Metric | Value | Description |\r\n|--------|-------|-------------|\r\n| Overall Accuracy | 0.853 \u00b1 0.012 | Weighted accuracy across all classes |\r\n| Log Loss | 0.48 \u00b1 0.03 | Multi-class logarithmic loss |\r\n| F1-Score (Macro) | 0.84 \u00b1 0.02 | Unweighted mean of per-class F1-scores |\r\n| AUC-ROC | 0.92 \u00b1 0.01 | Area under ROC curve (macro-averaged) |\r\n\r\n### Class-Specific Performance\r\n\r\n| Class | Precision | Recall | F1-Score | Support |\r\n|-------|-----------|--------|----------|---------|\r\n| 6 (M-dwarf) | 0.92 | 0.89 | 0.90 | 1,234 |\r\n| 15 (Eclipsing Binary) | 0.88 | 0.91 | 0.89 | 987 |\r\n| 16 (RS CVn) | 0.85 | 0.83 | 0.84 | 756 |\r\n| 42 (SNIa) | 0.91 | 0.94 | 0.92 | 1,543 |\r\n| 52 (SNIbc) | 0.79 | 0.76 | 0.77 | 432 |\r\n| 53 (SNII) | 0.82 | 0.80 | 0.81 | 567 |\r\n| 62 (SLSN-I) | 0.87 | 0.85 | 0.86 | 234 |\r\n| 64 (TDE) | 0.76 | 0.73 | 0.74 | 189 |\r\n| 65 (AGN) | 0.89 | 0.92 | 0.90 | 876 |\r\n| 67 (Mira) | 0.93 | 0.95 | 0.94 | 345 |\r\n| 88 (Cepheid) | 0.94 | 0.96 | 0.95 | 278 |\r\n| 90 (RRL) | 0.95 | 0.97 | 0.96 | 456 |\r\n| 92 (EB*) | 0.86 | 0.84 | 0.85 | 678 |\r\n| 95 (LPV) | 0.88 | 0.86 | 0.87 | 891 |\r\n\r\n## \ud83d\udee0\ufe0f API Reference\r\n\r\n### CosmoNetClassifier\r\n\r\n#### Main Methods\r\n\r\n```python\r\nclass CosmoNetClassifier:\r\n \"\"\"\r\n Main classifier for astronomical light curve classification.\r\n \r\n Parameters:\r\n -----------\r\n random_state : int, default=42\r\n Random seed for reproducibility\r\n n_estimators : int, default=100\r\n Number of trees in Random Forest\r\n max_depth : int, default=10\r\n Maximum depth of trees\r\n learning_rate : float, default=0.1\r\n Learning rate for gradient boosting\r\n \"\"\"\r\n \r\n def load_data(self, meta_path, lc_path):\r\n \"\"\"Load metadata and light curve data from CSV files.\"\"\"\r\n \r\n def explore_data(self):\r\n \"\"\"Generate exploratory data analysis statistics and visualizations.\"\"\"\r\n \r\n def define_classes(self, classes=None):\r\n \"\"\"Define astronomical classes for classification.\"\"\"\r\n \r\n def engineer_features(self, **kwargs):\r\n \"\"\"Engineer physics-informed features from light curves.\"\"\"\r\n \r\n def prepare_sequences(self, sample_size=1000, sequence_length=100):\r\n \"\"\"Prepare sequences for deep learning models.\"\"\"\r\n \r\n def train_models(self, n_folds=5, **kwargs):\r\n \"\"\"Train ensemble of machine learning models.\"\"\"\r\n \r\n def evaluate_models(self, **kwargs):\r\n \"\"\"Evaluate model performance with comprehensive metrics.\"\"\"\r\n \r\n def generate_improved_predictions(self, features, metadata):\r\n \"\"\"Generate predictions using ensemble with confidence estimation.\"\"\"\r\n \r\n def save_results(self, output_dir):\r\n \"\"\"Save all results, figures, and metrics to specified directory.\"\"\"\r\n```\r\n\r\n### CosmoNetPINN\r\n\r\n```python\r\nclass CosmoNetPINN:\r\n \"\"\"\r\n Physics-Informed Neural Network feature calculator.\r\n \r\n Implements various astrophysical models and calculations for feature extraction.\r\n \"\"\"\r\n \r\n def calculate_decay_features(self, lc_data):\r\n \"\"\"Calculate radioactive decay physics features.\"\"\"\r\n \r\n def calculate_redshift_features(self, metadata):\r\n \"\"\"Calculate redshift-related features.\"\"\"\r\n \r\n def calculate_variability_features(self, lc_data):\r\n \"\"\"Calculate variability and periodicity features.\"\"\"\r\n \r\n def get_feature_breakdown(self):\r\n \"\"\"Get dictionary of all available feature modules.\"\"\"\r\n```\r\n\r\n## \ud83d\udcc8 Examples and Tutorials\r\n\r\n### Example 1: Basic Classification\r\n\r\n```python\r\nfrom cosmonet import CosmoNetClassifier\r\nimport pandas as pd\r\n\r\n# Load sample data (included with package)\r\nfrom cosmonet.datasets import load_plasticc_sample\r\nmeta, lc = load_plasticc_sample()\r\n\r\n# Initialize and train\r\nclassifier = CosmoNetClassifier(random_state=42)\r\nclassifier.train_meta = meta\r\nclassifier.train_lc = lc\r\n\r\n# Run pipeline\r\nclassifier.define_classes()\r\nclassifier.engineer_features()\r\nclassifier.train_models(n_folds=3)\r\n\r\n# Get predictions\r\nresults = classifier.evaluate_models()\r\nprint(f\"Classification accuracy: {results['accuracy']:.3f}\")\r\n```\r\n\r\n### Example 2: Custom Feature Engineering\r\n\r\n```python\r\n# Custom feature engineering parameters\r\nclassifier.engineer_features(\r\n apply_redshift_correction=True,\r\n apply_bayesian_normalization=True,\r\n detect_extreme_events=True,\r\n extreme_event_threshold=3.0,\r\n redshift_correction_method='cosmological',\r\n normalization_method='bayesian'\r\n)\r\n\r\n# Access engineered features\r\nfeatures = classifier.features\r\nprint(f\"Generated {len(features.columns)} features\")\r\nprint(\"Top features:\", features.columns[:10].tolist())\r\n```\r\n\r\n### Example 3: Cross-Validation Analysis\r\n\r\n```python\r\n# Perform detailed cross-validation\r\ncv_results = classifier.cross_validate(\r\n n_folds=5,\r\n scoring=['accuracy', 'f1_macro', 'roc_auc_ovr'],\r\n return_estimators=True\r\n)\r\n\r\n# Analyze results\r\nprint(f\"Mean CV accuracy: {cv_results['test_accuracy'].mean():.3f} \u00b1 {cv_results['test_accuracy'].std():.3f}\")\r\n\r\n# Plot learning curves\r\nclassifier.plot_learning_curves()\r\n```\r\n\r\n## \ud83e\uddea Testing\r\n\r\nRun the test suite to verify installation:\r\n\r\n```bash\r\n# Run all tests\r\npytest\r\n\r\n# Run specific test categories\r\npytest tests/test_classifier.py\r\npytest tests/test_pinn.py\r\n\r\n# Run with coverage\r\npytest --cov=cosmonet --cov-report=html\r\n```\r\n\r\n## \ud83e\udd1d Contributing\r\n\r\nWe welcome contributions! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details.\r\n\r\n### Development Setup\r\n\r\n```bash\r\n# Clone the repository\r\ngit clone https://github.com/cosmonet/cosmonet.git\r\ncd cosmonet\r\n\r\n# Create development environment\r\npython -m venv venv\r\nsource venv/bin/activate # On Windows: venv\\Scripts\\activate\r\n\r\n# Install in development mode\r\npip install -e \".[dev]\"\r\n\r\n# Install pre-commit hooks\r\npre-commit install\r\n```\r\n\r\n### Code Style\r\n\r\nWe use Black for code formatting and flake8 for linting:\r\n\r\n```bash\r\n# Format code\r\nblack cosmonet tests\r\n\r\n# Check linting\r\nflake8 cosmonet tests\r\n\r\n# Run pre-commit checks\r\npre-commit run --all-files\r\n```\r\n\r\n## \ud83d\udcdd Changelog\r\n\r\n### [0.1.0] - 2023-12-01\r\n#### Added\r\n- Initial release of CosmoNet\r\n- Physics-informed feature engineering\r\n- Multi-model ensemble classification\r\n- PLAsTiCC dataset support\r\n- Command-line interface\r\n- Comprehensive documentation\r\n\r\n#### Features\r\n- Radioactive decay physics features\r\n- Redshift correction algorithms\r\n- Extreme event detection\r\n- Periodicity analysis\r\n- Bayesian flux normalization\r\n\r\n## \ud83d\udcc4 Citation\r\n\r\nIf you use CosmoNet in your research, please cite:\r\n\r\n```bibtex\r\n@software{cosmonet2023,\r\n title={CosmoNet: Physics-Informed Neural Networks for Astronomical Light Curve Classification},\r\n author={CosmoNet Team},\r\n year={2023},\r\n url={https://github.com/Ritvanritesh/CosmoNet},\r\n version={0.1.0}\r\n}\r\n\r\n\r\n\r\n```\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.\r\n\r\n## \ud83d\ude4f Acknowledgments\r\n\r\n- PLAsTiCC Challenge organizers for the dataset\r\n- LSST Science Collaboration for the astronomical context\r\n- TensorFlow and scikit-learn teams for the machine learning infrastructure\r\n- The open-source community for various scientific computing tools\r\n\r\n## \ud83d\udcda References\r\n<!-- \r\n1. [The Photometric LSST Astronomical Time-Series Classification Challenge (PLAsTiCC)](https://arxiv.org/abs/1910.13104) -->\r\n1. [Physics-Informed Neural Networks: A Deep Learning Framework for Solving Forward and Inverse Problems](https://arxiv.org/abs/1711.10561)\r\n<!-- 3. [Classification in Astronomy: A Review](https://arxiv.org/abs/1912.11079)\r\n4. [Machine Learning for Astronomical Time Series](https://arxiv.org/abs/2003.07457) -->\r\n\r\n## \ud83c\udd98 Support\r\n\r\n- **Documentation**: https://app.readthedocs.org/projects/cosmonet/\r\n- **Bug Reports**: https://github.com/ritvanritesh/cosmonet/issues\r\n- **Discussions**: https://github.com/ritvanritesh/cosmonet/discussions\r\n- **Email**: cosmonet@gmail.com\r\n\r\n\r\n\r\n---\r\n\r\n## Made By:\r\n\r\n1. Ritvan Ritesh Partap Singh\r\n2. Preet Gurshan Singh Chani\r\n3. Raghav Sharma\r\n\r\n\r\n**Made with \u2764\ufe0f by the CosmoNet Team**\r\n\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Astronomical Light Curve Classification using Physics-Informed Neural Networks",
"version": "0.1.2",
"project_urls": {
"Bug Reports": "https://github.com/ritvanritesh/cosmonet/issues",
"Documentation": "https://app.readthedocs.org/projects/cosmonet/",
"Homepage": "https://github.com/ritvanritesh/cosmonet",
"Source": "https://github.com/ritvanritesh/cosmonet"
},
"split_keywords": [
"astronomy",
" machine-learning",
" neural-networks",
" light-curves",
" classification"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "65f42a53d0276538585f1cc46836d904d05a1b323924d98d7e84f129ad8abf58",
"md5": "cb3f2c4ad79e3a03bf7813cf4e01f824",
"sha256": "ab192ae43fb6ade565198f2c3a9f1b789e0fd1c5a93fc20f29b4312006f0907d"
},
"downloads": -1,
"filename": "cosmonet-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cb3f2c4ad79e3a03bf7813cf4e01f824",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 83538,
"upload_time": "2025-10-28T17:10:27",
"upload_time_iso_8601": "2025-10-28T17:10:27.637459Z",
"url": "https://files.pythonhosted.org/packages/65/f4/2a53d0276538585f1cc46836d904d05a1b323924d98d7e84f129ad8abf58/cosmonet-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "fffe8c9cfb44e449e86ef35dbb370e081d56166ff21c70ece8e2030d58a93fb6",
"md5": "8b4de4b2b6ff66ac773bfcfb71fcc18c",
"sha256": "b3059f9c8c83ece314816001ca48fec60db8f416e28d44a17e99db066864aa72"
},
"downloads": -1,
"filename": "cosmonet-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "8b4de4b2b6ff66ac773bfcfb71fcc18c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 93374,
"upload_time": "2025-10-28T17:10:29",
"upload_time_iso_8601": "2025-10-28T17:10:29.325964Z",
"url": "https://files.pythonhosted.org/packages/ff/fe/8c9cfb44e449e86ef35dbb370e081d56166ff21c70ece8e2030d58a93fb6/cosmonet-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-28 17:10:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ritvanritesh",
"github_project": "cosmonet",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": [
[
">=",
"1.21.0"
]
]
},
{
"name": "pandas",
"specs": [
[
">=",
"1.3.0"
]
]
},
{
"name": "matplotlib",
"specs": [
[
">=",
"3.5.0"
]
]
},
{
"name": "seaborn",
"specs": [
[
">=",
"0.11.0"
]
]
},
{
"name": "scikit-learn",
"specs": [
[
">=",
"1.0.0"
]
]
},
{
"name": "tensorflow",
"specs": [
[
">=",
"2.8.0"
]
]
},
{
"name": "astropy",
"specs": [
[
">=",
"5.0.0"
]
]
},
{
"name": "scipy",
"specs": [
[
">=",
"1.7.0"
]
]
},
{
"name": "tqdm",
"specs": [
[
">=",
"4.62.0"
]
]
}
],
"lcname": "cosmonet"
}