square / pysurvival

Open source package for Survival Analysis modeling
https://www.pysurvival.io/
Apache License 2.0
350 stars 106 forks source link

Mistake in "CoxPHModel.predict_risk"---line 308 in "models/semi_parametric.py" #26

Open RuinChu opened 4 years ago

RuinChu commented 4 years ago

There seem to be a mistake in calculating risk_score for Cox. In "models/semi_parametric.py" line 308-312:

        risk_score = np.exp(np.dot(x, self.weights))
        if not use_log:
            risk_score = np.exp(risk_score)

        return risk_score

There are a redundant "np.exp()" in line 308 The logged risk score should just be "np.dot(x, self.weights)"

Hope you check it soon. Please tell me if I misunderstand it.

alabamagan commented 3 years ago

Giving this a bump, seems like the default returns the exp of exp.