Spaces:
Sleeping
Sleeping
Update logic/nlp_report.py
Browse files- logic/nlp_report.py +21 -1
logic/nlp_report.py
CHANGED
@@ -15,7 +15,7 @@ model_path = hf_hub_download(
|
|
15 |
|
16 |
llm = Llama(
|
17 |
model_path=model_path,
|
18 |
-
n_ctx=
|
19 |
chat_format="chatml",
|
20 |
verbose=False
|
21 |
)
|
@@ -72,3 +72,23 @@ Write a concise and insightful clinical summary, including key gaps and social c
|
|
72 |
except Exception as e:
|
73 |
logging.error(f"LLM error: {e}")
|
74 |
return "[Error generating summary]"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
llm = Llama(
|
17 |
model_path=model_path,
|
18 |
+
n_ctx=2048,
|
19 |
chat_format="chatml",
|
20 |
verbose=False
|
21 |
)
|
|
|
72 |
except Exception as e:
|
73 |
logging.error(f"LLM error: {e}")
|
74 |
return "[Error generating summary]"
|
75 |
+
|
76 |
+
# Additional: Quality validation helper for UI feedback
|
77 |
+
|
78 |
+
def summarize_data_quality(df):
|
79 |
+
issues = []
|
80 |
+
required_cols = ['patient_id', 'age', 'gender', 'hcc_codes']
|
81 |
+
for col in required_cols:
|
82 |
+
if col not in df.columns:
|
83 |
+
issues.append(f"Missing column: {col}")
|
84 |
+
elif df[col].isnull().any():
|
85 |
+
issues.append(f"Null values in column: {col}")
|
86 |
+
|
87 |
+
percent_missing = df.isnull().mean().round(2) * 100
|
88 |
+
high_missing = percent_missing[percent_missing > 30].to_dict()
|
89 |
+
if high_missing:
|
90 |
+
for col, pct in high_missing.items():
|
91 |
+
issues.append(f"Over 30% missing in: {col} ({pct:.0f}%)")
|
92 |
+
|
93 |
+
summary_df = pd.DataFrame({"Issues": issues})
|
94 |
+
return summary_df
|