Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ class ModelTrainingInput(ResearchInput):
|
|
45 |
class DataAnalyzer(ABC):
|
46 |
"""Abstract base class for data analysis modules"""
|
47 |
@abstractmethod
|
48 |
-
def invoke(self, **kwargs) -> Dict[str, Any]:
|
49 |
pass
|
50 |
|
51 |
# ---------------------- Concrete Analyzer Implementations ---------------------------
|
@@ -323,7 +323,10 @@ class AutomatedInsights():
|
|
323 |
for name in analysis_names:
|
324 |
if name in self.analyses:
|
325 |
analyzer = self.analyses[name]
|
326 |
-
|
|
|
|
|
|
|
327 |
else:
|
328 |
results[name] = {"error": "Analysis not found"}
|
329 |
return results
|
@@ -661,7 +664,7 @@ def main():
|
|
661 |
result = st.session_state.kpi_monitoring.calculate_kpis(data)
|
662 |
st.json(result)
|
663 |
with insights_tab:
|
664 |
-
|
665 |
data = st.session_state.data[selected_data_key]
|
666 |
available_analysis = ["EDA", "temporal", "distribution", "hypothesis", "model"]
|
667 |
selected_analysis = st.multiselect("Select Analysis", available_analysis)
|
@@ -685,28 +688,4 @@ def main():
|
|
685 |
if st.button("Generate Treatment Recommendation"):
|
686 |
if condition_col and treatment_col:
|
687 |
with st.spinner("Generating Treatment Recommendation"):
|
688 |
-
result = st.session_state.treatment_recommendation.recommend(data, condition_col = condition_col
|
689 |
-
st.json(result)
|
690 |
-
|
691 |
-
with reports_tab:
|
692 |
-
st.header("Reports")
|
693 |
-
report_name = st.text_input("Report Name")
|
694 |
-
report_def = st.text_area("Report definition")
|
695 |
-
if st.button("Create Report Definition"):
|
696 |
-
st.session_state.automated_reports.create_report_definition(report_name, report_def)
|
697 |
-
st.success("Report definition created")
|
698 |
-
if selected_data_key:
|
699 |
-
data = st.session_state.data
|
700 |
-
if st.button("Generate Report"):
|
701 |
-
with st.spinner("Generating Report..."):
|
702 |
-
report = st.session_state.automated_reports.generate_report(report_name, data)
|
703 |
-
with knowledge_tab:
|
704 |
-
st.header("Medical Knowledge")
|
705 |
-
query = st.text_input("Enter your medical question here:")
|
706 |
-
if st.button("Search"):
|
707 |
-
with st.spinner("Searching..."):
|
708 |
-
result = st.session_state.knowledge_base.search_medical_info(query)
|
709 |
-
st.write(result)
|
710 |
-
|
711 |
-
if __name__ == "__main__":
|
712 |
-
main()
|
|
|
45 |
class DataAnalyzer(ABC):
|
46 |
"""Abstract base class for data analysis modules"""
|
47 |
@abstractmethod
|
48 |
+
def invoke(self, data:pd.DataFrame, **kwargs) -> Dict[str, Any]:
|
49 |
pass
|
50 |
|
51 |
# ---------------------- Concrete Analyzer Implementations ---------------------------
|
|
|
323 |
for name in analysis_names:
|
324 |
if name in self.analyses:
|
325 |
analyzer = self.analyses[name]
|
326 |
+
try:
|
327 |
+
results[name] = analyzer.invoke(data=data, **kwargs)
|
328 |
+
except Exception as e:
|
329 |
+
results[name] = {"error": str(e)}
|
330 |
else:
|
331 |
results[name] = {"error": "Analysis not found"}
|
332 |
return results
|
|
|
664 |
result = st.session_state.kpi_monitoring.calculate_kpis(data)
|
665 |
st.json(result)
|
666 |
with insights_tab:
|
667 |
+
if selected_data_key:
|
668 |
data = st.session_state.data[selected_data_key]
|
669 |
available_analysis = ["EDA", "temporal", "distribution", "hypothesis", "model"]
|
670 |
selected_analysis = st.multiselect("Select Analysis", available_analysis)
|
|
|
688 |
if st.button("Generate Treatment Recommendation"):
|
689 |
if condition_col and treatment_col:
|
690 |
with st.spinner("Generating Treatment Recommendation"):
|
691 |
+
result = st.session_state.treatment_recommendation.recommend(data, condition_col = condition_col
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|