Our Blog

Latest News

Radial Velocity: Predicting Exoplanetary Albedo with Neural Networks

The following code is a Python script that uses a neural network to predict exoplanetary albedo based on features such as exoplanetary mass, radius, and atmospheric composition. The script is designed to be run in a Jupyter notebook or a Python IDE.

The script begins by importing the necessary libraries, including Pandas for loading and manipulating the data, Matplotlib for visualizing the results, and scikit-learn for preprocessing the data and evaluating the model’s performance. The script also imports the necessary functions from TensorFlow’s keras module for building and training the neural network model.

Next, the script defines a preprocessing function called process_atmospheric_composition() which takes in a string containing a list of integers and returns the mean of the integers as a numerical representation of the exoplanetary atmospheric composition.

The script then loads the exoplanet data from a CSV file using Pandas and preprocesses the data by applying the process_atmospheric_composition() function to the exoplanetary atmospheric composition data and scaling the resulting data using scikit-learn’s StandardScaler. The preprocessed data is then split into training and test sets using scikit-learn’s train_test_split() function.

The script then defines a neural network model using the TensorFlow Sequential class and Dense layers. The model is compiled using the TensorFlow compile() function, specifying the loss function and optimization algorithm to use during training.

The model is then trained on the training data using the TensorFlow fit() function and the training and validation loss is plotted using Matplotlib. The model’s performance is also evaluated on the test data using the TensorFlow evaluate() function and the mean squared error (MSE), root mean squared error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) are calculated using scikit-learn’s mean_squared_error(), mean_absolute_error(), and mean_absolute_percentage_error() functions.

Finally, the script generates predictions on the test data using the TensorFlow predict() function and plots the predictions against the true values using Matplotlib.

Overall, this script demonstrates how to use a neural network to predict exoplanetary albedo based on exoplanetary mass, radius, and atmospheric composition data. It also shows how to preprocess the data, split it into training and test sets, build and train a neural network model, evaluate the model’s performance, and generate predictions on new data.

One important thing to note is that the model’s performance may vary depending on the specific characteristics of the data and the chosen model hyperparameters, such as the number of layers, the number of neurons per layer, and the learning rate. It is always a good idea to experiment with different model architectures and hyperparameter settings to find the combination that works best for your data.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jan  2 05:49:38 2023

@author: ramnot
"""

# Import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import re
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import mean_squared_error, mean_absolute_error, mean_absolute_percentage_error
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense

# Preprocessing function for exoplanetary atmospheric composition data
def process_atmospheric_composition(composition):
    # Extract integers from string
    integers = [int(x) for x in re.findall(r'\d+', composition)]
    
    # Calculate mean of integers
    mean = sum(integers) / len(integers)
    
    return mean

# Load data
df = pd.read_csv("data.csv")

# Preprocess data
X = df[["exoplanetary mass", "exoplanetary radius"]]
X["exoplanetary atmospheric composition"] = df["exoplanetary atmospheric composition"].apply(process_atmospheric_composition)
y = df["exoplanetary albedo"]

scaler = StandardScaler()
X = scaler.fit_transform(X)

# Split data into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# Define model architecture
model = Sequential()
model.add(Dense(64, input_dim=3, activation="relu"))
model.add(Dense(32, activation="relu"))
model.add(Dense(1))

# Compile model
model.compile(loss="mean_squared_error", optimizer="adam")

# Train model
history = model.fit(X_train, y_train, epochs=10, batch_size=32, validation_data=(X_test, y_test))

# Generate predictions on test data
predictions = model.predict(X_test)

# Calculate evaluation metrics
mse = mean_squared_error(y_test, predictions)
rmse = np.sqrt(mse)
mae = mean_absolute_error(y_test, predictions)
mape = mean_absolute_percentage_error(y_test, predictions)

# Print evaluation metrics
print("MSE:", mse)
print("RMSE:", rmse)
print("MAE:", mae)
print("MAPE:", mape)

# Evaluate model
score = model.evaluate(X_test, y_test)
print("Test loss:", score)

# Plot predictions against true values
plt.plot(y_test, predictions, "o")
plt.xlabel("True values")
plt.ylabel("Predictions")
plt.show()

RAMNOT’s Build:

  1. Predicting exoplanetary albedo: The code can be used to predict the albedo of exoplanets based on features such as mass, radius, and atmospheric composition. This can help astronomers understand the physical properties of exoplanets and their potential habitability.
  2. Identifying exoplanets with high albedo: By generating predictions on a large dataset of exoplanets, the code can be used to identify exoplanets with high albedo, which may be more likely to be rocky and/or have a thick atmosphere.
  3. Comparing exoplanetary albedo to other physical properties: By visualizing the predicted exoplanetary albedo against other physical properties, such as mass, radius, and atmospheric composition, the code can help astronomers investigate potential correlations and relationships between these properties.
  4. Classifying exoplanets based on albedo: The code can be used to classify exoplanets into different albedo categories (e.g. high, medium, low) based on their predicted albedo values. This can help astronomers group exoplanets with similar physical properties and study them in more detail.
  5. Improving exoplanetary albedo models: The code can be used as a starting point for developing more sophisticated exoplanetary albedo models that incorporate additional features or use different machine learning algorithms.
  6. Validating exoplanetary albedo measurements: By comparing the predictions of the code to measured exoplanetary albedo values, astronomers can validate the accuracy of their measurements and identify any potential biases or errors in their data.
  7. Predicting exoplanetary temperatures: By using the exoplanetary albedo and other physical properties as inputs, the code can be modified to predict the surface temperature of exoplanets, which can help astronomers understand their potential habitability.
  8. Selecting exoplanets for further study: By using the code to identify exoplanets with high albedo or other desired physical properties, astronomers can prioritize exoplanets for further study using telescopes or other observational instruments.
  9. Identifying exoplanets with unusual physical properties: By generating predictions on a large dataset of exoplanets, the code can help astronomers identify exoplanets with unusual physical properties that may require further investigation.
  10. Improving exoplanetary atmospheric models: By incorporating exoplanetary albedo as a feature in atmospheric models, astronomers can improve the accuracy of their models and better understand the physical processes occurring on exoplanets.
Progress: Radial Velocity: Using Machine Learning to Analyze Exoplanetary Data
Radial Velocity: Predicting Exoplanetary Orbit Periods using a Decision Tree Model in Python