Janet Garcia commited on
Commit
0e490ce
·
0 Parent(s):

Initial commit

Browse files
Files changed (4) hide show
  1. .gitignore +35 -0
  2. README.md +0 -0
  3. app.py +48 -0
  4. requirements.txt +6 -0
.gitignore ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.so
4
+
5
+ # Virtual environments & local tooling
6
+ venv/
7
+ .venv/
8
+ env/
9
+ ENV/
10
+ .env
11
+ .env.*
12
+ pip-wheel-metadata/
13
+
14
+ # Build / packaging artifacts
15
+ *.egg-info/
16
+ dist/
17
+ build/
18
+
19
+ # Notebooks & test caches
20
+ .ipynb_checkpoints/
21
+ .pytest_cache/
22
+ .mypy_cache/
23
+ .ruff_cache/
24
+
25
+ # Coverage & log files
26
+ .coverage
27
+ coverage.xml
28
+ htmlcov/
29
+ *.log
30
+
31
+ # OS cruft
32
+ .DS_Store
33
+
34
+ # Hugging Face cache (set HF_HOME outside repo when possible)
35
+ .cache/huggingface/
README.md ADDED
File without changes
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import joblib
3
+ import pandas as pd
4
+ from huggingface_hub import hf_hub_download # NEW IMPORT
5
+
6
+ # Features used by your model
7
+ FEATURES = ["koi_period", "koi_duration", "koi_prad", "koi_depth"]
8
+
9
+ # Download the model from Hugging Face Hub
10
+ model_path = hf_hub_download(
11
+ repo_id="h0ntas/exo5",
12
+ filename="model.joblib"
13
+ )
14
+
15
+ # Load the downloaded model
16
+ model = joblib.load(model_path)
17
+
18
+
19
+ def predict(koi_period, koi_duration, koi_prad, koi_depth):
20
+ # Build a one-row DataFrame with the right column names
21
+ X = pd.DataFrame(
22
+ [[koi_period, koi_duration, koi_prad, koi_depth]],
23
+ columns=FEATURES
24
+ )
25
+
26
+ # Get the predicted class (0 or 1)
27
+ y = model.predict(X)[0]
28
+
29
+ # Try to get predicted probability if the model supports it
30
+ try:
31
+ p = model.predict_proba(X)[0][1]
32
+ label = "Candidate exoplanet" if int(y) == 1 else "Likely false positive"
33
+ return f"{label} | probability: {p:.2f}"
34
+ except Exception:
35
+ return "Candidate exoplanet" if int(y) == 1 else "Likely false positive"
36
+
37
+
38
+ # Gradio interface
39
+ demo = gr.Interface(
40
+ fn=predict,
41
+ inputs=[gr.Number(label=f) for f in FEATURES],
42
+ outputs=gr.Textbox(label="Prediction"),
43
+ title="Exoplanet Transit Classifier",
44
+ description="Enter KOI features to get a quick classification."
45
+ )
46
+
47
+ if __name__ == "__main__":
48
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio
2
+ scikit-learn
3
+ joblib
4
+ numpy
5
+ pandas
6
+ huggingface_hub