๐ง AI in healthcare diagnosticsJune 19, 2026โ
Tests passing
Rare Disease Diagnostic Assistant
A CLI tool that integrates AI diagnostic models to assist healthcare professionals in identifying rare diseases. Users can input patient medical history and lab results in a structured format, and the tool uses a pre-trained AI model to provide probabilistic diagnoses, ranked by confidence. This tool helps expedite the diagnostic process and supports decision-making in complex cases.
What It Does
- Load patient data from CSV or JSON files.
- Use a pre-trained AI model to generate diagnostic predictions.
- Save diagnostic reports in JSON format.
- Generate visualizations of diagnostic confidence for each patient.
Installation
The following Python packages are required to run the tool:
- pandas
- numpy
- matplotlib
- scikit-learn
- joblib
Install the dependencies using pip:
pip install pandas numpy matplotlib scikit-learn joblibUsage
Run the CLI tool with the following command:
python rare_disease_diagnostic_assistant.py --input <input_file> --model <model_file> --output <output_file>Arguments
--input: Path to the input patient data file (CSV or JSON).--model: Path to the pre-trained AI model file (Pickle format).--output: Path to save the diagnostic report (JSON format).
Example
python rare_disease_diagnostic_assistant.py --input patient_data.csv --model ai_model.pkl --output diagnostic_report.jsonSource Code
import argparse
import json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import joblib
from sklearn.ensemble import RandomForestClassifier
def load_model(model_path):
"""Load the pre-trained AI model."""
try:
model = joblib.load(model_path)
return model
except Exception as e:
raise ValueError(f"Error loading model: {e}")
def load_patient_data(input_path):
"""Load patient data from a CSV or JSON file."""
try:
if input_path.endswith('.csv'):
return pd.read_csv(input_path)
elif input_path.endswith('.json'):
return pd.read_json(input_path)
else:
raise ValueError("Unsupported file format. Use CSV or JSON.")
except Exception as e:
raise ValueError(f"Error loading input data: {e}")
def generate_diagnostic_report(model, patient_data):
"""Generate diagnostic predictions and confidence scores."""
try:
predictions = model.predict_proba(patient_data)
classes = model.classes_
results = []
for i, probs in enumerate(predictions):
patient_result = {
"patient_id": patient_data.index[i],
"diagnoses": [
{"disease": classes[j], "confidence": float(probs[j])}
for j in np.argsort(probs)[::-1]
]
}
results.append(patient_result)
return results
except Exception as e:
raise ValueError(f"Error generating diagnostic report: {e}")
def save_report(report, output_path):
"""Save the diagnostic report to a JSON file."""
try:
with open(output_path, 'w') as f:
json.dump(report, f, indent=4)
except Exception as e:
raise ValueError(f"Error saving report: {e}")
def plot_diagnostics(report, output_path):
"""Generate and save diagnostic visualizations."""
try:
for patient in report:
patient_id = patient['patient_id']
diagnoses = patient['diagnoses'][:5] # Top 5 diagnoses
diseases = [d['disease'] for d in diagnoses]
confidences = [d['confidence'] for d in diagnoses]
plt.figure(figsize=(10, 6))
plt.barh(diseases, confidences, color='skyblue')
plt.xlabel('Confidence')
plt.title(f'Diagnostic Confidence for Patient {patient_id}')
plt.gca().invert_yaxis()
plt.tight_layout()
plt.savefig(f"{output_path}_patient_{patient_id}.png")
plt.close()
except Exception as e:
raise ValueError(f"Error generating plots: {e}")
def main():
parser = argparse.ArgumentParser(description="Rare Disease Diagnostic Assistant")
parser.add_argument('--input', required=True, help="Path to input patient data (CSV or JSON)")
parser.add_argument('--model', required=True, help="Path to pre-trained AI model (Pickle file)")
parser.add_argument('--output', required=True, help="Path to save the diagnostic report (JSON file)")
args = parser.parse_args()
try:
# Load model and data
model = load_model(args.model)
patient_data = load_patient_data(args.input)
# Generate diagnostic report
report = generate_diagnostic_report(model, patient_data)
# Save report
save_report(report, args.output)
# Generate and save visualizations
plot_diagnostics(report, args.output)
print(f"Diagnostic report and visualizations saved successfully to {args.output}")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- rare_disease_diagnostic_assistant
- Category
- AI in healthcare diagnostics
- Generated
- June 19, 2026
- Tests
- Passing โ
- Fix Loops
- 2
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-06-19/rare_disease_diagnostic_assistant cd generated_tools/2026-06-19/rare_disease_diagnostic_assistant pip install -r requirements.txt 2>/dev/null || true python rare_disease_diagnostic_assistant.py