AstroNN is an open-source software package designed to leverage neural networks for astronomical data analysis. Developed to meet the specific needs of the astronomy community, AstroNN integrates deep learning techniques with traditional astrophysical methods, providing a powerful toolset for researchers.

The primary goal of AstroNN is to facilitate the extraction of meaningful patterns and insights from large and complex astronomical datasets. It achieves this by offering pre-trained neural network models that can be applied to various types of astronomical data, such as spectra, images, and time-series data. These models are designed to handle tasks like classification, regression, and clustering, which are essential for analyzing celestial objects and phenomena.

One of the significant advantages of AstroNN is its user-friendly interface, which simplifies the process of training and applying neural networks to astronomical data. The software includes comprehensive documentation and tutorials, making it accessible to astronomers who may not have extensive experience with machine learning. This ease of use ensures that a broader range of researchers can take advantage of advanced analytical techniques without needing to become experts in artificial intelligence.

AstroNN also emphasizes flexibility and customization. Users can fine-tune the pre-trained models to suit their specific research needs or develop new models tailored to unique datasets. This adaptability allows for a wide range of applications, from studying stellar populations and galaxy formation to identifying exoplanets and understanding the large-scale structure of the universe.

The software package is continuously updated and maintained by a collaborative community of developers and researchers. This ongoing development ensures that AstroNN remains at the forefront of integrating cutting-edge machine learning techniques with astronomical research. Additionally, the open-source nature of AstroNN encourages contributions from the broader scientific community, fostering innovation and the sharing of best practices.

In summary, AstroNN is a versatile and user-friendly software package that brings the power of neural networks to astronomical data analysis. Its pre-trained models, comprehensive documentation, and customizable framework make it an invaluable tool for researchers aiming to unlock the secrets of the universe through advanced data analysis techniques.

I found a neat library for Astronomy datasets. AstroNN Is a collection of Keras-driven neural networks for astronomy data.

Getting Started

Install AstroNN

pip install astroNN matplotlib sklearn

Create a Jupyter notebook

jupyter notebook

Paste the following into the IN

%matplotlib inline
%config InlineBackend.figure_format='retina'

# import everything we need first
from tensorflow.keras import utils
import numpy as np
from sklearn.model_selection import train_test_split
import pylab as plt

from astroNN.models import Galaxy10CNN
from astroNN.datasets import galaxy10
from astroNN.datasets.galaxy10 import galaxy10cls_lookup, galaxy10_confusion

# To load images and labels (will download automatically at the first time)
# First time downloading location will be ~/.astroNN/datasets/
images, labels = galaxy10.load_data()

# To convert the labels to categorical 10 classes
labels = utils.to_categorical(labels, 10)

# Select 10 of the images to inspect
img = None
plt.ion()
print('===================Data Inspection===================')
for counter, i in enumerate(range(np.random.randint(0, labels.shape[0], size=10).shape[0])):
    img = plt.imshow(images[i])
    plt.title('Class {}: {} \n Random Demo images {} of 10'.format(np.argmax(labels[i]), galaxy10cls_lookup(labels[i]), counter+1))
    plt.draw()
    plt.pause(2.)
plt.close('all')
print('===============Data Inspection Finished===============')

# To convert to desirable type
labels = labels.astype(np.float32)
images = images.astype(np.float32)

# Split the dataset into training set and testing set
train_idx, test_idx = train_test_split(np.arange(labels.shape[0]), test_size=0.1)
train_images, train_labels, test_images, test_labels = images[train_idx], labels[train_idx], images[test_idx], labels[test_idx]

# To create a neural network instance
galaxy10net = Galaxy10CNN()

# set maximium epochs the neural network can run, set 5 to get quick result
galaxy10net.max_epochs = 5

# To train the nerual net
# astroNN will normalize the data by default
galaxy10net.train(train_images, train_labels)

# print model summary before training
galaxy10net.keras_model.summary()

# After the training, you can test the neural net performance
# Please notice predicted_labels are labels predicted from neural network. test_labels are ground truth from the dataset
predicted_labels = galaxy10net.test(test_images)

# Convert predicted_labels to class
prediction_class = np.argmax(predicted_labels, axis=1)

# Convert test_labels to class
test_class = np.argmax(test_labels, axis=1)

# Prepare a confusion matrix
confusion_matrix = np.zeros((10,10))

# create the confusion matrix
for counter, i in enumerate(prediction_class):
    confusion_matrix[i, test_class[counter]] += 1

# Plot the confusion matrix
galaxy10_confusion(confusion_matrix)