Skip to main content

Astronomical Data Science and Machine Learning Toolkit

Project description

spacekit

Powered by Astropy GitHub repo size GitHub license

Astronomical Data Science and Machine Learning Toolkit

spacekit
└── spacekit
    └── analyzer
        └── compute.py
        └── explore.py
        └── track.py
    └── builder
        └── cnn.py
    └── extractor
        └── draw_mosaics.py
        └── frame_data.py
        └── load_images.py
        └── scrape_json.py
    └── preprocessor
        └── augment.py
        └── radio.py
        └── transform.py
    └── skopes
        └── hst
            └── mosaic
                    └── svm_corrupt.py
                    └── svm_predict.py
                    └── svm_train.py
                    └── models
└── setup.py
└── tests
└── LICENSE
└── README.md

Setup

Install with pip

$ pip install spacekit

Install from source

$ git clone https://github.com/alphasentaurii/spacekit
$ cd spacekit
$ pip install -e .

Run

Example: HST Single Visit Mosaic Alignment Classification

Classify new data using pre-trained model:

  1. Preprocess data (scrape from regression test json and fits files)

from the command line

$ python -m spacekit.extractor.frame_data path/to/svmdata -o=./newdata.csv
  1. Preprocess images (generate png preview files)
python -m spacekit.extractor.draw_mosaics path/to/svmdata -o=./img
  1. Generate predictions
$ python -m spacekit.skopes.hst.mosaic.svm_predict ./mydata.csv ./img -m=./models/ensembleSVM -o=./results

Build, train, evaluate new classifier from labeled data

Run steps 1 and 2 above, then:

# Note: there are several option flags you can also include in this command
$ python -m spacekit.skopes.hst.mosaic.svm_train ./mydata.csv ./img

Python

# import spacekit training submodule
from spacekit.skopes.hst.mosaic.svm_train import prep_ensemble_data, train_model, compute_results
# initialize some vars
training_data = "labeled_data.csv" # preprocessed dataframe (see step 1 above)
img_path = "./img" # preprocessed PNG image files (see step 2 above)
model_name = "my_new_model_name" # give the model a custom name (optional)
res_path = "./results" # where to save the model training results (optional)
# training parameters (optional - uses these defaults if none are explicitly set)
params=dict(
    batch_size=32,
    epochs=60, # set to 1 or 5 if just testing functionality...or 1000 if you have all day
    lr=1e-4,
    decay=[100000, 0.96],
    early_stopping=None,
    verbose=2,
    ensemble=True
    )
# create train test val splits, test-val index (for reviewing names of images model gets wrong)
tv_idx, XTR, YTR, XTS, YTS, XVL, YVL = prep_ensemble_data(training_data, img_path)
# train the model
ens_model, ens_history = train_model(XTR, YTR, XTS, YTS, model_name)
# evaluate results (saved to local pickle files for later analysis)
compute_results(ens_model, ens_history, model_name, tv_idx, XTR, YTR, XTS, YTS, XVL, YVL)
                       
           /\    _       _                           _                      *  
/\_/\_____/  \__| |_____| |_________________________| |___________________*___
[===]    / /\ \ | |  _  |  _  | _  \/ __/ -__|  \| \_  _/ _  \ \_/ | * _/| | |
 \./    /_/  \_\|_|  ___|_| |_|__/\_\ \ \____|_|\__| \__/__/\_\___/|_|\_\|_|_|
                  | /             |___/        
                  |/   

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

spacekit-0.2.4.tar.gz (62.6 kB view hashes)

Uploaded Source

Built Distribution

spacekit-0.2.4-py3-none-any.whl (50.9 kB view hashes)

Uploaded Python 3

Supported by

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