UFO-web / app.py
Coco-Spot
Deploy UFO app to Hugging Face Space
3b317d3
Raw
History Blame Contribute Delete
1.06 kB
import pickle
from pathlib import Path
import pandas as pd
import streamlit as st
MODEL_PATH = Path(__file__).with_name("ufo-model.pkl")
COUNTRIES = ["Australia", "Canada", "Germany", "UK", "US"]
FEATURE_COLUMNS = ["Seconds", "Latitude", "Longitude"]
@st.cache_resource
def load_model():
with MODEL_PATH.open("rb") as model_file:
return pickle.load(model_file)
st.set_page_config(page_title="UFO Predictor", layout="centered")
st.title("UFO Country Predictor")
st.write("Predict the likely reporting country from sighting duration and coordinates.")
seconds = st.number_input("Seconds", min_value=1.0, max_value=60.0, value=10.0)
latitude = st.number_input("Latitude", value=44.0)
longitude = st.number_input("Longitude", value=-12.0)
if st.button("Predict"):
model = load_model()
features = pd.DataFrame(
[[seconds, latitude, longitude]],
columns=FEATURE_COLUMNS,
)
class_id = int(model.predict(features)[0])
st.success(f"Likely country: {COUNTRIES[class_id]}")
st.caption(f"Class id: {class_id}")