-
Notifications
You must be signed in to change notification settings - Fork 11
Description
Issue Description:
Currently, Stingray.jl lacks an automated mechanism to detect anomalies in astronomical time series data. This feature would be useful for identifying rare astrophysical events, such as unexpected X-ray bursts or irregular pulsar behavior.
Adding machine learning-based anomaly detection would enhance the software’s capabilities by automating the detection of unusual patterns in light curves.
Proposed Solution:
Integrate an Autoencoder-based anomaly detection model using Flux.jl.
Train the model on historical astronomical datasets to learn normal patterns.
Flag outliers that deviate significantly from expected behavior.
using Flux, Random
Simulated Light Curve Data (10 features)
X_train = rand(100, 10) # Training data
X_test = rand(10, 10) # Test data with potential anomalies
Define Autoencoder Model
encoder = Chain(Dense(10, 5, relu), Dense(5, 2, relu))
decoder = Chain(Dense(2, 5, relu), Dense(5, 10, relu))
autoencoder = Chain(encoder, decoder)
Loss Function (Mean Squared Error)
loss(x) = Flux.mse(autoencoder(x), x)
Training Process
opt = Flux.ADAM(0.01)
for epoch in 1:100
Flux.train!(loss, Flux.params(autoencoder), [(X_train,)], opt)
end
Test the model
reconstructed = autoencoder(X_test)
anomaly_scores = sum(abs.(X_test .- reconstructed), dims=2) # Compute anomaly scores
Flag anomalies based on threshold
threshold = quantile(anomaly_scores, 0.95)
anomalies = anomaly_scores .> threshold
println("Anomalies detected: ", anomalies)
Next Steps:
Refine the model using real astrophysical data from NASA HEASARC.
Implement visualization tools to highlight detected anomalies.
Optimize for efficiency in large datasets.