File size: 927 Bytes
78960a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# utils.py

import joblib
import json
import os
import re

def load_model(model_path):
    """Load the trained model."""
    return joblib.load(model_path)

def load_label_encoders(encoder_dir):
    """Load label encoders from JSON files."""
    encoders = {}
    for filename in os.listdir(encoder_dir):
        if filename.endswith('_label_encoder.json'):
            column = filename.replace('_label_encoder.json', '')
            with open(os.path.join(encoder_dir, filename), 'r') as file:
                encoders[column] = json.load(file)
    return encoders

def load_rules():
    """Load rule-based susceptibility rules."""
    return {
        ("ACINETOBACTER", "Aztreonam"): "Resistant",
        ("ACINETOBACTER", "Cefazolin"): "Resistant",
        # Add all other rules here...
    }

def extract_genus(organism_name):
    """Extract the genus from the organism name."""
    return organism_name.split()[0].upper()