Coder Social home page Coder Social logo

ml-accreted-vs-insitu's Introduction

This repository contains the codes and machine learning models developed for separating accreted and in-situ stars in Milky Way-like galaxies. These are defined as disc galaxies (corotational parameter ε > 0.5) within a dark matter halo of mass M200 ~ 1012 M.

The available models are:

  • multilayer perceptron (MLP);

  • MLP with galaxy features;

  • transformational machine learning (TML), based on an ensemble of MLPs;

  • XGBoost.

All models can be found in the implementations developed using both ARTEMIS and Auriga data.

The codes for the training and optimisation of the models are reported in codes for reference.

Main Advantages

Compared to traditional selection criteria, machine learning models provide:

  1. more realistic description of the distribution of accreted stars in the galaxy;

  2. higher purity in the retrieved sample of accreted stars;

  3. adjustable classification threshold, which allows the user to decide whether to focus on the purity or completeness of the accreted stars sample.

image

The performance of the models might vary depending on the data they are applied on. The MLP developed on ARTEMIS data is shown to be the most robust in terms of performance.

Dependencies

The following list of packages is required to use the models:

  • joblib (recommended version: 1.2.0)

  • numpy (reccommended version: 1.24.3)

  • tensorflow (recommended version: 2.13.0)

Get Started

  1. Clone this repository
git clone https://github.com/ariasant/ML-accreted-vs-insitu.git
  1. OPTIONAL: Add the path of the repository to your python path

Ex: for MAC and Linux distributions add this in you .bashrc file:

export PYTHONPATH="${PYTHONPATH}:/path/to/this/repository"
  1. Create a virtual environment with all the dependencies

Ex: using conda:

conda create -n foo python=3.9.16 joblib=1.2.0 numpy=1.24.3 tensorflow=2.13.0
  1. Activate the environment

Ex: using conda:

conda activate path/to/environemnt/foo
  1. Import the model you want to use

Inside your favourite Python development environment:

from models import MLP_ARTEMIS

model = MLP_ARTEMIS()

  1. Load data

Define your array of input data making sure to follow the indications in the documentation.

  1. Get predictions
predictions = model.predict(previously_loaded_data,
                            threshold=0.5
)

Documentation

The machine learning models have been trained using specific vectors of stellar properties for the star particles in the ARTEMIS and Auriga simulations. When the models are applied to new data, it is crucial to provide them in the order and units specified in the documentation of each model.

Feature Description Units

Stellar Properties

R Galactocentric radius in the plane of the disc. kpc
z Distance from the plane of the disc. kpc
vθ Velocity in the direction of disc rotation. kms-1
σ Dispersion velocity in the plane perpendicular to the disc. kms-1
[Fe/H] Iron-to-hydrogen abundance. -
[α/Fe] α-to-iron abundance. -
MG Absolute magnitude in the Gaia MG passband. -
BP-RP Colour evaluated in the Gaia GBP and GRP passbands. -

Galaxy Properties

κco Co-rotational parameter. -
M* Total stellar mass within 30 kpc radius. 1010 M
r1/2 Half-radius. kpc
vθ MAX Maximum rotational velocity within 30 kpc radius. kms-1
〈[Fe/H]〉 Average iron-to-idrogen abundance. -
〈[α/H]〉 Average α-to-idrogen abundance. -

MLP_ARTEMIS, MLP_Auriga

These are subclasses of tensorflow.keras.Model objects. The models have been trained on stellar properties only. Method:

predict

.predict(x,
         threshold=None
         )
Args

x

Numpy array of N stars with shape (N,8)

Order: R, z, vθ, σ, [Fe/H], [α/Fe], MG, BP-RP

threshold

"None" or float between 0 and 1. The classification threshold used for separating accreted and in-situ stars.

Returns

Numpy array of class predictions: 0 -> In-situ, 1-> Accreted.

If threshold=None, the probabilities of stars belonging to the accreted class are returned.

MLP_galaxy_features_ARTEMIS, MLP_galaxy_features_Auriga

These are subclasses of tensorflow.keras.Model objects. The models have been trained on stellar properties and on general properties of the associated galaxies. Method:

predict

.predict(x,
         threshold=None
         )
Args

x

Numpy array of N stars with shape (N,8)

Order: R, z, vθ, σ, [Fe/H], [α/Fe], MG, BP-RP, Mstar, r1/2, vθMAX, 〈[Fe/H]〉, 〈[α/H]〉

threshold

"None" or float between 0 and 1. The classification threshold used for separating accreted and in-situ stars.

Returns

Numpy array of class predictions: 0 -> In-situ, 1-> Accreted.

If threshold=None, the probabilities of stars belonging to the accreted class are returned.

TML_ARTEMIS, TML_Auriga

These are subclasses of tensorflow.keras.Model objects. The models are based on an ensemble of MLPs, each of which is tensorflow.keras.Model object. During the prediction, x is passed to each MLP in the ensemble. The resulting ensemble of predictions is then used as an input to another MLP. Method:

.predict(x,
         threshold=None
         )
Args

x

Numpy array of N stars with shape (N,8)

Order: R, z, vθ, σ, [Fe/H], [α/Fe], MG, BP-RP

threshold

"None" or float between 0 and 1. The classification threshold used for separating accreted and in-situ stars.

Returns

Numpy array of class predictions: 0 -> In-situ, 1-> Accreted.

If threshold=None, the probabilities of stars belonging to the accreted class are returned.

xgb_ARTEMIS, xgb_Auriga

These are trained instances of the xgboost.XGBClassifier object. Method:

.predict(x,
         threshold=None
         )
Args

x

Numpy array of N stars with shape (N,8)

Order: R, z, vθ, σ, [Fe/H], [α/Fe], MG, BP-RP

threshold

"None" or float between 0 and 1. The classification threshold used for separating accreted and in-situ stars.

Returns

Numpy array of class predictions: 0 -> In-situ, 1-> Accreted.

If threshold=None, the probabilities of stars belonging to the accreted class are returned.

Reference Paper

ml-accreted-vs-insitu's People

Contributors

ariasant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.