def calc_risk_score_infection(*argv): language = argv[0] default = html.H4(languages["results_card_infection"][language][0], className="score-calculator-card-content-infection"), submit = argv[1] labs = argv[2] feats = argv[3:-1] temp_unit = argv[-1] if not labs and oxygen_in_infec: feats = switch_oxygen(feats, oxygen_infec_ind) #if submit button was clicked if submit > 0: x = feats if labs: valid, err, x = valid_input(labs_features["numeric"], x[0], len(labs_features["numeric"]), language) else: valid, err, x = valid_input(no_labs_features["numeric"], x[0], len(no_labs_features["numeric"]), language) if valid: if labs: score, imputed, fig = predict_risk_infec( labs_cols, labs_model, labs_features, labs_imputer, labs_explainer, x, temp_unit, languages["results_card_infection"][language], language) else: score, imputed, fig = predict_risk_infec( no_labs_cols, no_labs_model, no_labs_features, no_labs_imputer, no_labs_explainer, x, temp_unit, languages["results_card_infection"][language], language) if fig: image = display_fig_infec(fig) else: image = '' return score, '', imputed, image, { "height": 200 }, languages["visual_1"][language] else: return default, err, '', '', {}, '' #user has not clicked submit return default, '', '', '', {}, ''
def valid_input_mort(labs, feature_vals, language): if labs: features = labs_features_mort imputer = labs_imputer_mort else: features = no_labs_features_mort imputer = no_labs_imputer_mort length = len(features["numeric"]) return valid_input(features["numeric"], feature_vals[0], length, language)
def valid_input_infec(labs, feature_vals, language): if labs: with open('assets/risk_calculators/infection/labs_imputer.pkl', 'rb') as file: imputer_pickle = pickle.load(file) with open('assets/risk_calculators/infection/labs_json.pkl', 'rb') as file: features_pickle = pickle.load(file) else: with open('assets/risk_calculators/infection/without_labs_imputer.pkl', 'rb') as file: imputer_pickle = pickle.load(file) with open('assets/risk_calculators/infection/without_labs_json.pkl', 'rb') as file: features_pickle = pickle.load(file) features = features_pickle["json"] imputer = imputer_pickle["imputer"] length = len(features["numeric"]) return valid_input(features["numeric"], feature_vals[0], length, language)