Skip to main content

Diabetes Osteoporosis Prediction Package - AI-powered analysis for diabetes complicated with osteoporosis

Project description

DOP1 - Diabetes Osteoporosis Prediction Package

A Python package for AI-powered analysis of diabetes complicated with osteoporosis using machine learning and OpenAI's GPT models.

Features

  • AI-Powered Analysis: Uses OpenAI's GPT models for intelligent prediction of osteoporosis risk in diabetic patients
  • Comprehensive Data Processing: Handles laboratory and clinical feature data
  • Batch Processing: Efficiently processes large datasets with progress tracking
  • Error Handling: Robust error handling with detailed logging
  • Configurable API: Flexible API endpoint and key configuration
  • Command Line Interface: Easy-to-use CLI for batch processing
  • Comprehensive Testing: Full test suite with coverage reporting

Installation

From Source (Development)

# Clone the repository
git clone https://github.com/dop-research/dop1.git
cd dop1

# Install in development mode
pip install -e .

# Install with development dependencies
pip install -e .[dev]

# Run tests
make test

Using pip (when published)

pip install dop1

Quick Start

Python API

from dop1 import DOPPredictor

# Initialize the predictor
predictor = DOPPredictor(api_key="your-api-key")

# Analyze a single patient
patient_data = {
    'id': 1000529,
    'GROUP': 1,  # This will be predicted
    'Age': 1,
    'Gender': 0,
    'ALP': 0,
    'BMI': 1,
    'GNRI': 1,
    'eGFR': 0,
    'SII': 1,
    'FT4': 0,
    'PDW': 0,
    'Creatinine': 0,
    'FT3': 0,
    'RDW_SD': 1
}

result = predictor.predict_single(patient_data)
print(f"Prediction: {result}")

# Process a batch of patients from CSV
predictor.process_batch("patients.csv", output_dir="results")

Command Line Interface

# Set API key
export OPENAI_API_KEY="your-api-key-here"

# Process a CSV file
dop1 predict data.csv --output results/

# Use custom model
dop1 predict data.csv --model gpt-4 --output results/

# Show help
dop1 --help

Data Format

The package expects CSV files with the following columns:

Column Description Values
id Patient identifier Any unique identifier
GROUP Target variable 0 = low bone mass/normal, 1 = osteoporosis/severe osteoporosis
Age Age group 0 or 1
Gender Gender 0 = male, 1 = female
ALP Alkaline phosphatase 0 or 1
BMI Body Mass Index 0 or 1
GNRI Geriatric Nutritional Risk Index 0 or 1
eGFR Estimated Glomerular Filtration Rate 0 or 1
SII Systemic Immune-Inflammation Index 0 or 1
FT4 Free Thyroxine 0 or 1
PDW Platelet Distribution Width 0 or 1
Creatinine Serum Creatinine 0 or 1
FT3 Free Triiodothyronine 0 or 1
RDW_SD Red Cell Distribution Width 0 or 1

Configuration

Environment Variables

export OPENAI_API_KEY="your-api-key-here"
export OPENAI_BASE_URL="https://api.ocoolai.com/v1"  # Optional
export DOP1_MODEL="gpt-5"  # Optional

Programmatic Configuration

predictor = DOPPredictor(
    api_key="your-api-key",
    base_url="https://api.ocoolai.com/v1",
    model="gpt-5"
)

Examples

Basic Usage

See examples/basic_usage.py for a complete example.

Sample Data

Use examples/sample_data.csv as a template for your data format.

Development

Running Tests

# Run all tests
make test

# Run tests without coverage
make test-fast

# Run specific test file
pytest tests/test_predictor.py -v

Code Quality

# Format code
make format

# Run linting
make lint

# Run all checks
make check

Building

# Build package
make build

# Clean build artifacts
make clean

API Reference

DOPPredictor Class

__init__(api_key, base_url, model)

Initialize the predictor with API configuration.

predict_single(patient_data)

Predict osteoporosis risk for a single patient.

process_batch(filepath, output_dir, skip_existing)

Process a batch of patients from CSV file.

get_model_info()

Get information about the current model configuration.

Utility Functions

load_data(filepath)

Load patient data from CSV file.

validate_data(data)

Validate patient data format.

save_results(results, filepath)

Save results to file.

Error Handling

The package provides custom exceptions:

  • DOPError: Base exception class
  • ValidationError: Data validation errors
  • APIError: API call failures
  • ConfigurationError: Configuration issues
  • FileError: File operation errors

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

License

MIT License - see LICENSE file for details.

Support

For issues and questions:

  • Create an issue on GitHub
  • Check the documentation
  • Review the examples

Changelog

v0.1.0

  • Initial release
  • Basic prediction functionality
  • Batch processing
  • CLI interface
  • Comprehensive testing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dop1-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dop1-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file dop1-0.1.0.tar.gz.

File metadata

  • Download URL: dop1-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.23 Darwin/24.1.0

File hashes

Hashes for dop1-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3578125d48b609c66b2f1a187171f79ac95835ca428fcc24085c1a3d616f73dc
MD5 925b8c40142fbaae8c7b8c6cbb75f1ce
BLAKE2b-256 43fde8a691632a93ee62df7ad3545d28c60fd3a64dd7ba8642c059ae51c3207c

See more details on using hashes here.

File details

Details for the file dop1-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: dop1-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.9.23 Darwin/24.1.0

File hashes

Hashes for dop1-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f8361dddd1686537e82496759e8a007416fd454f47ff78213e41ce4ac29f04a4
MD5 cb931d4490ab7d8e09992f3d432e3d0a
BLAKE2b-256 674211821188371225319bae1855c987a09076280543a1b8e83a6539d2b9c2ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page