Skip to main content

CrunchDAO example packages for machine learning competitions

Project description

CrunchDAO Crunch Example

This package provides example utilities and base classes for CrunchDAO machine learning competitions.

Installation

pip install crunchdao-crunch-example

Usage

Iris Classification

The crunchdao.crunch_example.iris package provides base classes for iris classification models:

from crunchdao.crunch_example.iris import IrisModelBase
import pandas as pd

class MyIrisModel(IrisModelBase):
    def train(self, train_data: pd.DataFrame) -> None:
        # Implement your training logic here
        # train_data contains features and target labels
        pass
    
    def infer(self, dataframe: pd.DataFrame) -> pd.DataFrame:
        # Implement your inference logic here
        # dataframe contains features to predict on
        predictions = [0, 1, 2]  # Your model predictions
        
        return pd.DataFrame({
            'prediction': predictions
        })

# Use your model
model = MyIrisModel()

# Training data with features and target
train_data = pd.DataFrame({
    'sepal_length': [5.1, 4.9, 4.7],
    'sepal_width': [3.5, 3.0, 3.2],
    'petal_length': [1.4, 1.4, 1.3],
    'petal_width': [0.2, 0.2, 0.2],
    'species': [0, 0, 0]  # 0=setosa, 1=versicolor, 2=virginica
})

model.train(train_data)

# Test data with just features
test_data = pd.DataFrame({
    'sepal_length': [6.1, 5.9],
    'sepal_width': [2.9, 3.0],
    'petal_length': [4.7, 4.2],
    'petal_width': [1.4, 1.5]
})

predictions = model.infer(test_data)
print(predictions)

Package Structure

This package uses namespace packaging to allow for future expansion:

  • crunchdao.crunch_example.iris - Iris classification utilities
    • model_base.py - Base class for iris models
    • models/ - Example model implementations (neural_network, random_forest, svm)
    • scripts/ - Utility scripts for training and model management
  • Future: crunchdao.crunch_example.forex - Forex prediction utilities
  • Future: crunchdao.crunch_example.crypto - Cryptocurrency utilities

Model Examples

The package includes complete model implementations:

  • Neural Network (models/neural_network/) - Multi-layer perceptron with sklearn
  • Random Forest (models/random_forest/) - Ensemble tree-based classifier
  • SVM (models/svm/) - Support vector machine classifier

Each model includes:

  • Pre-trained model files in resources/
  • Implementation code in submissions/main.py
  • Dependencies in submissions/requirements.txt

Utility Scripts

The scripts/ directory contains:

  • pretrain_models.py - Train all models on iris dataset
  • pretrain_neural_network.py - Specific neural network training
  • sync_models.py - Sync models with storage systems
  • cleanup_docker.py - Docker environment cleanup

Development

Requirements

  • Python 3.11+
  • uv (for dependency management)

Setup

# Clone the repository
git clone https://github.com/crunchdao/coordinator-setup
cd coordinator-setup/examples/crunch_examples

# Install dependencies
uv sync

# Install in development mode
uv pip install -e .

Testing

uv run pytest

Building

# Build the package
uv build

# Upload to PyPI (requires authentication)
uv publish

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

crunchdao_crunch_example-0.1.0.tar.gz (168.1 kB view details)

Uploaded Source

Built Distribution

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

crunchdao_crunch_example-0.1.0-py3-none-any.whl (177.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for crunchdao_crunch_example-0.1.0.tar.gz
Algorithm Hash digest
SHA256 aaaf7c9a8fd221911bd30e54837da3f8dc847347a6f59e6f9c8093a7a5731f17
MD5 04a2ebf5498db654705eed256945f7ee
BLAKE2b-256 b6a8a13cebaa3901319edb1a0b554ea3b74cf3f09ba96b62a37b736c7d843897

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for crunchdao_crunch_example-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cdd209857326e114a228550c22f8157e5711ee827566883e1dacadbc72b0cfef
MD5 7be8c560175f29ba65b30b79eecabfd5
BLAKE2b-256 9c15063286993a42f4d0ac413a92fb32325c93eb0e5c8667c54623ba3405dcb3

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