コード例 #1
0
 def get_stroke_probability(self, person):
     model_spec = load_model_spec("StrokeMIPartitionModel")
     strokePartitionModel = StatsModelLinearRiskFactorModel(
         RegressionModel(**model_spec))
     strokeProbability = scipySpecial.expit(
         strokePartitionModel.estimate_next_risk(person))
     return strokeProbability
コード例 #2
0
    def setUp(self):
        self.imputed_dataset_first_person = Person(71, NHANESGender.MALE,
                                                   NHANESRaceEthnicity.NON_HISPANIC_WHITE,
                                                   144.667, 52.6667, 9.5, 34, 191, 30.05,
                                                   110.0, 128, 45, 0, Education.COLLEGEGRADUATE,
                                                   SmokingStatus.FORMER, AlcoholCategory.NONE, 0, 0, 0,
                                                   initializeAFib)

        model_spec = load_model_spec("nhanesMortalityModel")
        self.model = StatsModelCoxModel(CoxRegressionModel(**model_spec))
コード例 #3
0
    def __init__(
        self,
        mi_case_fatality=default_mi_case_fatality,
        stroke_case_fatality=default_stroke_case_fatality,
        mi_secondary_case_fatality=default_secondary_mi_case_fatality,
        stroke_secondary_case_fatality=default_secondary_stroke_case_fatality,
        secondary_prevention_multiplier=default_secondary_prevention_multiplier,
    ):
        self.mi_case_fatality = mi_case_fatality
        self.mi_secondary_case_fatality = (mi_secondary_case_fatality,)
        self.stroke_case_fatality = stroke_case_fatality
        self.stroke_secondary_case_fatality = stroke_secondary_case_fatality
        self.secondary_prevention_multiplier = secondary_prevention_multiplier

        model_spec = load_model_spec("StrokeMIPartitionModel")
        self.strokePartitionModel = StatsModelLinearRiskFactorModel(RegressionModel(**model_spec))
コード例 #4
0
    def __init__(self):
        self.mi_case_fatality = CVOutcomeDetermination.default_mi_case_fatality
        self.secondary_mi_case_fatality = CVOutcomeDetermination.default_secondary_mi_case_fatality
        self.stroke_case_fatality = CVOutcomeDetermination.default_stroke_case_fatality
        self.secondary_stroke_case_fatality = (
            CVOutcomeDetermination.default_secondary_stroke_case_fatality)
        self.secondary_prevention_multiplier = (
            CVOutcomeDetermination.default_secondary_prevention_multiplier)

        self.outcomeDet = CVOutcomeDetermination(
            self.mi_case_fatality,
            self.stroke_case_fatality,
            self.secondary_mi_case_fatality,
            self.secondary_stroke_case_fatality,
            self.secondary_prevention_multiplier,
        )

        # variable used in testing to control whether a patient will have a stroke or mi
        self.manualStrokeMIProbability = None

        self._models = {}
        femaleCVCoefficients = {
            "lagAge": 0.106501,
            "black": 0.432440,
            "lagSbp#lagSbp": 0.000056,
            "lagSbp": 0.017666,
            "current_bp_treatment": 0.731678,
            "current_diabetes": 0.943970,
            "current_smoker": 1.009790,
            "lagAge#black": -0.008580,
            "lagSbp#current_bp_treatment": -0.003647,
            "lagSbp#black": 0.006208,
            "black#current_bp_treatment": 0.152968,
            "lagAge#lagSbp": -0.000153,
            "black#current_diabetes": 0.115232,
            "black#current_smoker": -0.092231,
            "lagSbp#black#current_bp_treatment": -0.000173,
            "lagAge#lagSbp#black": -0.000094,
            "Intercept": -12.823110,
        }

        maleCVCoefficients = {
            "lagAge": 0.064200,
            "black": 0.482835,
            "lagSbp#lagSbp": -0.000061,
            "lagSbp": 0.038950,
            "current_bp_treatment": 2.055533,
            "current_diabetes": 0.842209,
            "current_smoker": 0.895589,
            "lagAge#black": 0,
            "lagSbp#current_bp_treatment": -0.014207,
            "lagSbp#black": 0.011609,
            "black#current_bp_treatment": -0.119460,
            "lagAge#lagSbp": 0.000025,
            "black#current_diabetes": -0.077214,
            "black#current_smoker": -0.226771,
            "lagSbp#black#current_bp_treatment": 0.004190,
            "lagAge#lagSbp#black": -0.000199,
            "Intercept": -11.679980,
        }

        self._models[OutcomeModelType.CARDIOVASCULAR] = {
            "female":
            ASCVDOutcomeModel(
                RegressionModel(
                    coefficients=femaleCVCoefficients,
                    coefficient_standard_errors={
                        key: 0
                        for key in femaleCVCoefficients
                    },
                    residual_mean=0,
                    residual_standard_deviation=0,
                ),
                tot_chol_hdl_ratio=0.151318,
                black_race_x_tot_chol_hdl_ratio=0.070498,
            ),
            "male":
            ASCVDOutcomeModel(
                RegressionModel(
                    coefficients=maleCVCoefficients,
                    coefficient_standard_errors={
                        key: 0
                        for key in maleCVCoefficients
                    },
                    residual_mean=0,
                    residual_standard_deviation=0,
                ),
                tot_chol_hdl_ratio=0.193307,
                black_race_x_tot_chol_hdl_ratio=-0.117749,
            ),
        }
        self._models[
            OutcomeModelType.GLOBAL_COGNITIVE_PERFORMANCE] = GCPModel()
        self._models[OutcomeModelType.DEMENTIA] = DementiaModel()

        # This represents non-cardiovascular mortality..
        nonCVModelSpec = load_model_spec("nhanesMortalityModelLogit")
        mortModel = StatsModelLogisticRiskFactorModel(
            RegressionModel(**nonCVModelSpec), False)
        # Recalibrate mortalitly model to align with life table data, as explored in notebook
        # buildNHANESMortalityModel
        mortModel.non_intercept_params[
            "age"] = mortModel.non_intercept_params["age"] * -1
        mortModel.non_intercept_params["squareAge"] = (
            mortModel.non_intercept_params["squareAge"] * 4)
        self._models[OutcomeModelType.NON_CV_MORTALITY] = mortModel
コード例 #5
0
 def initialize_cox_model(self, modelName):
     model_spec = load_model_spec(modelName)
     return StatsModelCoxModel(CoxRegressionModel(**model_spec))