def predict_risk_mort(cols, model, features, imputer, explainer, feature_vals, temp_unit, card_text, language): score, imputed_text, plot = predict_risk(True, model, features, imputer, explainer, feature_vals, cols, temp_unit, language) card_content = [ html.H4(card_text, className="score-calculator-card-content"), html.H4(str(score) + "%", className="score-calculator-card-content"), ] return card_content, imputed_text, plot
def predict_risk_mort(cols, model, features, imputer, explainer, feature_vals, temp_unit, card_text, language): """Given features, other input, etc. calculate a score and return score_card, imputed_text, and user plot""" score, imputed_text, plot = predict_risk(True, model, features, imputer, explainer, feature_vals, cols, temp_unit, language) card_content = [ html.H4(card_text, className="score-calculator-card-content"), html.H4(str(score) + "%", className="score-calculator-card-content"), ] return card_content, imputed_text, plot
def predict_risk_infec(cols, model, features, imputer, explainer, feature_vals, temp_unit, card_text, language): score, impute_text, plot = predict_risk(False, model, features, imputer, explainer, feature_vals, cols, temp_unit, language) card_content = [ html.H4(card_text[0], className="score-calculator-card-content-infection"), html.H4(str(int(math.floor(score / 10.0))) + card_text[1], className="score-calculator-card-content-infection"), ] return card_content, impute_text, plot
def predict_risk_mort(labs, feature_vals, temp_unit, card_text, language): if labs: cols = cols_labs_mort model = labs_model_mort features = labs_features_mort imputer = labs_imputer_mort explainer = labs_explainer_mort else: cols = cols_no_labs_mort model = no_labs_model_mort features = no_labs_features_mort imputer = no_labs_imputer_mort explainer = no_labs_explainer_mort score, imputed_text, plot = predict_risk(True, model, features, imputer, explainer, feature_vals, cols, temp_unit, labs, language) card_content = [ html.H4(card_text, className="score-calculator-card-content"), html.H4(str(score) + "%", className="score-calculator-card-content"), ] return card_content, imputed_text, plot
def predict_risk_infec(labs, feature_vals, temp_unit, card_text, 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) with open('assets/risk_calculators/infection/labs_model_explainer.pkl', 'rb') as file: model_pickle = pickle.load(file) cols = get_cols(True) 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) with open( 'assets/risk_calculators/infection/without_labs_model_explainer.pkl', 'rb') as file: model_pickle = pickle.load(file) cols = get_cols(False) model = model_pickle["model"] features = features_pickle["json"] imputer = imputer_pickle["imputer"] explainer = model_pickle["explainer"] score, impute_text, plot = predict_risk(False, model, features, imputer, explainer, feature_vals, cols, temp_unit, labs, language) card_content = [ html.H4(card_text[0], className="score-calculator-card-content-infection"), html.H4(str(int(math.floor(score / 10.0))) + card_text[1], className="score-calculator-card-content-infection"), ] return card_content, impute_text, plot
def predict_risk_mort(labs, feature_vals, temp_unit, card_text, language): if labs: with open('assets/risk_calculators/mortality/labs_imputer.pkl', 'rb') as file: imputer_pickle = pickle.load(file) with open('assets/risk_calculators/mortality/labs_json.pkl', 'rb') as file: features_pickle = pickle.load(file) with open('assets/risk_calculators/mortality/labs_model_explainer.pkl', 'rb') as file: model_pickle = pickle.load(file) cols = get_cols(True) else: with open('assets/risk_calculators/mortality/without_labs_imputer.pkl', 'rb') as file: imputer_pickle = pickle.load(file) with open('assets/risk_calculators/mortality/without_labs_json.pkl', 'rb') as file: features_pickle = pickle.load(file) with open( 'assets/risk_calculators/mortality/without_labs_model_explainer.pkl', 'rb') as file: model_pickle = pickle.load(file) cols = get_cols(False) model = model_pickle["model"] features = features_pickle["json"] imputer = imputer_pickle["imputer"] explainer = model_pickle["explainer"] score, imputed_text, plot = predict_risk(True, model, features, imputer, explainer, feature_vals, cols, temp_unit, labs, language) card_content = [ html.H4(card_text, className="score-calculator-card-content"), html.H4(str(score) + "%", className="score-calculator-card-content"), ] return card_content, imputed_text, plot
def predict_risk_infec(labs, feature_vals, temp_unit, card_text, language): if labs: cols = cols_labs_infec model = labs_model_infec features = labs_features_infec imputer = labs_imputer_infec explainer = labs_explainer_infec else: cols = cols_no_labs_infec model = no_labs_model_infec features = no_labs_features_infec imputer = no_labs_imputer_infec explainer = no_labs_explainer_infec score, impute_text, plot = predict_risk(False, model, features, imputer, explainer, feature_vals, cols, temp_unit, labs, language) card_content = [ html.H4(card_text[0], className="score-calculator-card-content-infection"), html.H4(str(int(math.floor(score / 10.0))) + card_text[1], className="score-calculator-card-content-infection"), ] return card_content, impute_text, plot