Giter Club home page Giter Club logo

relife's People

Contributors

tomguillon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

relife's Issues

Issue when specifying a label name for ECDF plots

Should allow to customized label names when plotting ECDF:

# Import load_circuit_breaker function from relife.dataset
from relife import *
from relife.datasets import load_circuit_breaker 

# Assign time, event variables from dataset
time, event = load_circuit_breaker().astuple()[:-1]

# Get only time values for observed event
time1 = time[event==1]

# Fit ECDF estimator to time1
ecdf = ECDF().fit(time1)

# Plot ECDF estimator of F and 1-F
ecdf.plot(label='custom_label')

returns error:
TypeError: plot() got multiple values for keyword argument 'label'

Numerical instability in the derivative of the upper gamma function

The computation of the derivative of the upper gamma function in

def _jac_uppergamma_c(c: np.ndarray, x: np.ndarray) -> np.ndarray:
     return shifted_laguerre(lambda s: np.log(s) * s ** (c - 1), x, ndim=np.ndim(x))

is unstable for low values of the parameters. The numerical result diverges from the true value as parameters go to 0. Test example : c = 0.001, x = 0.002.

Error when printing variance for a Gamma distribution

returns an error printing variance for a Gamma distribution.
test:

from relife import *
gamma = Gamma(c = 41.26, rate = 1.62)
gamma.var()

returns:

TypeError: var() missing 1 required positional argument: 'params'

should returns the variance of the gamma distribution as a float.

temporary solution:

gamma.var(gamma.params)

A proposition to fix this issue:
In distribution.py:

    def var(self) -> np.ndarray:
        c, rate = self.params
        return c / (rate**2)

Issue with convergence of ParametricLifetimeDistribution.fit()

Some issues may happen when fitting data. There is a convergence problem using with the minimize function of scipy.
Here is an example with Gompertz distribution:

from relife import *

weibull = Weibull(c=7.531, rate=0.037)
rtf = RunToFailure(weibull, cf=1)

datagen = rtf.sample(T=300, n_samples=100, random_state=0)
time, event, entry = datagen.to_lifetime_data(t0=0,tf=30).astuple()
gompertz = Gompertz().fit(time,event,entry)

/home/xxx/.local/lib/python3.8/site-packages/relife/parametric.py:347: RuntimeWarning: invalid value encountered in sqrt
self.se = np.sqrt(np.diag(self.var))

Problem may be solved by improving the initialization "params0" and/or using another type of solver (by default L-BFGS).

Fix docstrings for ar and ar1

for ar in OneCycleAgeReplacementPolicy and ar1 for AgeReplacementPolicy:
should be "times to preventive replacements" or "times until preventive replacements" (or sthg else) instead of "Ages of the first preventive replacements"

Doubly censored data in the Kaplan-Meier estimator documentation

Hello,

I am fitting a Kaplan-Meier estimator with doubly censored data. But I get an error. To reproduce the error use the example below.

from relife.nonparametric import KaplanMeier as KM
km = KM()
km.fit(time=np.array([1,2,3]),event=np.array([1,0,2]))

The error is:

  File ~/relife/nonparametric.py:54 in _estimate
    raise ValueError("event values must be in [0,1]")
ValueError: event values must be in [0,1]

But the documentation says that event 2 is used to flag an event as left-censored.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.