Spaces:
Sleeping
Sleeping
Commit ·
cce95b5
1
Parent(s): adf3172
fix: move future import to the top for Python syntax compliance
Browse files- app/app.py +1 -16
app/app.py
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
st.title("Twitter Sentiment Intelligence")
|
| 4 |
-
|
| 5 |
try:
|
| 6 |
# Main app logic
|
| 7 |
"""Streamlit front-end for the Deloitte-ready Twitter Sentiment Intelligence dashboard."""
|
| 8 |
-
|
| 9 |
-
from __future__ import annotations
|
| 10 |
-
|
| 11 |
import json
|
| 12 |
import sys
|
| 13 |
from pathlib import Path
|
| 14 |
from typing import Dict
|
| 15 |
-
|
| 16 |
import pandas as pd
|
| 17 |
-
|
| 18 |
# -------------------------------------------------------------------------
|
| 19 |
# Path setup to include the local src/ package for imports
|
| 20 |
# -------------------------------------------------------------------------
|
|
@@ -22,10 +16,8 @@ try:
|
|
| 22 |
SRC_PATH = ROOT / "src"
|
| 23 |
if str(SRC_PATH) not in sys.path:
|
| 24 |
sys.path.insert(0, str(SRC_PATH))
|
| 25 |
-
|
| 26 |
from twitter_sentiment.config import load_config
|
| 27 |
from twitter_sentiment.predictor import load_artifacts, predict_with_threshold
|
| 28 |
-
|
| 29 |
# -------------------------------------------------------------------------
|
| 30 |
# Streamlit App Configuration
|
| 31 |
# -------------------------------------------------------------------------
|
|
@@ -34,7 +26,6 @@ try:
|
|
| 34 |
page_icon="💼",
|
| 35 |
layout="wide",
|
| 36 |
)
|
| 37 |
-
|
| 38 |
# -------------------------------------------------------------------------
|
| 39 |
# Cached resource loading (config, pipeline, metrics)
|
| 40 |
# NOTE: artifacts/sentiment_pipeline.joblib is referenced relatively
|
|
@@ -47,8 +38,6 @@ try:
|
|
| 47 |
# The load_artifacts function references 'artifacts/sentiment_pipeline.joblib' relatively
|
| 48 |
pipeline, metrics = load_artifacts(config)
|
| 49 |
return config, pipeline, metrics
|
| 50 |
-
|
| 51 |
-
|
| 52 |
# -------------------------------------------------------------------------
|
| 53 |
# Helper function to format prediction probabilities
|
| 54 |
# -------------------------------------------------------------------------
|
|
@@ -59,8 +48,6 @@ try:
|
|
| 59 |
.sort_values("confidence", ascending=False)
|
| 60 |
.style.format({"confidence": "{:.2%}"})
|
| 61 |
)
|
| 62 |
-
|
| 63 |
-
|
| 64 |
# -------------------------------------------------------------------------
|
| 65 |
# Main Streamlit Application
|
| 66 |
# -------------------------------------------------------------------------
|
|
@@ -69,9 +56,7 @@ try:
|
|
| 69 |
config, pipeline, metrics = _load_dependencies()
|
| 70 |
# Main application logic continues here
|
| 71 |
pass
|
| 72 |
-
|
| 73 |
if __name__ == "__main__":
|
| 74 |
main()
|
| 75 |
-
|
| 76 |
except Exception as e:
|
| 77 |
st.error(f"Startup failed: {e}")
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
import streamlit as st
|
|
|
|
| 3 |
st.title("Twitter Sentiment Intelligence")
|
|
|
|
| 4 |
try:
|
| 5 |
# Main app logic
|
| 6 |
"""Streamlit front-end for the Deloitte-ready Twitter Sentiment Intelligence dashboard."""
|
|
|
|
|
|
|
|
|
|
| 7 |
import json
|
| 8 |
import sys
|
| 9 |
from pathlib import Path
|
| 10 |
from typing import Dict
|
|
|
|
| 11 |
import pandas as pd
|
|
|
|
| 12 |
# -------------------------------------------------------------------------
|
| 13 |
# Path setup to include the local src/ package for imports
|
| 14 |
# -------------------------------------------------------------------------
|
|
|
|
| 16 |
SRC_PATH = ROOT / "src"
|
| 17 |
if str(SRC_PATH) not in sys.path:
|
| 18 |
sys.path.insert(0, str(SRC_PATH))
|
|
|
|
| 19 |
from twitter_sentiment.config import load_config
|
| 20 |
from twitter_sentiment.predictor import load_artifacts, predict_with_threshold
|
|
|
|
| 21 |
# -------------------------------------------------------------------------
|
| 22 |
# Streamlit App Configuration
|
| 23 |
# -------------------------------------------------------------------------
|
|
|
|
| 26 |
page_icon="💼",
|
| 27 |
layout="wide",
|
| 28 |
)
|
|
|
|
| 29 |
# -------------------------------------------------------------------------
|
| 30 |
# Cached resource loading (config, pipeline, metrics)
|
| 31 |
# NOTE: artifacts/sentiment_pipeline.joblib is referenced relatively
|
|
|
|
| 38 |
# The load_artifacts function references 'artifacts/sentiment_pipeline.joblib' relatively
|
| 39 |
pipeline, metrics = load_artifacts(config)
|
| 40 |
return config, pipeline, metrics
|
|
|
|
|
|
|
| 41 |
# -------------------------------------------------------------------------
|
| 42 |
# Helper function to format prediction probabilities
|
| 43 |
# -------------------------------------------------------------------------
|
|
|
|
| 48 |
.sort_values("confidence", ascending=False)
|
| 49 |
.style.format({"confidence": "{:.2%}"})
|
| 50 |
)
|
|
|
|
|
|
|
| 51 |
# -------------------------------------------------------------------------
|
| 52 |
# Main Streamlit Application
|
| 53 |
# -------------------------------------------------------------------------
|
|
|
|
| 56 |
config, pipeline, metrics = _load_dependencies()
|
| 57 |
# Main application logic continues here
|
| 58 |
pass
|
|
|
|
| 59 |
if __name__ == "__main__":
|
| 60 |
main()
|
|
|
|
| 61 |
except Exception as e:
|
| 62 |
st.error(f"Startup failed: {e}")
|