partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
CoxPHFitter._compute_scaled_schoenfeld
r""" Let s_k be the kth schoenfeld residuals. Then E[s_k] = 0. For tests of proportionality, we want to test if \beta_i(t) is \beta_i (constant) or not. Let V_k be the contribution to the information matrix at time t_k. A main result from Grambsch and Therneau is that \beta(t) = E[s_k*...
lifelines/fitters/coxph_fitter.py
def _compute_scaled_schoenfeld(self, X, T, E, weights, index=None): r""" Let s_k be the kth schoenfeld residuals. Then E[s_k] = 0. For tests of proportionality, we want to test if \beta_i(t) is \beta_i (constant) or not. Let V_k be the contribution to the information matrix at time t_k....
def _compute_scaled_schoenfeld(self, X, T, E, weights, index=None): r""" Let s_k be the kth schoenfeld residuals. Then E[s_k] = 0. For tests of proportionality, we want to test if \beta_i(t) is \beta_i (constant) or not. Let V_k be the contribution to the information matrix at time t_k....
[ "r", "Let", "s_k", "be", "the", "kth", "schoenfeld", "residuals", ".", "Then", "E", "[", "s_k", "]", "=", "0", ".", "For", "tests", "of", "proportionality", "we", "want", "to", "test", "if", "\\", "beta_i", "(", "t", ")", "is", "\\", "beta_i", "(",...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L933-L959
[ "def", "_compute_scaled_schoenfeld", "(", "self", ",", "X", ",", "T", ",", "E", ",", "weights", ",", "index", "=", "None", ")", ":", "n_deaths", "=", "self", ".", "event_observed", ".", "sum", "(", ")", "scaled_schoenfeld_resids", "=", "n_deaths", "*", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter._compute_schoenfeld_within_strata
A positive value of the residual shows an X value that is higher than expected at that death time.
lifelines/fitters/coxph_fitter.py
def _compute_schoenfeld_within_strata(self, X, T, E, weights): """ A positive value of the residual shows an X value that is higher than expected at that death time. """ # TODO: the diff_against is gross # This uses Efron ties. n, d = X.shape if not np.any(E): ...
def _compute_schoenfeld_within_strata(self, X, T, E, weights): """ A positive value of the residual shows an X value that is higher than expected at that death time. """ # TODO: the diff_against is gross # This uses Efron ties. n, d = X.shape if not np.any(E): ...
[ "A", "positive", "value", "of", "the", "residual", "shows", "an", "X", "value", "that", "is", "higher", "than", "expected", "at", "that", "death", "time", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L984-L1069
[ "def", "_compute_schoenfeld_within_strata", "(", "self", ",", "X", ",", "T", ",", "E", ",", "weights", ")", ":", "# TODO: the diff_against is gross", "# This uses Efron ties.", "n", ",", "d", "=", "X", ".", "shape", "if", "not", "np", ".", "any", "(", "E", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter._compute_delta_beta
approximate change in betas as a result of excluding ith row. Good for finding outliers / specific subjects that influence the model disproportionately. Good advice: don't drop these outliers, model them.
lifelines/fitters/coxph_fitter.py
def _compute_delta_beta(self, X, T, E, weights, index=None): """ approximate change in betas as a result of excluding ith row. Good for finding outliers / specific subjects that influence the model disproportionately. Good advice: don't drop these outliers, model them. """ score_...
def _compute_delta_beta(self, X, T, E, weights, index=None): """ approximate change in betas as a result of excluding ith row. Good for finding outliers / specific subjects that influence the model disproportionately. Good advice: don't drop these outliers, model them. """ score_...
[ "approximate", "change", "in", "betas", "as", "a", "result", "of", "excluding", "ith", "row", ".", "Good", "for", "finding", "outliers", "/", "specific", "subjects", "that", "influence", "the", "model", "disproportionately", ".", "Good", "advice", ":", "don", ...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1071-L1084
[ "def", "_compute_delta_beta", "(", "self", ",", "X", ",", "T", ",", "E", ",", "weights", ",", "index", "=", "None", ")", ":", "score_residuals", "=", "self", ".", "_compute_score", "(", "X", ",", "T", ",", "E", ",", "weights", ",", "index", "=", "i...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.summary
Summary statistics describing the fit. Set alpha property in the object before calling. Returns ------- df : DataFrame Contains columns coef, np.exp(coef), se(coef), z, p, lower, upper
lifelines/fitters/coxph_fitter.py
def summary(self): """Summary statistics describing the fit. Set alpha property in the object before calling. Returns ------- df : DataFrame Contains columns coef, np.exp(coef), se(coef), z, p, lower, upper""" ci = 1 - self.alpha with np.errstate(inva...
def summary(self): """Summary statistics describing the fit. Set alpha property in the object before calling. Returns ------- df : DataFrame Contains columns coef, np.exp(coef), se(coef), z, p, lower, upper""" ci = 1 - self.alpha with np.errstate(inva...
[ "Summary", "statistics", "describing", "the", "fit", ".", "Set", "alpha", "property", "in", "the", "object", "before", "calling", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1200-L1219
[ "def", "summary", "(", "self", ")", ":", "ci", "=", "1", "-", "self", ".", "alpha", "with", "np", ".", "errstate", "(", "invalid", "=", "\"ignore\"", ",", "divide", "=", "\"ignore\"", ")", ":", "df", "=", "pd", ".", "DataFrame", "(", "index", "=", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.predict_log_partial_hazard
r""" This is equivalent to R's linear.predictors. Returns the log of the partial hazard for the individuals, partial since the baseline hazard is not included. Equal to :math:`(x - mean(x_{train}))'\beta ` Parameters ---------- X: numpy array or DataFrame a...
lifelines/fitters/coxph_fitter.py
def predict_log_partial_hazard(self, X): r""" This is equivalent to R's linear.predictors. Returns the log of the partial hazard for the individuals, partial since the baseline hazard is not included. Equal to :math:`(x - mean(x_{train}))'\beta ` Parameters ---------- ...
def predict_log_partial_hazard(self, X): r""" This is equivalent to R's linear.predictors. Returns the log of the partial hazard for the individuals, partial since the baseline hazard is not included. Equal to :math:`(x - mean(x_{train}))'\beta ` Parameters ---------- ...
[ "r", "This", "is", "equivalent", "to", "R", "s", "linear", ".", "predictors", ".", "Returns", "the", "log", "of", "the", "partial", "hazard", "for", "the", "individuals", "partial", "since", "the", "baseline", "hazard", "is", "not", "included", ".", "Equal...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1332-L1378
[ "def", "predict_log_partial_hazard", "(", "self", ",", "X", ")", ":", "hazard_names", "=", "self", ".", "hazards_", ".", "index", "if", "isinstance", "(", "X", ",", "pd", ".", "Series", ")", "and", "(", "(", "X", ".", "shape", "[", "0", "]", "==", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.predict_cumulative_hazard
Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as the training data. times: iterable, optional an itera...
lifelines/fitters/coxph_fitter.py
def predict_cumulative_hazard(self, X, times=None): """ Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as t...
def predict_cumulative_hazard(self, X, times=None): """ Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as t...
[ "Parameters", "----------" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1380-L1430
[ "def", "predict_cumulative_hazard", "(", "self", ",", "X", ",", "times", "=", "None", ")", ":", "if", "self", ".", "strata", ":", "cumulative_hazard_", "=", "pd", ".", "DataFrame", "(", ")", "for", "stratum", ",", "stratified_X", "in", "X", ".", "groupby...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.predict_survival_function
Predict the survival function for individuals, given their covariates. This assumes that the individual just entered the study (that is, we do not condition on how long they have already lived for.) Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy a...
lifelines/fitters/coxph_fitter.py
def predict_survival_function(self, X, times=None): """ Predict the survival function for individuals, given their covariates. This assumes that the individual just entered the study (that is, we do not condition on how long they have already lived for.) Parameters ---------- ...
def predict_survival_function(self, X, times=None): """ Predict the survival function for individuals, given their covariates. This assumes that the individual just entered the study (that is, we do not condition on how long they have already lived for.) Parameters ---------- ...
[ "Predict", "the", "survival", "function", "for", "individuals", "given", "their", "covariates", ".", "This", "assumes", "that", "the", "individual", "just", "entered", "the", "study", "(", "that", "is", "we", "do", "not", "condition", "on", "how", "long", "t...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1432-L1455
[ "def", "predict_survival_function", "(", "self", ",", "X", ",", "times", "=", "None", ")", ":", "return", "np", ".", "exp", "(", "-", "self", ".", "predict_cumulative_hazard", "(", "X", ",", "times", "=", "times", ")", ")" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.predict_percentile
Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ---------- X: numpy array or DataFrame ...
lifelines/fitters/coxph_fitter.py
def predict_percentile(self, X, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ...
def predict_percentile(self, X, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ...
[ "Returns", "the", "median", "lifetimes", "for", "the", "individuals", "by", "default", ".", "If", "the", "survival", "curve", "of", "an", "individual", "does", "not", "cross", "0", ".", "5", "then", "the", "result", "is", "infinity", ".", "http", ":", "/...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1457-L1482
[ "def", "predict_percentile", "(", "self", ",", "X", ",", "p", "=", "0.5", ")", ":", "subjects", "=", "_get_index", "(", "X", ")", "return", "qth_survival_times", "(", "p", ",", "self", ".", "predict_survival_function", "(", "X", ")", "[", "subjects", "]"...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.predict_expectation
r""" Compute the expected lifetime, :math:`E[T]`, using covariates X. This algorithm to compute the expectation is to use the fact that :math:`E[T] = \int_0^\inf P(T > t) dt = \int_0^\inf S(t) dt`. To compute the integral, we use the trapizoidal rule to approximate the integral. Caution ...
lifelines/fitters/coxph_fitter.py
def predict_expectation(self, X): r""" Compute the expected lifetime, :math:`E[T]`, using covariates X. This algorithm to compute the expectation is to use the fact that :math:`E[T] = \int_0^\inf P(T > t) dt = \int_0^\inf S(t) dt`. To compute the integral, we use the trapizoidal rule to approxim...
def predict_expectation(self, X): r""" Compute the expected lifetime, :math:`E[T]`, using covariates X. This algorithm to compute the expectation is to use the fact that :math:`E[T] = \int_0^\inf P(T > t) dt = \int_0^\inf S(t) dt`. To compute the integral, we use the trapizoidal rule to approxim...
[ "r", "Compute", "the", "expected", "lifetime", ":", "math", ":", "E", "[", "T", "]", "using", "covariates", "X", ".", "This", "algorithm", "to", "compute", "the", "expectation", "is", "to", "use", "the", "fact", "that", ":", "math", ":", "E", "[", "T...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1510-L1546
[ "def", "predict_expectation", "(", "self", ",", "X", ")", ":", "subjects", "=", "_get_index", "(", "X", ")", "v", "=", "self", ".", "predict_survival_function", "(", "X", ")", "[", "subjects", "]", "return", "pd", ".", "DataFrame", "(", "trapz", "(", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter._compute_baseline_survival
Importantly, this agrees with what the KaplanMeierFitter produces. Ex: Example ------- >>> from lifelines.datasets import load_rossi >>> from lifelines import CoxPHFitter, KaplanMeierFitter >>> rossi = load_rossi() >>> kmf = KaplanMeierFitter() >>> kmf.fit(rossi[...
lifelines/fitters/coxph_fitter.py
def _compute_baseline_survival(self): """ Importantly, this agrees with what the KaplanMeierFitter produces. Ex: Example ------- >>> from lifelines.datasets import load_rossi >>> from lifelines import CoxPHFitter, KaplanMeierFitter >>> rossi = load_rossi() ...
def _compute_baseline_survival(self): """ Importantly, this agrees with what the KaplanMeierFitter produces. Ex: Example ------- >>> from lifelines.datasets import load_rossi >>> from lifelines import CoxPHFitter, KaplanMeierFitter >>> rossi = load_rossi() ...
[ "Importantly", "this", "agrees", "with", "what", "the", "KaplanMeierFitter", "produces", ".", "Ex", ":" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1580-L1601
[ "def", "_compute_baseline_survival", "(", "self", ")", ":", "survival_df", "=", "np", ".", "exp", "(", "-", "self", ".", "baseline_cumulative_hazard_", ")", "if", "self", ".", "strata", "is", "None", ":", "survival_df", ".", "columns", "=", "[", "\"baseline ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.plot_covariate_groups
Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' survival as we vary covariate(s), all else being held equal. The baseline survival curve is equal to t...
lifelines/fitters/coxph_fitter.py
def plot_covariate_groups(self, covariates, values, plot_baseline=True, **kwargs): """ Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' surviva...
def plot_covariate_groups(self, covariates, values, plot_baseline=True, **kwargs): """ Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' surviva...
[ "Produces", "a", "visual", "representation", "comparing", "the", "baseline", "survival", "curve", "of", "the", "model", "versus", "what", "happens", "when", "a", "covariate", "(", "s", ")", "is", "varied", "over", "values", "in", "a", "group", ".", "This", ...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1654-L1749
[ "def", "plot_covariate_groups", "(", "self", ",", "covariates", ",", "values", ",", "plot_baseline", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "covariates", "=", "_to_list", "(", "covariates", ")",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.check_assumptions
Use this function to test the proportional hazards assumption. See usage example at https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%20hazard%20assumption.html Parameters ----------- training_df: DataFrame the original DataFrame used in the call to...
lifelines/fitters/coxph_fitter.py
def check_assumptions( self, training_df, advice=True, show_plots=False, p_value_threshold=0.01, plot_n_bootstraps=10 ): """ Use this function to test the proportional hazards assumption. See usage example at https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%2...
def check_assumptions( self, training_df, advice=True, show_plots=False, p_value_threshold=0.01, plot_n_bootstraps=10 ): """ Use this function to test the proportional hazards assumption. See usage example at https://lifelines.readthedocs.io/en/latest/jupyter_notebooks/Proportional%2...
[ "Use", "this", "function", "to", "test", "the", "proportional", "hazards", "assumption", ".", "See", "usage", "example", "at", "https", ":", "//", "lifelines", ".", "readthedocs", ".", "io", "/", "en", "/", "latest", "/", "jupyter_notebooks", "/", "Proportio...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1751-L1953
[ "def", "check_assumptions", "(", "self", ",", "training_df", ",", "advice", "=", "True", ",", "show_plots", "=", "False", ",", "p_value_threshold", "=", "0.01", ",", "plot_n_bootstraps", "=", "10", ")", ":", "if", "not", "training_df", ".", "index", ".", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
CoxPHFitter.score_
The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the training dataset. References ...
lifelines/fitters/coxph_fitter.py
def score_(self): """ The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the trai...
def score_(self): """ The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the trai...
[ "The", "concordance", "score", "(", "also", "known", "as", "the", "c", "-", "index", ")", "of", "the", "fit", ".", "The", "c", "-", "index", "is", "a", "generalization", "of", "the", "ROC", "AUC", "to", "survival", "data", "including", "censorships", "...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/coxph_fitter.py#L1956-L1991
[ "def", "score_", "(", "self", ")", ":", "# pylint: disable=access-member-before-definition", "if", "not", "hasattr", "(", "self", ",", "\"_concordance_score_\"", ")", ":", "if", "self", ".", "strata", ":", "# https://stats.stackexchange.com/questions/133817/stratified-conco...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
concordance_index
Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. The c-index is the average of how often a model says X is greater than Y when, in the o...
lifelines/utils/concordance.py
def concordance_index(event_times, predicted_scores, event_observed=None): """ Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. ...
def concordance_index(event_times, predicted_scores, event_observed=None): """ Calculates the concordance index (C-index) between two series of event times. The first is the real survival times from the experimental data, and the other is the predicted survival times from a model of some kind. ...
[ "Calculates", "the", "concordance", "index", "(", "C", "-", "index", ")", "between", "two", "series", "of", "event", "times", ".", "The", "first", "is", "the", "real", "survival", "times", "from", "the", "experimental", "data", "and", "the", "other", "is",...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L7-L79
[ "def", "concordance_index", "(", "event_times", ",", "predicted_scores", ",", "event_observed", "=", "None", ")", ":", "event_times", "=", "np", ".", "asarray", "(", "event_times", ",", "dtype", "=", "float", ")", "predicted_scores", "=", "np", ".", "asarray",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_concordance_summary_statistics
Find the concordance index in n * log(n) time. Assumes the data has been verified by lifelines.utils.concordance_index first.
lifelines/utils/concordance.py
def _concordance_summary_statistics( event_times, predicted_event_times, event_observed ): # pylint: disable=too-many-locals """Find the concordance index in n * log(n) time. Assumes the data has been verified by lifelines.utils.concordance_index first. """ # Here's how this works. # # It ...
def _concordance_summary_statistics( event_times, predicted_event_times, event_observed ): # pylint: disable=too-many-locals """Find the concordance index in n * log(n) time. Assumes the data has been verified by lifelines.utils.concordance_index first. """ # Here's how this works. # # It ...
[ "Find", "the", "concordance", "index", "in", "n", "*", "log", "(", "n", ")", "time", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L88-L175
[ "def", "_concordance_summary_statistics", "(", "event_times", ",", "predicted_event_times", ",", "event_observed", ")", ":", "# pylint: disable=too-many-locals", "# Here's how this works.", "#", "# It would be pretty easy to do if we had no censored data and no ties. There, the basic idea"...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_handle_pairs
Handle all pairs that exited at the same time as truth[first_ix]. Returns ------- (pairs, correct, tied, next_ix) new_pairs: The number of new comparisons performed new_correct: The number of comparisons correctly predicted next_ix: The next index that needs to be handled
lifelines/utils/concordance.py
def _handle_pairs(truth, pred, first_ix, times_to_compare): """ Handle all pairs that exited at the same time as truth[first_ix]. Returns ------- (pairs, correct, tied, next_ix) new_pairs: The number of new comparisons performed new_correct: The number of comparisons correctly predict...
def _handle_pairs(truth, pred, first_ix, times_to_compare): """ Handle all pairs that exited at the same time as truth[first_ix]. Returns ------- (pairs, correct, tied, next_ix) new_pairs: The number of new comparisons performed new_correct: The number of comparisons correctly predict...
[ "Handle", "all", "pairs", "that", "exited", "at", "the", "same", "time", "as", "truth", "[", "first_ix", "]", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L178-L200
[ "def", "_handle_pairs", "(", "truth", ",", "pred", ",", "first_ix", ",", "times_to_compare", ")", ":", "next_ix", "=", "first_ix", "while", "next_ix", "<", "len", "(", "truth", ")", "and", "truth", "[", "next_ix", "]", "==", "truth", "[", "first_ix", "]"...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_naive_concordance_summary_statistics
Fallback, simpler method to compute concordance. Assumes the data has been verified by lifelines.utils.concordance_index first.
lifelines/utils/concordance.py
def _naive_concordance_summary_statistics(event_times, predicted_event_times, event_observed): """ Fallback, simpler method to compute concordance. Assumes the data has been verified by lifelines.utils.concordance_index first. """ num_pairs = 0.0 num_correct = 0.0 num_tied = 0.0 for a,...
def _naive_concordance_summary_statistics(event_times, predicted_event_times, event_observed): """ Fallback, simpler method to compute concordance. Assumes the data has been verified by lifelines.utils.concordance_index first. """ num_pairs = 0.0 num_correct = 0.0 num_tied = 0.0 for a,...
[ "Fallback", "simpler", "method", "to", "compute", "concordance", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L203-L228
[ "def", "_naive_concordance_summary_statistics", "(", "event_times", ",", "predicted_event_times", ",", "event_observed", ")", ":", "num_pairs", "=", "0.0", "num_correct", "=", "0.0", "num_tied", "=", "0.0", "for", "a", ",", "time_a", "in", "enumerate", "(", "event...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_valid_comparison
True if times can be compared.
lifelines/utils/concordance.py
def _valid_comparison(time_a, time_b, event_a, event_b): """True if times can be compared.""" if time_a == time_b: # Ties are only informative if exactly one event happened return event_a != event_b if event_a and event_b: return True if event_a and time_a < time_b: retur...
def _valid_comparison(time_a, time_b, event_a, event_b): """True if times can be compared.""" if time_a == time_b: # Ties are only informative if exactly one event happened return event_a != event_b if event_a and event_b: return True if event_a and time_a < time_b: retur...
[ "True", "if", "times", "can", "be", "compared", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/concordance.py#L237-L248
[ "def", "_valid_comparison", "(", "time_a", ",", "time_b", ",", "event_a", ",", "event_b", ")", ":", "if", "time_a", "==", "time_b", ":", "# Ties are only informative if exactly one event happened", "return", "event_a", "!=", "event_b", "if", "event_a", "and", "event...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogNormalAFTFitter.predict_percentile
Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ---------- X: numpy array or DataFrame ...
lifelines/fitters/log_normal_aft_fitter.py
def predict_percentile(self, X, ancillary_X=None, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions ...
def predict_percentile(self, X, ancillary_X=None, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions ...
[ "Returns", "the", "median", "lifetimes", "for", "the", "individuals", "by", "default", ".", "If", "the", "survival", "curve", "of", "an", "individual", "does", "not", "cross", "p", "then", "the", "result", "is", "infinity", ".", "http", ":", "//", "stats",...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_normal_aft_fitter.py#L98-L127
[ "def", "predict_percentile", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ",", "p", "=", "0.5", ")", ":", "exp_mu_", ",", "sigma_", "=", "self", ".", "_prep_inputs_for_prediction_and_return_scores", "(", "X", ",", "ancillary_X", ")", "return", "pd...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogNormalAFTFitter.predict_median
Returns the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ---------- X: numpy array or DataFrame a (n...
lifelines/fitters/log_normal_aft_fitter.py
def predict_median(self, X, ancillary_X=None): """ Returns the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ...
def predict_median(self, X, ancillary_X=None): """ Returns the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ...
[ "Returns", "the", "median", "lifetimes", "for", "the", "individuals", ".", "If", "the", "survival", "curve", "of", "an", "individual", "does", "not", "cross", "0", ".", "5", "then", "the", "result", "is", "infinity", ".", "http", ":", "//", "stats", ".",...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_normal_aft_fitter.py#L129-L158
[ "def", "predict_median", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ")", ":", "exp_mu_", ",", "_", "=", "self", ".", "_prep_inputs_for_prediction_and_return_scores", "(", "X", ",", "ancillary_X", ")", "return", "pd", ".", "DataFrame", "(", "exp_...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogNormalAFTFitter.predict_expectation
Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as the train...
lifelines/fitters/log_normal_aft_fitter.py
def predict_expectation(self, X, ancillary_X=None): """ Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a...
def predict_expectation(self, X, ancillary_X=None): """ Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a...
[ "Predict", "the", "expectation", "of", "lifetimes", ":", "math", ":", "E", "[", "T", "|", "x", "]", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_normal_aft_fitter.py#L160-L187
[ "def", "predict_expectation", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ")", ":", "exp_mu_", ",", "sigma_", "=", "self", ".", "_prep_inputs_for_prediction_and_return_scores", "(", "X", ",", "ancillary_X", ")", "return", "pd", ".", "DataFrame", "(...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogNormalAFTFitter.predict_cumulative_hazard
Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order ...
lifelines/fitters/log_normal_aft_fitter.py
def predict_cumulative_hazard(self, X, times=None, ancillary_X=None): """ Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns ...
def predict_cumulative_hazard(self, X, times=None, ancillary_X=None): """ Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns ...
[ "Return", "the", "cumulative", "hazard", "rate", "of", "subjects", "in", "X", "at", "time", "points", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_normal_aft_fitter.py#L189-L220
[ "def", "predict_cumulative_hazard", "(", "self", ",", "X", ",", "times", "=", "None", ",", "ancillary_X", "=", "None", ")", ":", "import", "numpy", "as", "np", "times", "=", "coalesce", "(", "times", ",", "self", ".", "timeline", ",", "np", ".", "uniqu...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
UnivariateFitter.subtract
Subtract the {0} of two {1} objects. Parameters ---------- other: an {1} fitted instance.
lifelines/fitters/__init__.py
def subtract(self, other): """ Subtract the {0} of two {1} objects. Parameters ---------- other: an {1} fitted instance. """ self_estimate = getattr(self, self._estimate_name) other_estimate = getattr(other, other._estimate_name) new_index = np.co...
def subtract(self, other): """ Subtract the {0} of two {1} objects. Parameters ---------- other: an {1} fitted instance. """ self_estimate = getattr(self, self._estimate_name) other_estimate = getattr(other, other._estimate_name) new_index = np.co...
[ "Subtract", "the", "{", "0", "}", "of", "two", "{", "1", "}", "objects", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L150-L167
[ "def", "subtract", "(", "self", ",", "other", ")", ":", "self_estimate", "=", "getattr", "(", "self", ",", "self", ".", "_estimate_name", ")", "other_estimate", "=", "getattr", "(", "other", ",", "other", ".", "_estimate_name", ")", "new_index", "=", "np",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
UnivariateFitter.predict
Predict the {0} at certain point in time. Uses a linear interpolation if points in time are not in the index. Parameters ---------- times: a scalar or an array of times to predict the value of {0} at. Returns ------- predictions: a scalar if time is a scalar, a ...
lifelines/fitters/__init__.py
def predict(self, times): """ Predict the {0} at certain point in time. Uses a linear interpolation if points in time are not in the index. Parameters ---------- times: a scalar or an array of times to predict the value of {0} at. Returns ------- ...
def predict(self, times): """ Predict the {0} at certain point in time. Uses a linear interpolation if points in time are not in the index. Parameters ---------- times: a scalar or an array of times to predict the value of {0} at. Returns ------- ...
[ "Predict", "the", "{", "0", "}", "at", "certain", "point", "in", "time", ".", "Uses", "a", "linear", "interpolation", "if", "points", "in", "time", "are", "not", "in", "the", "index", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L192-L209
[ "def", "predict", "(", "self", ",", "times", ")", ":", "if", "callable", "(", "self", ".", "_estimation_method", ")", ":", "return", "pd", ".", "DataFrame", "(", "self", ".", "_estimation_method", "(", "_to_array", "(", "times", ")", ")", ",", "index", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
UnivariateFitter._conditional_time_to_event_
Return a DataFrame, with index equal to survival_function_, that estimates the median duration remaining until the death event, given survival up until time t. For example, if an individual exists until age 1, their expected life remaining *given they lived to time 1* might be 9 years. ...
lifelines/fitters/__init__.py
def _conditional_time_to_event_(self): """ Return a DataFrame, with index equal to survival_function_, that estimates the median duration remaining until the death event, given survival up until time t. For example, if an individual exists until age 1, their expected life remaining *give...
def _conditional_time_to_event_(self): """ Return a DataFrame, with index equal to survival_function_, that estimates the median duration remaining until the death event, given survival up until time t. For example, if an individual exists until age 1, their expected life remaining *give...
[ "Return", "a", "DataFrame", "with", "index", "equal", "to", "survival_function_", "that", "estimates", "the", "median", "duration", "remaining", "until", "the", "death", "event", "given", "survival", "up", "until", "time", "t", ".", "For", "example", "if", "an...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L228-L252
[ "def", "_conditional_time_to_event_", "(", "self", ")", ":", "age", "=", "self", ".", "survival_function_", ".", "index", ".", "values", "[", ":", ",", "None", "]", "columns", "=", "[", "\"%s - Conditional time remaining to event\"", "%", "self", ".", "_label", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter._compute_confidence_bounds_of_transform
This computes the confidence intervals of a transform of the parameters. Ex: take the fitted parameters, a function/transform and the variance matrix and give me back confidence intervals of the transform. Parameters ----------- transform: function must a function of...
lifelines/fitters/__init__.py
def _compute_confidence_bounds_of_transform(self, transform, alpha, ci_labels): """ This computes the confidence intervals of a transform of the parameters. Ex: take the fitted parameters, a function/transform and the variance matrix and give me back confidence intervals of the transform...
def _compute_confidence_bounds_of_transform(self, transform, alpha, ci_labels): """ This computes the confidence intervals of a transform of the parameters. Ex: take the fitted parameters, a function/transform and the variance matrix and give me back confidence intervals of the transform...
[ "This", "computes", "the", "confidence", "intervals", "of", "a", "transform", "of", "the", "parameters", ".", "Ex", ":", "take", "the", "fitted", "parameters", "a", "function", "/", "transform", "and", "the", "variance", "matrix", "and", "give", "me", "back"...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L446-L487
[ "def", "_compute_confidence_bounds_of_transform", "(", "self", ",", "transform", ",", "alpha", ",", "ci_labels", ")", ":", "alpha2", "=", "1", "-", "alpha", "/", "2.0", "z", "=", "inv_normal_cdf", "(", "alpha2", ")", "df", "=", "pd", ".", "DataFrame", "(",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.summary
Summary statistics describing the fit. Returns ------- df : pd.DataFrame Contains columns coef, exp(coef), se(coef), z, p, lower, upper See Also -------- ``print_summary``
lifelines/fitters/__init__.py
def summary(self): """ Summary statistics describing the fit. Returns ------- df : pd.DataFrame Contains columns coef, exp(coef), se(coef), z, p, lower, upper See Also -------- ``print_summary`` """ ci = 1 - self.alpha ...
def summary(self): """ Summary statistics describing the fit. Returns ------- df : pd.DataFrame Contains columns coef, exp(coef), se(coef), z, p, lower, upper See Also -------- ``print_summary`` """ ci = 1 - self.alpha ...
[ "Summary", "statistics", "describing", "the", "fit", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L573-L596
[ "def", "summary", "(", "self", ")", ":", "ci", "=", "1", "-", "self", ".", "alpha", "lower_upper_bounds", "=", "self", ".", "_compute_confidence_bounds_of_parameters", "(", ")", "df", "=", "pd", ".", "DataFrame", "(", "index", "=", "self", ".", "_fitted_pa...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.print_summary
Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: print additional metadata in the output (useful to provide model n...
lifelines/fitters/__init__.py
def print_summary(self, decimals=2, **kwargs): """ Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: ...
def print_summary(self, decimals=2, **kwargs): """ Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: ...
[ "Print", "summary", "statistics", "describing", "the", "fit", "the", "coefficients", "and", "the", "error", "bounds", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L599-L638
[ "def", "print_summary", "(", "self", ",", "decimals", "=", "2", ",", "*", "*", "kwargs", ")", ":", "justify", "=", "string_justify", "(", "18", ")", "print", "(", "self", ")", "print", "(", "\"{} = {}\"", ".", "format", "(", "justify", "(", "\"number o...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.fit
Parameters ---------- durations: an array, or pd.Series length n, duration subject was observed for event_observed: numpy array or pd.Series, optional length n, True if the the death was observed, False if the event was lost (right-censored). Defaults all True if event_observ...
lifelines/fitters/__init__.py
def fit( self, durations, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, left_censorship=False, ): # pylint: disable=too-many-arguments """ ...
def fit( self, durations, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, left_censorship=False, ): # pylint: disable=too-many-arguments """ ...
[ "Parameters", "----------", "durations", ":", "an", "array", "or", "pd", ".", "Series", "length", "n", "duration", "subject", "was", "observed", "for", "event_observed", ":", "numpy", "array", "or", "pd", ".", "Series", "optional", "length", "n", "True", "if...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L640-L706
[ "def", "fit", "(", "self", ",", "durations", ",", "event_observed", "=", "None", ",", "timeline", "=", "None", ",", "label", "=", "None", ",", "alpha", "=", "None", ",", "ci_labels", "=", "None", ",", "show_progress", "=", "False", ",", "entry", "=", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.fit_left_censoring
Fit the model to a left-censored dataset Parameters ---------- durations: an array, or pd.Series length n, duration subject was observed for event_observed: numpy array or pd.Series, optional length n, True if the the death was observed, False if the event was lost (...
lifelines/fitters/__init__.py
def fit_left_censoring( self, durations, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, ): # pylint: disable=too-many-arguments """ Fit the mod...
def fit_left_censoring( self, durations, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, ): # pylint: disable=too-many-arguments """ Fit the mod...
[ "Fit", "the", "model", "to", "a", "left", "-", "censored", "dataset" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L708-L766
[ "def", "fit_left_censoring", "(", "self", ",", "durations", ",", "event_observed", "=", "None", ",", "timeline", "=", "None", ",", "label", "=", "None", ",", "alpha", "=", "None", ",", "ci_labels", "=", "None", ",", "show_progress", "=", "False", ",", "e...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.fit_interval_censoring
Fit the model to an interval censored dataset. Parameters ---------- lower_bound: an array, or pd.Series length n, the start of the period the subject experienced the event in. upper_bound: an array, or pd.Series length n, the end of the period the subject experience...
lifelines/fitters/__init__.py
def fit_interval_censoring( self, lower_bound, upper_bound, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, ): # pylint: disable=too-many-arguments ...
def fit_interval_censoring( self, lower_bound, upper_bound, event_observed=None, timeline=None, label=None, alpha=None, ci_labels=None, show_progress=False, entry=None, weights=None, ): # pylint: disable=too-many-arguments ...
[ "Fit", "the", "model", "to", "an", "interval", "censored", "dataset", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L768-L844
[ "def", "fit_interval_censoring", "(", "self", ",", "lower_bound", ",", "upper_bound", ",", "event_observed", "=", "None", ",", "timeline", "=", "None", ",", "label", "=", "None", ",", "alpha", "=", "None", ",", "ci_labels", "=", "None", ",", "show_progress",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.survival_function_at_times
Return a Pandas series of the predicted survival value at specific times. Parameters ----------- times: iterable or float values to return the survival function at. label: string, optional Rename the series returned. Useful for plotting. Returns ----...
lifelines/fitters/__init__.py
def survival_function_at_times(self, times, label=None): """ Return a Pandas series of the predicted survival value at specific times. Parameters ----------- times: iterable or float values to return the survival function at. label: string, optional R...
def survival_function_at_times(self, times, label=None): """ Return a Pandas series of the predicted survival value at specific times. Parameters ----------- times: iterable or float values to return the survival function at. label: string, optional R...
[ "Return", "a", "Pandas", "series", "of", "the", "predicted", "survival", "value", "at", "specific", "times", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L926-L943
[ "def", "survival_function_at_times", "(", "self", ",", "times", ",", "label", "=", "None", ")", ":", "label", "=", "coalesce", "(", "label", ",", "self", ".", "_label", ")", "return", "pd", ".", "Series", "(", "self", ".", "_survival_function", "(", "sel...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.cumulative_density_at_times
Return a Pandas series of the predicted cumulative density function (1-survival function) at specific times. Parameters ----------- times: iterable or float values to return the survival function at. label: string, optional Rename the series returned. Useful for plot...
lifelines/fitters/__init__.py
def cumulative_density_at_times(self, times, label=None): """ Return a Pandas series of the predicted cumulative density function (1-survival function) at specific times. Parameters ----------- times: iterable or float values to return the survival function at. ...
def cumulative_density_at_times(self, times, label=None): """ Return a Pandas series of the predicted cumulative density function (1-survival function) at specific times. Parameters ----------- times: iterable or float values to return the survival function at. ...
[ "Return", "a", "Pandas", "series", "of", "the", "predicted", "cumulative", "density", "function", "(", "1", "-", "survival", "function", ")", "at", "specific", "times", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L946-L963
[ "def", "cumulative_density_at_times", "(", "self", ",", "times", ",", "label", "=", "None", ")", ":", "label", "=", "coalesce", "(", "label", ",", "self", ".", "_label", ")", "return", "pd", ".", "Series", "(", "self", ".", "_cumulative_density", "(", "s...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.cumulative_hazard_at_times
Return a Pandas series of the predicted cumulative hazard value at specific times. Parameters ----------- times: iterable or float values to return the cumulative hazard at. label: string, optional Rename the series returned. Useful for plotting. Returns ...
lifelines/fitters/__init__.py
def cumulative_hazard_at_times(self, times, label=None): """ Return a Pandas series of the predicted cumulative hazard value at specific times. Parameters ----------- times: iterable or float values to return the cumulative hazard at. label: string, optional ...
def cumulative_hazard_at_times(self, times, label=None): """ Return a Pandas series of the predicted cumulative hazard value at specific times. Parameters ----------- times: iterable or float values to return the cumulative hazard at. label: string, optional ...
[ "Return", "a", "Pandas", "series", "of", "the", "predicted", "cumulative", "hazard", "value", "at", "specific", "times", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L966-L983
[ "def", "cumulative_hazard_at_times", "(", "self", ",", "times", ",", "label", "=", "None", ")", ":", "label", "=", "coalesce", "(", "label", ",", "self", ".", "_label", ")", "return", "pd", ".", "Series", "(", "self", ".", "_cumulative_hazard", "(", "sel...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.hazard_at_times
Return a Pandas series of the predicted hazard at specific times. Parameters ----------- times: iterable or float values to return the hazard at. label: string, optional Rename the series returned. Useful for plotting. Returns -------- pd.Ser...
lifelines/fitters/__init__.py
def hazard_at_times(self, times, label=None): """ Return a Pandas series of the predicted hazard at specific times. Parameters ----------- times: iterable or float values to return the hazard at. label: string, optional Rename the series returned. Use...
def hazard_at_times(self, times, label=None): """ Return a Pandas series of the predicted hazard at specific times. Parameters ----------- times: iterable or float values to return the hazard at. label: string, optional Rename the series returned. Use...
[ "Return", "a", "Pandas", "series", "of", "the", "predicted", "hazard", "at", "specific", "times", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L986-L1003
[ "def", "hazard_at_times", "(", "self", ",", "times", ",", "label", "=", "None", ")", ":", "label", "=", "coalesce", "(", "label", ",", "self", ".", "_label", ")", "return", "pd", ".", "Series", "(", "self", ".", "_hazard", "(", "self", ".", "_fitted_...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.confidence_interval_hazard_
The confidence interval of the hazard.
lifelines/fitters/__init__.py
def confidence_interval_hazard_(self): """ The confidence interval of the hazard. """ return self._compute_confidence_bounds_of_transform(self._hazard, self.alpha, self._ci_labels)
def confidence_interval_hazard_(self): """ The confidence interval of the hazard. """ return self._compute_confidence_bounds_of_transform(self._hazard, self.alpha, self._ci_labels)
[ "The", "confidence", "interval", "of", "the", "hazard", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1032-L1036
[ "def", "confidence_interval_hazard_", "(", "self", ")", ":", "return", "self", ".", "_compute_confidence_bounds_of_transform", "(", "self", ".", "_hazard", ",", "self", ".", "alpha", ",", "self", ".", "_ci_labels", ")" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.confidence_interval_survival_function_
The confidence interval of the survival function.
lifelines/fitters/__init__.py
def confidence_interval_survival_function_(self): """ The confidence interval of the survival function. """ return self._compute_confidence_bounds_of_transform(self._survival_function, self.alpha, self._ci_labels)
def confidence_interval_survival_function_(self): """ The confidence interval of the survival function. """ return self._compute_confidence_bounds_of_transform(self._survival_function, self.alpha, self._ci_labels)
[ "The", "confidence", "interval", "of", "the", "survival", "function", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1040-L1044
[ "def", "confidence_interval_survival_function_", "(", "self", ")", ":", "return", "self", ".", "_compute_confidence_bounds_of_transform", "(", "self", ".", "_survival_function", ",", "self", ".", "alpha", ",", "self", ".", "_ci_labels", ")" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.confidence_interval_cumulative_density_
The confidence interval of the survival function.
lifelines/fitters/__init__.py
def confidence_interval_cumulative_density_(self): """ The confidence interval of the survival function. """ return self._compute_confidence_bounds_of_transform(self._cumulative_density, self.alpha, self._ci_labels)
def confidence_interval_cumulative_density_(self): """ The confidence interval of the survival function. """ return self._compute_confidence_bounds_of_transform(self._cumulative_density, self.alpha, self._ci_labels)
[ "The", "confidence", "interval", "of", "the", "survival", "function", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1048-L1052
[ "def", "confidence_interval_cumulative_density_", "(", "self", ")", ":", "return", "self", ".", "_compute_confidence_bounds_of_transform", "(", "self", ".", "_cumulative_density", ",", "self", ".", "alpha", ",", "self", ".", "_ci_labels", ")" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericUnivariateFitter.plot
Produce a pretty-plot of the estimate.
lifelines/fitters/__init__.py
def plot(self, **kwargs): """ Produce a pretty-plot of the estimate. """ set_kwargs_drawstyle(kwargs, "default") return _plot_estimate( self, estimate=getattr(self, self._estimate_name), confidence_intervals=self.confidence_interval_, **kwargs )
def plot(self, **kwargs): """ Produce a pretty-plot of the estimate. """ set_kwargs_drawstyle(kwargs, "default") return _plot_estimate( self, estimate=getattr(self, self._estimate_name), confidence_intervals=self.confidence_interval_, **kwargs )
[ "Produce", "a", "pretty", "-", "plot", "of", "the", "estimate", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1055-L1062
[ "def", "plot", "(", "self", ",", "*", "*", "kwargs", ")", ":", "set_kwargs_drawstyle", "(", "kwargs", ",", "\"default\"", ")", "return", "_plot_estimate", "(", "self", ",", "estimate", "=", "getattr", "(", "self", ",", "self", ".", "_estimate_name", ")", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.fit
Fit the accelerated failure time model to a right-censored dataset. Parameters ---------- df: DataFrame a Pandas DataFrame with necessary columns `duration_col` and `event_col` (see below), covariates columns, and special columns (weights). `duration_col` ref...
lifelines/fitters/__init__.py
def fit( self, df, duration_col, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): """ Fit the accelerated failure time ...
def fit( self, df, duration_col, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): """ Fit the accelerated failure time ...
[ "Fit", "the", "accelerated", "failure", "time", "model", "to", "a", "right", "-", "censored", "dataset", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1215-L1325
[ "def", "fit", "(", "self", ",", "df", ",", "duration_col", ",", "event_col", "=", "None", ",", "ancillary_df", "=", "None", ",", "show_progress", "=", "False", ",", "timeline", "=", "None", ",", "weights_col", "=", "None", ",", "robust", "=", "False", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.fit_interval_censoring
Fit the accelerated failure time model to a left-censored dataset. Parameters ---------- df: DataFrame a Pandas DataFrame with necessary columns ``lower_bound_col``, ``upper_bound_col`` (see below), and any other covariates or weights. lower_bound_col: string ...
lifelines/fitters/__init__.py
def fit_interval_censoring( self, df, lower_bound_col, upper_bound_col, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): ...
def fit_interval_censoring( self, df, lower_bound_col, upper_bound_col, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): ...
[ "Fit", "the", "accelerated", "failure", "time", "model", "to", "a", "left", "-", "censored", "dataset", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1327-L1455
[ "def", "fit_interval_censoring", "(", "self", ",", "df", ",", "lower_bound_col", ",", "upper_bound_col", ",", "event_col", "=", "None", ",", "ancillary_df", "=", "None", ",", "show_progress", "=", "False", ",", "timeline", "=", "None", ",", "weights_col", "=",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.fit_left_censoring
Fit the accelerated failure time model to a left-censored dataset. Parameters ---------- df: DataFrame a Pandas DataFrame with necessary columns `duration_col` and `event_col` (see below), covariates columns, and special columns (weights). `duration_col` refe...
lifelines/fitters/__init__.py
def fit_left_censoring( self, df, duration_col=None, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): """ Fit the accel...
def fit_left_censoring( self, df, duration_col=None, event_col=None, ancillary_df=None, show_progress=False, timeline=None, weights_col=None, robust=False, initial_point=None, entry_col=None, ): """ Fit the accel...
[ "Fit", "the", "accelerated", "failure", "time", "model", "to", "a", "left", "-", "censored", "dataset", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1457-L1563
[ "def", "fit_left_censoring", "(", "self", ",", "df", ",", "duration_col", "=", "None", ",", "event_col", "=", "None", ",", "ancillary_df", "=", "None", ",", "show_progress", "=", "False", ",", "timeline", "=", "None", ",", "weights_col", "=", "None", ",", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter._create_initial_point
See https://github.com/CamDavidsonPilon/lifelines/issues/664
lifelines/fitters/__init__.py
def _create_initial_point(self, Ts, E, entries, weights, Xs): """ See https://github.com/CamDavidsonPilon/lifelines/issues/664 """ import lifelines # kinda hacky but lol def transform_ith_param(model, i): param = model._fitted_parameters_[i] if param <= ...
def _create_initial_point(self, Ts, E, entries, weights, Xs): """ See https://github.com/CamDavidsonPilon/lifelines/issues/664 """ import lifelines # kinda hacky but lol def transform_ith_param(model, i): param = model._fitted_parameters_[i] if param <= ...
[ "See", "https", ":", "//", "github", ".", "com", "/", "CamDavidsonPilon", "/", "lifelines", "/", "issues", "/", "664" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1674-L1706
[ "def", "_create_initial_point", "(", "self", ",", "Ts", ",", "E", ",", "entries", ",", "weights", ",", "Xs", ")", ":", "import", "lifelines", "# kinda hacky but lol", "def", "transform_ith_param", "(", "model", ",", "i", ")", ":", "param", "=", "model", "....
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.predict_median
Predict the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be ...
lifelines/fitters/__init__.py
def predict_median(self, X, ancillary_X=None): """ Predict the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate nu...
def predict_median(self, X, ancillary_X=None): """ Predict the median lifetimes for the individuals. If the survival curve of an individual does not cross 0.5, then the result is infinity. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate nu...
[ "Predict", "the", "median", "lifetimes", "for", "the", "individuals", ".", "If", "the", "survival", "curve", "of", "an", "individual", "does", "not", "cross", "0", ".", "5", "then", "the", "result", "is", "infinity", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L1979-L2007
[ "def", "predict_median", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ")", ":", "return", "self", ".", "predict_percentile", "(", "X", ",", "p", "=", "0.5", ",", "ancillary_X", "=", "ancillary_X", ")" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.score_
The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the training dataset.
lifelines/fitters/__init__.py
def score_(self): """ The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the trai...
def score_(self): """ The concordance score (also known as the c-index) of the fit. The c-index is a generalization of the ROC AUC to survival data, including censorships. For this purpose, the ``score_`` is a measure of the predictive accuracy of the fitted model onto the trai...
[ "The", "concordance", "score", "(", "also", "known", "as", "the", "c", "-", "index", ")", "of", "the", "fit", ".", "The", "c", "-", "index", "is", "a", "generalization", "of", "the", "ROC", "AUC", "to", "survival", "data", "including", "censorships", "...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L2010-L2024
[ "def", "score_", "(", "self", ")", ":", "# pylint: disable=access-member-before-definition", "if", "hasattr", "(", "self", ",", "\"_predicted_median\"", ")", ":", "self", ".", "_concordance_score_", "=", "concordance_index", "(", "self", ".", "durations", ",", "self...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.plot
Produces a visual representation of the coefficients, including their standard errors and magnitudes. Parameters ---------- columns : list, optional specify a subset of the columns to plot errorbar_kwargs: pass in additional plotting commands to matplotlib errorb...
lifelines/fitters/__init__.py
def plot(self, columns=None, parameter=None, **errorbar_kwargs): """ Produces a visual representation of the coefficients, including their standard errors and magnitudes. Parameters ---------- columns : list, optional specify a subset of the columns to plot e...
def plot(self, columns=None, parameter=None, **errorbar_kwargs): """ Produces a visual representation of the coefficients, including their standard errors and magnitudes. Parameters ---------- columns : list, optional specify a subset of the columns to plot e...
[ "Produces", "a", "visual", "representation", "of", "the", "coefficients", "including", "their", "standard", "errors", "and", "magnitudes", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L2038-L2105
[ "def", "plot", "(", "self", ",", "columns", "=", "None", ",", "parameter", "=", "None", ",", "*", "*", "errorbar_kwargs", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "set_kwargs_ax", "(", "errorbar_kwargs", ")", "ax", "=", "errorbar_kw...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
ParametericAFTRegressionFitter.plot_covariate_groups
Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' survival as we vary covariate(s), all else being held equal. The baseline survival curve is equal to t...
lifelines/fitters/__init__.py
def plot_covariate_groups(self, covariates, values, plot_baseline=True, **kwargs): """ Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' surviva...
def plot_covariate_groups(self, covariates, values, plot_baseline=True, **kwargs): """ Produces a visual representation comparing the baseline survival curve of the model versus what happens when a covariate(s) is varied over values in a group. This is useful to compare subjects' surviva...
[ "Produces", "a", "visual", "representation", "comparing", "the", "baseline", "survival", "curve", "of", "the", "model", "versus", "what", "happens", "when", "a", "covariate", "(", "s", ")", "is", "varied", "over", "values", "in", "a", "group", ".", "This", ...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/__init__.py#L2107-L2188
[ "def", "plot_covariate_groups", "(", "self", ",", "covariates", ",", "values", ",", "plot_baseline", "=", "True", ",", "*", "*", "kwargs", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "covariates", "=", "_to_list", "(", "covariates", ")",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogLogisticAFTFitter.predict_percentile
Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions Parameters ---------- X: numpy array or DataFrame ...
lifelines/fitters/log_logistic_aft_fitter.py
def predict_percentile(self, X, ancillary_X=None, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions ...
def predict_percentile(self, X, ancillary_X=None, p=0.5): """ Returns the median lifetimes for the individuals, by default. If the survival curve of an individual does not cross ``p``, then the result is infinity. http://stats.stackexchange.com/questions/102986/percentile-loss-functions ...
[ "Returns", "the", "median", "lifetimes", "for", "the", "individuals", "by", "default", ".", "If", "the", "survival", "curve", "of", "an", "individual", "does", "not", "cross", "p", "then", "the", "result", "is", "infinity", ".", "http", ":", "//", "stats",...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_logistic_aft_fitter.py#L94-L124
[ "def", "predict_percentile", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ",", "p", "=", "0.5", ")", ":", "alpha_", ",", "beta_", "=", "self", ".", "_prep_inputs_for_prediction_and_return_scores", "(", "X", ",", "ancillary_X", ")", "return", "pd",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogLogisticAFTFitter.predict_expectation
Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order as the train...
lifelines/fitters/log_logistic_aft_fitter.py
def predict_expectation(self, X, ancillary_X=None): """ Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a...
def predict_expectation(self, X, ancillary_X=None): """ Predict the expectation of lifetimes, :math:`E[T | x]`. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a...
[ "Predict", "the", "expectation", "of", "lifetimes", ":", "math", ":", "E", "[", "T", "|", "x", "]", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_logistic_aft_fitter.py#L126-L155
[ "def", "predict_expectation", "(", "self", ",", "X", ",", "ancillary_X", "=", "None", ")", ":", "alpha_", ",", "beta_", "=", "self", ".", "_prep_inputs_for_prediction_and_return_scores", "(", "X", ",", "ancillary_X", ")", "v", "=", "(", "alpha_", "*", "np", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
LogLogisticAFTFitter.predict_cumulative_hazard
Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns can be in any order. If a numpy array, columns must be in the same order a...
lifelines/fitters/log_logistic_aft_fitter.py
def predict_cumulative_hazard(self, X, times=None, ancillary_X=None): """ Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns ...
def predict_cumulative_hazard(self, X, times=None, ancillary_X=None): """ Return the cumulative hazard rate of subjects in X at time points. Parameters ---------- X: numpy array or DataFrame a (n,d) covariate numpy array or DataFrame. If a DataFrame, columns ...
[ "Return", "the", "cumulative", "hazard", "rate", "of", "subjects", "in", "X", "at", "time", "points", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/log_logistic_aft_fitter.py#L157-L183
[ "def", "predict_cumulative_hazard", "(", "self", ",", "X", ",", "times", "=", "None", ",", "ancillary_X", "=", "None", ")", ":", "times", "=", "coalesce", "(", "times", ",", "self", ".", "timeline", ",", "np", ".", "unique", "(", "self", ".", "duration...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
NelsonAalenFitter.fit
Parameters ----------- durations: an array, or pd.Series, of length n duration subject was observed for timeline: iterable return the best estimate at the values in timelines (positively increasing) event_observed: an array, or pd.Series, of length n Tru...
lifelines/fitters/nelson_aalen_fitter.py
def fit( self, durations, event_observed=None, timeline=None, entry=None, label="NA_estimate", alpha=None, ci_labels=None, weights=None, ): # pylint: disable=too-many-arguments """ Parameters ----------- duratio...
def fit( self, durations, event_observed=None, timeline=None, entry=None, label="NA_estimate", alpha=None, ci_labels=None, weights=None, ): # pylint: disable=too-many-arguments """ Parameters ----------- duratio...
[ "Parameters", "-----------", "durations", ":", "an", "array", "or", "pd", ".", "Series", "of", "length", "n", "duration", "subject", "was", "observed", "for", "timeline", ":", "iterable", "return", "the", "best", "estimate", "at", "the", "values", "in", "tim...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/nelson_aalen_fitter.py#L73-L152
[ "def", "fit", "(", "self", ",", "durations", ",", "event_observed", "=", "None", ",", "timeline", "=", "None", ",", "entry", "=", "None", ",", "label", "=", "\"NA_estimate\"", ",", "alpha", "=", "None", ",", "ci_labels", "=", "None", ",", "weights", "=...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
NelsonAalenFitter.smoothed_hazard_
Parameters ----------- bandwidth: float the bandwith used in the Epanechnikov kernel. Returns ------- DataFrame: a DataFrame of the smoothed hazard
lifelines/fitters/nelson_aalen_fitter.py
def smoothed_hazard_(self, bandwidth): """ Parameters ----------- bandwidth: float the bandwith used in the Epanechnikov kernel. Returns ------- DataFrame: a DataFrame of the smoothed hazard """ timeline = self.timeline ...
def smoothed_hazard_(self, bandwidth): """ Parameters ----------- bandwidth: float the bandwith used in the Epanechnikov kernel. Returns ------- DataFrame: a DataFrame of the smoothed hazard """ timeline = self.timeline ...
[ "Parameters", "-----------", "bandwidth", ":", "float", "the", "bandwith", "used", "in", "the", "Epanechnikov", "kernel", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/nelson_aalen_fitter.py#L202-L225
[ "def", "smoothed_hazard_", "(", "self", ",", "bandwidth", ")", ":", "timeline", "=", "self", ".", "timeline", "cumulative_hazard_name", "=", "self", ".", "cumulative_hazard_", ".", "columns", "[", "0", "]", "hazard_name", "=", "\"differenced-\"", "+", "cumulativ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
NelsonAalenFitter.smoothed_hazard_confidence_intervals_
Parameters ---------- bandwidth: float the bandwidth to use in the Epanechnikov kernel. > 0 hazard_: numpy array a computed (n,) numpy array of estimated hazard rates. If none, uses ``smoothed_hazard_``
lifelines/fitters/nelson_aalen_fitter.py
def smoothed_hazard_confidence_intervals_(self, bandwidth, hazard_=None): """ Parameters ---------- bandwidth: float the bandwidth to use in the Epanechnikov kernel. > 0 hazard_: numpy array a computed (n,) numpy array of estimated hazard rates. If non...
def smoothed_hazard_confidence_intervals_(self, bandwidth, hazard_=None): """ Parameters ---------- bandwidth: float the bandwidth to use in the Epanechnikov kernel. > 0 hazard_: numpy array a computed (n,) numpy array of estimated hazard rates. If non...
[ "Parameters", "----------", "bandwidth", ":", "float", "the", "bandwidth", "to", "use", "in", "the", "Epanechnikov", "kernel", ".", ">", "0", "hazard_", ":", "numpy", "array", "a", "computed", "(", "n", ")", "numpy", "array", "of", "estimated", "hazard", "...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/nelson_aalen_fitter.py#L227-L255
[ "def", "smoothed_hazard_confidence_intervals_", "(", "self", ",", "bandwidth", ",", "hazard_", "=", "None", ")", ":", "if", "hazard_", "is", "None", ":", "hazard_", "=", "self", ".", "smoothed_hazard_", "(", "bandwidth", ")", ".", "values", "[", ":", ",", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_BTree._treeify
Convert the np.ndarray `values` into a complete balanced tree. Assumes `values` is sorted ascending. Returns a list `t` of the same length in which t[i] > t[2i+1] and t[i] < t[2i+2] for all i.
lifelines/utils/btree.py
def _treeify(values): """Convert the np.ndarray `values` into a complete balanced tree. Assumes `values` is sorted ascending. Returns a list `t` of the same length in which t[i] > t[2i+1] and t[i] < t[2i+2] for all i.""" if len(values) == 1: # this case causes problems later ...
def _treeify(values): """Convert the np.ndarray `values` into a complete balanced tree. Assumes `values` is sorted ascending. Returns a list `t` of the same length in which t[i] > t[2i+1] and t[i] < t[2i+2] for all i.""" if len(values) == 1: # this case causes problems later ...
[ "Convert", "the", "np", ".", "ndarray", "values", "into", "a", "complete", "balanced", "tree", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/btree.py#L30-L64
[ "def", "_treeify", "(", "values", ")", ":", "if", "len", "(", "values", ")", "==", "1", ":", "# this case causes problems later", "return", "values", "tree", "=", "np", ".", "empty_like", "(", "values", ")", "# Tree indices work as follows:", "# 0 is the root", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_BTree.insert
Insert an occurrence of `value` into the btree.
lifelines/utils/btree.py
def insert(self, value): """Insert an occurrence of `value` into the btree.""" i = 0 n = len(self._tree) while i < n: cur = self._tree[i] self._counts[i] += 1 if value < cur: i = 2 * i + 1 elif value > cur: i...
def insert(self, value): """Insert an occurrence of `value` into the btree.""" i = 0 n = len(self._tree) while i < n: cur = self._tree[i] self._counts[i] += 1 if value < cur: i = 2 * i + 1 elif value > cur: i...
[ "Insert", "an", "occurrence", "of", "value", "into", "the", "btree", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/btree.py#L66-L79
[ "def", "insert", "(", "self", ",", "value", ")", ":", "i", "=", "0", "n", "=", "len", "(", "self", ".", "_tree", ")", "while", "i", "<", "n", ":", "cur", "=", "self", ".", "_tree", "[", "i", "]", "self", ".", "_counts", "[", "i", "]", "+=",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_BTree.rank
Returns the rank and count of the value in the btree.
lifelines/utils/btree.py
def rank(self, value): """Returns the rank and count of the value in the btree.""" i = 0 n = len(self._tree) rank = 0 count = 0 while i < n: cur = self._tree[i] if value < cur: i = 2 * i + 1 continue elif...
def rank(self, value): """Returns the rank and count of the value in the btree.""" i = 0 n = len(self._tree) rank = 0 count = 0 while i < n: cur = self._tree[i] if value < cur: i = 2 * i + 1 continue elif...
[ "Returns", "the", "rank", "and", "count", "of", "the", "value", "in", "the", "btree", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/utils/btree.py#L84-L116
[ "def", "rank", "(", "self", ",", "value", ")", ":", "i", "=", "0", "n", "=", "len", "(", "self", ".", "_tree", ")", "rank", "=", "0", "count", "=", "0", "while", "i", "<", "n", ":", "cur", "=", "self", ".", "_tree", "[", "i", "]", "if", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
qq_plot
Produces a quantile-quantile plot of the empirical CDF against the fitted parametric CDF. Large deviances away from the line y=x can invalidate a model (though we expect some natural deviance in the tails). Parameters ----------- model: obj A fitted lifelines univariate parametric model, li...
lifelines/plotting.py
def qq_plot(model, **plot_kwargs): """ Produces a quantile-quantile plot of the empirical CDF against the fitted parametric CDF. Large deviances away from the line y=x can invalidate a model (though we expect some natural deviance in the tails). Parameters ----------- model: obj A f...
def qq_plot(model, **plot_kwargs): """ Produces a quantile-quantile plot of the empirical CDF against the fitted parametric CDF. Large deviances away from the line y=x can invalidate a model (though we expect some natural deviance in the tails). Parameters ----------- model: obj A f...
[ "Produces", "a", "quantile", "-", "quantile", "plot", "of", "the", "empirical", "CDF", "against", "the", "fitted", "parametric", "CDF", ".", "Large", "deviances", "away", "from", "the", "line", "y", "=", "x", "can", "invalidate", "a", "model", "(", "though...
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L79-L139
[ "def", "qq_plot", "(", "model", ",", "*", "*", "plot_kwargs", ")", ":", "from", "lifelines", ".", "utils", "import", "qth_survival_times", "from", "lifelines", "import", "KaplanMeierFitter", "set_kwargs_ax", "(", "plot_kwargs", ")", "ax", "=", "plot_kwargs", "."...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
remove_spines
Remove spines of axis. Parameters: ax: axes to operate on sides: list of sides: top, left, bottom, right Examples: removespines(ax, ['top']) removespines(ax, ['top', 'bottom', 'right', 'left'])
lifelines/plotting.py
def remove_spines(ax, sides): """ Remove spines of axis. Parameters: ax: axes to operate on sides: list of sides: top, left, bottom, right Examples: removespines(ax, ['top']) removespines(ax, ['top', 'bottom', 'right', 'left']) """ for side in sides: ax.spines[side]...
def remove_spines(ax, sides): """ Remove spines of axis. Parameters: ax: axes to operate on sides: list of sides: top, left, bottom, right Examples: removespines(ax, ['top']) removespines(ax, ['top', 'bottom', 'right', 'left']) """ for side in sides: ax.spines[side]...
[ "Remove", "spines", "of", "axis", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L152-L166
[ "def", "remove_spines", "(", "ax", ",", "sides", ")", ":", "for", "side", "in", "sides", ":", "ax", ".", "spines", "[", "side", "]", ".", "set_visible", "(", "False", ")", "return", "ax" ]
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
move_spines
Move the entire spine relative to the figure. Parameters: ax: axes to operate on sides: list of sides to move. Sides: top, left, bottom, right dists: list of float distances to move. Should match sides in length. Example: move_spines(ax, sides=['left', 'bottom'], dists=[-0.02, 0.1])
lifelines/plotting.py
def move_spines(ax, sides, dists): """ Move the entire spine relative to the figure. Parameters: ax: axes to operate on sides: list of sides to move. Sides: top, left, bottom, right dists: list of float distances to move. Should match sides in length. Example: move_spines(ax, sid...
def move_spines(ax, sides, dists): """ Move the entire spine relative to the figure. Parameters: ax: axes to operate on sides: list of sides to move. Sides: top, left, bottom, right dists: list of float distances to move. Should match sides in length. Example: move_spines(ax, sid...
[ "Move", "the", "entire", "spine", "relative", "to", "the", "figure", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L169-L183
[ "def", "move_spines", "(", "ax", ",", "sides", ",", "dists", ")", ":", "for", "side", ",", "dist", "in", "zip", "(", "sides", ",", "dists", ")", ":", "ax", ".", "spines", "[", "side", "]", ".", "set_position", "(", "(", "\"axes\"", ",", "dist", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
remove_ticks
Remove ticks from axis. Parameters: ax: axes to work on x: if True, remove xticks. Default False. y: if True, remove yticks. Default False. Examples: removeticks(ax, x=True) removeticks(ax, x=True, y=True)
lifelines/plotting.py
def remove_ticks(ax, x=False, y=False): """ Remove ticks from axis. Parameters: ax: axes to work on x: if True, remove xticks. Default False. y: if True, remove yticks. Default False. Examples: removeticks(ax, x=True) removeticks(ax, x=True, y=True) """ if x: ...
def remove_ticks(ax, x=False, y=False): """ Remove ticks from axis. Parameters: ax: axes to work on x: if True, remove xticks. Default False. y: if True, remove yticks. Default False. Examples: removeticks(ax, x=True) removeticks(ax, x=True, y=True) """ if x: ...
[ "Remove", "ticks", "from", "axis", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L186-L203
[ "def", "remove_ticks", "(", "ax", ",", "x", "=", "False", ",", "y", "=", "False", ")", ":", "if", "x", ":", "ax", ".", "xaxis", ".", "set_ticks_position", "(", "\"none\"", ")", "if", "y", ":", "ax", ".", "yaxis", ".", "set_ticks_position", "(", "\"...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
add_at_risk_counts
Add counts showing how many individuals were at risk at each time point in survival/hazard plots. Parameters ---------- fitters: One or several fitters, for example KaplanMeierFitter, NelsonAalenFitter, etc... Returns -------- ax: The axes which was used. Examples -...
lifelines/plotting.py
def add_at_risk_counts(*fitters, **kwargs): """ Add counts showing how many individuals were at risk at each time point in survival/hazard plots. Parameters ---------- fitters: One or several fitters, for example KaplanMeierFitter, NelsonAalenFitter, etc... Returns -------...
def add_at_risk_counts(*fitters, **kwargs): """ Add counts showing how many individuals were at risk at each time point in survival/hazard plots. Parameters ---------- fitters: One or several fitters, for example KaplanMeierFitter, NelsonAalenFitter, etc... Returns -------...
[ "Add", "counts", "showing", "how", "many", "individuals", "were", "at", "risk", "at", "each", "time", "point", "in", "survival", "/", "hazard", "plots", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L206-L302
[ "def", "add_at_risk_counts", "(", "*", "fitters", ",", "*", "*", "kwargs", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "# Axes and Figure can't be None", "ax", "=", "kwargs", ".", "get", "(", "\"ax\"", ",", "None", ")", "if", "ax", "is...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
plot_lifetimes
Returns a lifetime plot, see examples: https://lifelines.readthedocs.io/en/latest/Survival%20Analysis%20intro.html#Censoring Parameters ----------- durations: (n,) numpy array or pd.Series duration subject was observed for. event_observed: (n,) numpy array or pd.Series array of booleans: Tr...
lifelines/plotting.py
def plot_lifetimes( durations, event_observed=None, entry=None, left_truncated=False, sort_by_duration=True, event_observed_color="#A60628", event_censored_color="#348ABD", **kwargs ): """ Returns a lifetime plot, see examples: https://lifelines.readthedocs.io/en/latest/Survival%...
def plot_lifetimes( durations, event_observed=None, entry=None, left_truncated=False, sort_by_duration=True, event_observed_color="#A60628", event_censored_color="#348ABD", **kwargs ): """ Returns a lifetime plot, see examples: https://lifelines.readthedocs.io/en/latest/Survival%...
[ "Returns", "a", "lifetime", "plot", "see", "examples", ":", "https", ":", "//", "lifelines", ".", "readthedocs", ".", "io", "/", "en", "/", "latest", "/", "Survival%20Analysis%20intro", ".", "html#Censoring" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L305-L379
[ "def", "plot_lifetimes", "(", "durations", ",", "event_observed", "=", "None", ",", "entry", "=", "None", ",", "left_truncated", "=", "False", ",", "sort_by_duration", "=", "True", ",", "event_observed_color", "=", "\"#A60628\"", ",", "event_censored_color", "=", ...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
plot_loglogs
Specifies a plot of the log(-log(SV)) versus log(time) where SV is the estimated survival function.
lifelines/plotting.py
def plot_loglogs(cls, loc=None, iloc=None, show_censors=False, censor_styles=None, **kwargs): """ Specifies a plot of the log(-log(SV)) versus log(time) where SV is the estimated survival function. """ def loglog(s): return np.log(-np.log(s)) if (loc is not None) and (iloc is not None): ...
def plot_loglogs(cls, loc=None, iloc=None, show_censors=False, censor_styles=None, **kwargs): """ Specifies a plot of the log(-log(SV)) versus log(time) where SV is the estimated survival function. """ def loglog(s): return np.log(-np.log(s)) if (loc is not None) and (iloc is not None): ...
[ "Specifies", "a", "plot", "of", "the", "log", "(", "-", "log", "(", "SV", "))", "versus", "log", "(", "time", ")", "where", "SV", "is", "the", "estimated", "survival", "function", "." ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L409-L446
[ "def", "plot_loglogs", "(", "cls", ",", "loc", "=", "None", ",", "iloc", "=", "None", ",", "show_censors", "=", "False", ",", "censor_styles", "=", "None", ",", "*", "*", "kwargs", ")", ":", "def", "loglog", "(", "s", ")", ":", "return", "np", ".",...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
_plot_estimate
Plots a pretty figure of {0}.{1} Matplotlib plot arguments can be passed in inside the kwargs, plus Parameters ----------- show_censors: bool place markers at censorship events. Default: False censor_styles: bool If show_censors, this dictionary will be passed into the plot call. ...
lifelines/plotting.py
def _plot_estimate( cls, estimate=None, confidence_intervals=None, loc=None, iloc=None, show_censors=False, censor_styles=None, ci_legend=False, ci_force_lines=False, ci_alpha=0.25, ci_show=True, at_risk_counts=False, **kwargs ): """ Plots a pretty figure of ...
def _plot_estimate( cls, estimate=None, confidence_intervals=None, loc=None, iloc=None, show_censors=False, censor_styles=None, ci_legend=False, ci_force_lines=False, ci_alpha=0.25, ci_show=True, at_risk_counts=False, **kwargs ): """ Plots a pretty figure of ...
[ "Plots", "a", "pretty", "figure", "of", "{", "0", "}", ".", "{", "1", "}" ]
CamDavidsonPilon/lifelines
python
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/plotting.py#L449-L550
[ "def", "_plot_estimate", "(", "cls", ",", "estimate", "=", "None", ",", "confidence_intervals", "=", "None", ",", "loc", "=", "None", ",", "iloc", "=", "None", ",", "show_censors", "=", "False", ",", "censor_styles", "=", "None", ",", "ci_legend", "=", "...
bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8
train
translate_doc
translate a word document type of file and save the result as document and keep the exactly same file format. :param filename: word doc file :param destination='zh-CN': :param mix=True: if True, will have original language and target language into the same doc. paragraphs by paragraphs.
example/translate_word_doc.py
def translate_doc(filename, destination='zh-CN', mix=True): """ translate a word document type of file and save the result as document and keep the exactly same file format. :param filename: word doc file :param destination='zh-CN': :param mix=True: if True, will have original languag...
def translate_doc(filename, destination='zh-CN', mix=True): """ translate a word document type of file and save the result as document and keep the exactly same file format. :param filename: word doc file :param destination='zh-CN': :param mix=True: if True, will have original languag...
[ "translate", "a", "word", "document", "type", "of", "file", "and", "save", "the", "result", "as", "document", "and", "keep", "the", "exactly", "same", "file", "format", ".", ":", "param", "filename", ":", "word", "doc", "file", ":", "param", "destination",...
ssut/py-googletrans
python
https://github.com/ssut/py-googletrans/blob/4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81/example/translate_word_doc.py#L5-L26
[ "def", "translate_doc", "(", "filename", ",", "destination", "=", "'zh-CN'", ",", "mix", "=", "True", ")", ":", "def", "tx", "(", "t", ")", ":", "return", "Translator", "(", ")", ".", "translate", "(", "t", ",", "dest", "=", "destination", ")", ".", ...
4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81
train
Translator.translate
Translate text from source language to destination language :param text: The source text(s) to be translated. Batch translation is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, generator) :param dest: The language to tra...
googletrans/client.py
def translate(self, text, dest='en', src='auto'): """Translate text from source language to destination language :param text: The source text(s) to be translated. Batch translation is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, i...
def translate(self, text, dest='en', src='auto'): """Translate text from source language to destination language :param text: The source text(s) to be translated. Batch translation is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, i...
[ "Translate", "text", "from", "source", "language", "to", "destination", "language" ]
ssut/py-googletrans
python
https://github.com/ssut/py-googletrans/blob/4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81/googletrans/client.py#L106-L209
[ "def", "translate", "(", "self", ",", "text", ",", "dest", "=", "'en'", ",", "src", "=", "'auto'", ")", ":", "dest", "=", "dest", ".", "lower", "(", ")", ".", "split", "(", "'_'", ",", "1", ")", "[", "0", "]", "src", "=", "src", ".", "lower",...
4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81
train
Translator.detect
Detect language of the input text :param text: The source text(s) whose language you want to identify. Batch detection is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, generator) :rtype: Detected ...
googletrans/client.py
def detect(self, text): """Detect language of the input text :param text: The source text(s) whose language you want to identify. Batch detection is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, gener...
def detect(self, text): """Detect language of the input text :param text: The source text(s) whose language you want to identify. Batch detection is supported via sequence input. :type text: UTF-8 :class:`str`; :class:`unicode`; string sequence (list, tuple, iterator, gener...
[ "Detect", "language", "of", "the", "input", "text" ]
ssut/py-googletrans
python
https://github.com/ssut/py-googletrans/blob/4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81/googletrans/client.py#L211-L262
[ "def", "detect", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "text", ",", "list", ")", ":", "result", "=", "[", "]", "for", "item", "in", "text", ":", "lang", "=", "self", ".", "detect", "(", "item", ")", "result", ".", "append",...
4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81
train
TokenAcquirer._update
update tkk
googletrans/gtoken.py
def _update(self): """update tkk """ # we don't need to update the base TKK value when it is still valid now = math.floor(int(time.time() * 1000) / 3600000.0) if self.tkk and int(self.tkk.split('.')[0]) == now: return r = self.session.get(self.host) ...
def _update(self): """update tkk """ # we don't need to update the base TKK value when it is still valid now = math.floor(int(time.time() * 1000) / 3600000.0) if self.tkk and int(self.tkk.split('.')[0]) == now: return r = self.session.get(self.host) ...
[ "update", "tkk" ]
ssut/py-googletrans
python
https://github.com/ssut/py-googletrans/blob/4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81/googletrans/gtoken.py#L49-L111
[ "def", "_update", "(", "self", ")", ":", "# we don't need to update the base TKK value when it is still valid", "now", "=", "math", ".", "floor", "(", "int", "(", "time", ".", "time", "(", ")", "*", "1000", ")", "/", "3600000.0", ")", "if", "self", ".", "tkk...
4aebfb18faa45a7d7817fbd4b8fe8ff502bf9e81
train
make_wheel_filename_generic
Wheel filenames contain the python version and the python ABI version for the wheel. https://www.python.org/dev/peps/pep-0427/#file-name-convention Since we're distributing a rust binary this doesn't matter for us ...
ci/build_wheels.py
def make_wheel_filename_generic(wheel): """ Wheel filenames contain the python version and the python ABI version for the wheel. https://www.python.org/dev/peps/pep-0427/#file-name-convention Since we're distributing a rust binary this doesn't matter for us ... """ name, version, python, abi, platform =...
def make_wheel_filename_generic(wheel): """ Wheel filenames contain the python version and the python ABI version for the wheel. https://www.python.org/dev/peps/pep-0427/#file-name-convention Since we're distributing a rust binary this doesn't matter for us ... """ name, version, python, abi, platform =...
[ "Wheel", "filenames", "contain", "the", "python", "version", "and", "the", "python", "ABI", "version", "for", "the", "wheel", ".", "https", ":", "//", "www", ".", "python", ".", "org", "/", "dev", "/", "peps", "/", "pep", "-", "0427", "/", "#file", "...
benfred/py-spy
python
https://github.com/benfred/py-spy/blob/3629dc85066e1b342b886db468ac9438bf960266/ci/build_wheels.py#L16-L31
[ "def", "make_wheel_filename_generic", "(", "wheel", ")", ":", "name", ",", "version", ",", "python", ",", "abi", ",", "platform", "=", "wheel", ".", "split", "(", "\"-\"", ")", "# our binary handles multiple abi/versions of python", "python", ",", "abi", "=", "\...
3629dc85066e1b342b886db468ac9438bf960266
train
Embedding.most_frequent
Only most frequent k words to be included in the embeddings.
polyglot/mapping/embeddings.py
def most_frequent(self, k, inplace=False): """Only most frequent k words to be included in the embeddings.""" vocabulary = self.vocabulary.most_frequent(k) vectors = np.asarray([self[w] for w in vocabulary]) if inplace: self.vocabulary = vocabulary self.vectors = vectors return self ...
def most_frequent(self, k, inplace=False): """Only most frequent k words to be included in the embeddings.""" vocabulary = self.vocabulary.most_frequent(k) vectors = np.asarray([self[w] for w in vocabulary]) if inplace: self.vocabulary = vocabulary self.vectors = vectors return self ...
[ "Only", "most", "frequent", "k", "words", "to", "be", "included", "in", "the", "embeddings", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L80-L88
[ "def", "most_frequent", "(", "self", ",", "k", ",", "inplace", "=", "False", ")", ":", "vocabulary", "=", "self", ".", "vocabulary", ".", "most_frequent", "(", "k", ")", "vectors", "=", "np", ".", "asarray", "(", "[", "self", "[", "w", "]", "for", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.normalize_words
Normalize embeddings matrix row-wise. Args: ord: normalization order. Possible values {1, 2, 'inf', '-inf'}
polyglot/mapping/embeddings.py
def normalize_words(self, ord=2, inplace=False): """Normalize embeddings matrix row-wise. Args: ord: normalization order. Possible values {1, 2, 'inf', '-inf'} """ if ord == 2: ord = None # numpy uses this flag to indicate l2. vectors = self.vectors.T / np.linalg.norm(self.vectors, ord,...
def normalize_words(self, ord=2, inplace=False): """Normalize embeddings matrix row-wise. Args: ord: normalization order. Possible values {1, 2, 'inf', '-inf'} """ if ord == 2: ord = None # numpy uses this flag to indicate l2. vectors = self.vectors.T / np.linalg.norm(self.vectors, ord,...
[ "Normalize", "embeddings", "matrix", "row", "-", "wise", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L90-L102
[ "def", "normalize_words", "(", "self", ",", "ord", "=", "2", ",", "inplace", "=", "False", ")", ":", "if", "ord", "==", "2", ":", "ord", "=", "None", "# numpy uses this flag to indicate l2.", "vectors", "=", "self", ".", "vectors", ".", "T", "/", "np", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.nearest_neighbors
Return the nearest k words to the given `word`. Args: word (string): single word. top_k (integer): decides how many neighbors to report. Returns: A list of words sorted by the distances. The closest is the first. Note: L2 metric is used to calculate distances.
polyglot/mapping/embeddings.py
def nearest_neighbors(self, word, top_k=10): """Return the nearest k words to the given `word`. Args: word (string): single word. top_k (integer): decides how many neighbors to report. Returns: A list of words sorted by the distances. The closest is the first. Note: L2 metric ...
def nearest_neighbors(self, word, top_k=10): """Return the nearest k words to the given `word`. Args: word (string): single word. top_k (integer): decides how many neighbors to report. Returns: A list of words sorted by the distances. The closest is the first. Note: L2 metric ...
[ "Return", "the", "nearest", "k", "words", "to", "the", "given", "word", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L104-L122
[ "def", "nearest_neighbors", "(", "self", ",", "word", ",", "top_k", "=", "10", ")", ":", "#TODO(rmyeid): Use scikit ball tree, if scikit is available", "point", "=", "self", "[", "word", "]", "diff", "=", "self", ".", "vectors", "-", "point", "distances", "=", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.distances
Calculate eucledean pairwise distances between `word` and `words`. Args: word (string): single word. words (list): list of strings. Returns: numpy array of the distances. Note: L2 metric is used to calculate distances.
polyglot/mapping/embeddings.py
def distances(self, word, words): """Calculate eucledean pairwise distances between `word` and `words`. Args: word (string): single word. words (list): list of strings. Returns: numpy array of the distances. Note: L2 metric is used to calculate distances. """ point = ...
def distances(self, word, words): """Calculate eucledean pairwise distances between `word` and `words`. Args: word (string): single word. words (list): list of strings. Returns: numpy array of the distances. Note: L2 metric is used to calculate distances. """ point = ...
[ "Calculate", "eucledean", "pairwise", "distances", "between", "word", "and", "words", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L128-L146
[ "def", "distances", "(", "self", ",", "word", ",", "words", ")", ":", "point", "=", "self", "[", "word", "]", "vectors", "=", "np", ".", "asarray", "(", "[", "self", "[", "w", "]", "for", "w", "in", "words", "]", ")", "diff", "=", "vectors", "-...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.from_word2vec
Load the input-hidden weight matrix from the original C word2vec-tool format. Note that the information stored in the file is incomplete (the binary tree is missing), so while you can query for word similarity etc., you cannot continue training with a model loaded this way. `binary` is a boolean indic...
polyglot/mapping/embeddings.py
def from_word2vec(fname, fvocab=None, binary=False): """ Load the input-hidden weight matrix from the original C word2vec-tool format. Note that the information stored in the file is incomplete (the binary tree is missing), so while you can query for word similarity etc., you cannot continue training ...
def from_word2vec(fname, fvocab=None, binary=False): """ Load the input-hidden weight matrix from the original C word2vec-tool format. Note that the information stored in the file is incomplete (the binary tree is missing), so while you can query for word similarity etc., you cannot continue training ...
[ "Load", "the", "input", "-", "hidden", "weight", "matrix", "from", "the", "original", "C", "word2vec", "-", "tool", "format", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L226-L252
[ "def", "from_word2vec", "(", "fname", ",", "fvocab", "=", "None", ",", "binary", "=", "False", ")", ":", "vocabulary", "=", "None", "if", "fvocab", "is", "not", "None", ":", "logger", ".", "info", "(", "\"loading word counts from %s\"", "%", "(", "fvocab",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.load
Load an embedding dump generated by `save`
polyglot/mapping/embeddings.py
def load(fname): """Load an embedding dump generated by `save`""" content = _open(fname).read() if PY2: state = pickle.loads(content) else: state = pickle.loads(content, encoding='latin1') voc, vec = state if len(voc) == 2: words, counts = voc word_count = dict(zip(words...
def load(fname): """Load an embedding dump generated by `save`""" content = _open(fname).read() if PY2: state = pickle.loads(content) else: state = pickle.loads(content, encoding='latin1') voc, vec = state if len(voc) == 2: words, counts = voc word_count = dict(zip(words...
[ "Load", "an", "embedding", "dump", "generated", "by", "save" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L295-L310
[ "def", "load", "(", "fname", ")", ":", "content", "=", "_open", "(", "fname", ")", ".", "read", "(", ")", "if", "PY2", ":", "state", "=", "pickle", ".", "loads", "(", "content", ")", "else", ":", "state", "=", "pickle", ".", "loads", "(", "conten...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Embedding.save
Save a pickled version of the embedding into `fname`.
polyglot/mapping/embeddings.py
def save(self, fname): """Save a pickled version of the embedding into `fname`.""" vec = self.vectors voc = self.vocabulary.getstate() state = (voc, vec) with open(fname, 'wb') as f: pickle.dump(state, f, protocol=pickle.HIGHEST_PROTOCOL)
def save(self, fname): """Save a pickled version of the embedding into `fname`.""" vec = self.vectors voc = self.vocabulary.getstate() state = (voc, vec) with open(fname, 'wb') as f: pickle.dump(state, f, protocol=pickle.HIGHEST_PROTOCOL)
[ "Save", "a", "pickled", "version", "of", "the", "embedding", "into", "fname", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/mapping/embeddings.py#L312-L319
[ "def", "save", "(", "self", ",", "fname", ")", ":", "vec", "=", "self", ".", "vectors", "voc", "=", "self", ".", "vocabulary", ".", "getstate", "(", ")", "state", "=", "(", "voc", ",", "vec", ")", "with", "open", "(", "fname", ",", "'wb'", ")", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
unzip
Extract the contents of the zip file ``filename`` into the directory ``root``.
polyglot/downloader.py
def unzip(filename, root, verbose=True): """ Extract the contents of the zip file ``filename`` into the directory ``root``. """ for message in _unzip_iter(filename, root, verbose): if isinstance(message, ErrorMessage): raise Exception(message)
def unzip(filename, root, verbose=True): """ Extract the contents of the zip file ``filename`` into the directory ``root``. """ for message in _unzip_iter(filename, root, verbose): if isinstance(message, ErrorMessage): raise Exception(message)
[ "Extract", "the", "contents", "of", "the", "zip", "file", "filename", "into", "the", "directory", "root", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1212-L1219
[ "def", "unzip", "(", "filename", ",", "root", ",", "verbose", "=", "True", ")", ":", "for", "message", "in", "_unzip_iter", "(", "filename", ",", "root", ",", "verbose", ")", ":", "if", "isinstance", "(", "message", ",", "ErrorMessage", ")", ":", "rais...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
build_index
Create a new data.xml index file, by combining the xml description files for various packages and collections. ``root`` should be the path to a directory containing the package xml and zip files; and the collection xml files. The ``root`` directory is expected to have the following subdirectories:: root/...
polyglot/downloader.py
def build_index(root, base_url): """ Create a new data.xml index file, by combining the xml description files for various packages and collections. ``root`` should be the path to a directory containing the package xml and zip files; and the collection xml files. The ``root`` directory is expected to have ...
def build_index(root, base_url): """ Create a new data.xml index file, by combining the xml description files for various packages and collections. ``root`` should be the path to a directory containing the package xml and zip files; and the collection xml files. The ``root`` directory is expected to have ...
[ "Create", "a", "new", "data", ".", "xml", "index", "file", "by", "combining", "the", "xml", "description", "files", "for", "various", "packages", "and", "collections", ".", "root", "should", "be", "the", "path", "to", "a", "directory", "containing", "the", ...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1280-L1344
[ "def", "build_index", "(", "root", ",", "base_url", ")", ":", "# Find all packages.", "packages", "=", "[", "]", "for", "pkg_xml", ",", "zf", ",", "subdir", "in", "_find_packages", "(", "os", ".", "path", ".", "join", "(", "root", ",", "'packages'", ")",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_indent_xml
Helper for ``build_index()``: Given an XML ``ElementTree``, modify it (and its descendents) ``text`` and ``tail`` attributes to generate an indented tree, where each nested element is indented by 2 spaces with respect to its parent.
polyglot/downloader.py
def _indent_xml(xml, prefix=''): """ Helper for ``build_index()``: Given an XML ``ElementTree``, modify it (and its descendents) ``text`` and ``tail`` attributes to generate an indented tree, where each nested element is indented by 2 spaces with respect to its parent. """ if len(xml) > 0: xml.text = ...
def _indent_xml(xml, prefix=''): """ Helper for ``build_index()``: Given an XML ``ElementTree``, modify it (and its descendents) ``text`` and ``tail`` attributes to generate an indented tree, where each nested element is indented by 2 spaces with respect to its parent. """ if len(xml) > 0: xml.text = ...
[ "Helper", "for", "build_index", "()", ":", "Given", "an", "XML", "ElementTree", "modify", "it", "(", "and", "its", "descendents", ")", "text", "and", "tail", "attributes", "to", "generate", "an", "indented", "tree", "where", "each", "nested", "element", "is"...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1346-L1359
[ "def", "_indent_xml", "(", "xml", ",", "prefix", "=", "''", ")", ":", "if", "len", "(", "xml", ")", ">", "0", ":", "xml", ".", "text", "=", "(", "xml", ".", "text", "or", "''", ")", ".", "strip", "(", ")", "+", "'\\n'", "+", "prefix", "+", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_check_package
Helper for ``build_index()``: Perform some checks to make sure that the given package is consistent.
polyglot/downloader.py
def _check_package(pkg_xml, zipfilename, zf): """ Helper for ``build_index()``: Perform some checks to make sure that the given package is consistent. """ # The filename must patch the id given in the XML file. uid = os.path.splitext(os.path.split(zipfilename)[1])[0] if pkg_xml.get('id') != uid: raise...
def _check_package(pkg_xml, zipfilename, zf): """ Helper for ``build_index()``: Perform some checks to make sure that the given package is consistent. """ # The filename must patch the id given in the XML file. uid = os.path.splitext(os.path.split(zipfilename)[1])[0] if pkg_xml.get('id') != uid: raise...
[ "Helper", "for", "build_index", "()", ":", "Perform", "some", "checks", "to", "make", "sure", "that", "the", "given", "package", "is", "consistent", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1361-L1376
[ "def", "_check_package", "(", "pkg_xml", ",", "zipfilename", ",", "zf", ")", ":", "# The filename must patch the id given in the XML file.", "uid", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "split", "(", "zipfilename", ")", "[", "1"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_svn_revision
Helper for ``build_index()``: Calculate the subversion revision number for a given file (by using ``subprocess`` to run ``svn``).
polyglot/downloader.py
def _svn_revision(filename): """ Helper for ``build_index()``: Calculate the subversion revision number for a given file (by using ``subprocess`` to run ``svn``). """ p = subprocess.Popen(['svn', 'status', '-v', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, st...
def _svn_revision(filename): """ Helper for ``build_index()``: Calculate the subversion revision number for a given file (by using ``subprocess`` to run ``svn``). """ p = subprocess.Popen(['svn', 'status', '-v', filename], stdout=subprocess.PIPE, stderr=subprocess.PIPE) (stdout, st...
[ "Helper", "for", "build_index", "()", ":", "Calculate", "the", "subversion", "revision", "number", "for", "a", "given", "file", "(", "by", "using", "subprocess", "to", "run", "svn", ")", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1379-L1391
[ "def", "_svn_revision", "(", "filename", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "[", "'svn'", ",", "'status'", ",", "'-v'", ",", "filename", "]", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "PIPE"...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_find_collections
Helper for ``build_index()``: Yield a list of ElementTree.Element objects, each holding the xml for a single package collection.
polyglot/downloader.py
def _find_collections(root): """ Helper for ``build_index()``: Yield a list of ElementTree.Element objects, each holding the xml for a single package collection. """ packages = [] for dirname, subdirs, files in os.walk(root): for filename in files: if filename.endswith('.xml'): xmlfile = o...
def _find_collections(root): """ Helper for ``build_index()``: Yield a list of ElementTree.Element objects, each holding the xml for a single package collection. """ packages = [] for dirname, subdirs, files in os.walk(root): for filename in files: if filename.endswith('.xml'): xmlfile = o...
[ "Helper", "for", "build_index", "()", ":", "Yield", "a", "list", "of", "ElementTree", ".", "Element", "objects", "each", "holding", "the", "xml", "for", "a", "single", "package", "collection", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1393-L1403
[ "def", "_find_collections", "(", "root", ")", ":", "packages", "=", "[", "]", "for", "dirname", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "root", ")", ":", "for", "filename", "in", "files", ":", "if", "filename", ".", "endswith", "(...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
_find_packages
Helper for ``build_index()``: Yield a list of tuples ``(pkg_xml, zf, subdir)``, where: - ``pkg_xml`` is an ``ElementTree.Element`` holding the xml for a package - ``zf`` is a ``zipfile.ZipFile`` for the package's contents. - ``subdir`` is the subdirectory (relative to ``root``) where the package w...
polyglot/downloader.py
def _find_packages(root): """ Helper for ``build_index()``: Yield a list of tuples ``(pkg_xml, zf, subdir)``, where: - ``pkg_xml`` is an ``ElementTree.Element`` holding the xml for a package - ``zf`` is a ``zipfile.ZipFile`` for the package's contents. - ``subdir`` is the subdirectory (relative to...
def _find_packages(root): """ Helper for ``build_index()``: Yield a list of tuples ``(pkg_xml, zf, subdir)``, where: - ``pkg_xml`` is an ``ElementTree.Element`` holding the xml for a package - ``zf`` is a ``zipfile.ZipFile`` for the package's contents. - ``subdir`` is the subdirectory (relative to...
[ "Helper", "for", "build_index", "()", ":", "Yield", "a", "list", "of", "tuples", "(", "pkg_xml", "zf", "subdir", ")", "where", ":", "-", "pkg_xml", "is", "an", "ElementTree", ".", "Element", "holding", "the", "xml", "for", "a", "package", "-", "zf", "i...
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1405-L1448
[ "def", "_find_packages", "(", "root", ")", ":", "# Find all packages.", "packages", "=", "[", "]", "for", "dirname", ",", "subdirs", ",", "files", "in", "os", ".", "walk", "(", "root", ")", ":", "relpath", "=", "'/'", ".", "join", "(", "_path_from", "(...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.status
Return a constant describing the status of the given package or collection. Status can be one of ``INSTALLED``, ``NOT_INSTALLED``, ``STALE``, or ``PARTIAL``.
polyglot/downloader.py
def status(self, info_or_id, download_dir=None): """ Return a constant describing the status of the given package or collection. Status can be one of ``INSTALLED``, ``NOT_INSTALLED``, ``STALE``, or ``PARTIAL``. """ if download_dir is None: download_dir = self._download_dir info = self._info...
def status(self, info_or_id, download_dir=None): """ Return a constant describing the status of the given package or collection. Status can be one of ``INSTALLED``, ``NOT_INSTALLED``, ``STALE``, or ``PARTIAL``. """ if download_dir is None: download_dir = self._download_dir info = self._info...
[ "Return", "a", "constant", "describing", "the", "status", "of", "the", "given", "package", "or", "collection", ".", "Status", "can", "be", "one", "of", "INSTALLED", "NOT_INSTALLED", "STALE", "or", "PARTIAL", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L730-L763
[ "def", "status", "(", "self", ",", "info_or_id", ",", "download_dir", "=", "None", ")", ":", "if", "download_dir", "is", "None", ":", "download_dir", "=", "self", ".", "_download_dir", "info", "=", "self", ".", "_info_or_id", "(", "info_or_id", ")", "# Han...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.update
Re-download any packages whose status is STALE.
polyglot/downloader.py
def update(self, quiet=False, prefix='[polyglot_data] '): """ Re-download any packages whose status is STALE. """ self.clear_status_cache() for pkg in self.packages(): if self.status(pkg) == self.STALE: self.download(pkg, quiet=quiet, prefix=prefix)
def update(self, quiet=False, prefix='[polyglot_data] '): """ Re-download any packages whose status is STALE. """ self.clear_status_cache() for pkg in self.packages(): if self.status(pkg) == self.STALE: self.download(pkg, quiet=quiet, prefix=prefix)
[ "Re", "-", "download", "any", "packages", "whose", "status", "is", "STALE", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L794-L801
[ "def", "update", "(", "self", ",", "quiet", "=", "False", ",", "prefix", "=", "'[polyglot_data] '", ")", ":", "self", ".", "clear_status_cache", "(", ")", "for", "pkg", "in", "self", ".", "packages", "(", ")", ":", "if", "self", ".", "status", "(", "...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader._update_index
A helper function that ensures that self._index is up-to-date. If the index is older than self.INDEX_TIMEOUT, then download it again.
polyglot/downloader.py
def _update_index(self, url=None): """A helper function that ensures that self._index is up-to-date. If the index is older than self.INDEX_TIMEOUT, then download it again.""" # Check if the index is aleady up-to-date. If so, do nothing. if not (self._index is None or url is not None or tim...
def _update_index(self, url=None): """A helper function that ensures that self._index is up-to-date. If the index is older than self.INDEX_TIMEOUT, then download it again.""" # Check if the index is aleady up-to-date. If so, do nothing. if not (self._index is None or url is not None or tim...
[ "A", "helper", "function", "that", "ensures", "that", "self", ".", "_index", "is", "up", "-", "to", "-", "date", ".", "If", "the", "index", "is", "older", "than", "self", ".", "INDEX_TIMEOUT", "then", "download", "it", "again", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L807-L911
[ "def", "_update_index", "(", "self", ",", "url", "=", "None", ")", ":", "# Check if the index is aleady up-to-date. If so, do nothing.", "if", "not", "(", "self", ".", "_index", "is", "None", "or", "url", "is", "not", "None", "or", "time", ".", "time", "(", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.info
Return the ``Package`` or ``Collection`` record for the given item.
polyglot/downloader.py
def info(self, id): """Return the ``Package`` or ``Collection`` record for the given item.""" #self._update_index() # This is commented because it leads to # excessive network load if id in self._packages: return self._packages[id] if id in self._collections: return self...
def info(self, id): """Return the ``Package`` or ``Collection`` record for the given item.""" #self._update_index() # This is commented because it leads to # excessive network load if id in self._packages: return self._packages[id] if id in self._collections: return self...
[ "Return", "the", "Package", "or", "Collection", "record", "for", "the", "given", "item", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L922-L933
[ "def", "info", "(", "self", ",", "id", ")", ":", "#self._update_index() # This is commented because it leads to", "# excessive network load", "if", "id", "in", "self", ".", "_packages", ":", "return", "self", ".", "_packages", "[", "id", "]", "if", "id", "in", "...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.get_collection
Return the collection that represents a specific language or task. Args: lang (string): Language code. task (string): Task name.
polyglot/downloader.py
def get_collection(self, lang=None, task=None): """ Return the collection that represents a specific language or task. Args: lang (string): Language code. task (string): Task name. """ if lang: id = "{}{}".format(Downloader.LANG_PREFIX, lang) elif task: id = "{}{}".format(Downloader.TAS...
def get_collection(self, lang=None, task=None): """ Return the collection that represents a specific language or task. Args: lang (string): Language code. task (string): Task name. """ if lang: id = "{}{}".format(Downloader.LANG_PREFIX, lang) elif task: id = "{}{}".format(Downloader.TAS...
[ "Return", "the", "collection", "that", "represents", "a", "specific", "language", "or", "task", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L935-L949
[ "def", "get_collection", "(", "self", ",", "lang", "=", "None", ",", "task", "=", "None", ")", ":", "if", "lang", ":", "id", "=", "\"{}{}\"", ".", "format", "(", "Downloader", ".", "LANG_PREFIX", ",", "lang", ")", "elif", "task", ":", "id", "=", "\...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.supported_language
Return True if polyglot supports the language. Args: lang (string): Language code.
polyglot/downloader.py
def supported_language(lang): """Return True if polyglot supports the language. Args: lang (string): Language code. """ try: self.get_collection(lang=lang) return True except LanguageNotSupported as e: return False
def supported_language(lang): """Return True if polyglot supports the language. Args: lang (string): Language code. """ try: self.get_collection(lang=lang) return True except LanguageNotSupported as e: return False
[ "Return", "True", "if", "polyglot", "supports", "the", "language", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L951-L961
[ "def", "supported_language", "(", "lang", ")", ":", "try", ":", "self", ".", "get_collection", "(", "lang", "=", "lang", ")", "return", "True", "except", "LanguageNotSupported", "as", "e", ":", "return", "False" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.supported_languages
Languages that are covered by a specific task. Args: task (string): Task name.
polyglot/downloader.py
def supported_languages(self, task=None): """Languages that are covered by a specific task. Args: task (string): Task name. """ if task: collection = self.get_collection(task=task) return [isoLangs[x.id.split('.')[1]]["name"] for x in collectio...
def supported_languages(self, task=None): """Languages that are covered by a specific task. Args: task (string): Task name. """ if task: collection = self.get_collection(task=task) return [isoLangs[x.id.split('.')[1]]["name"] for x in collectio...
[ "Languages", "that", "are", "covered", "by", "a", "specific", "task", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L963-L975
[ "def", "supported_languages", "(", "self", ",", "task", "=", "None", ")", ":", "if", "task", ":", "collection", "=", "self", ".", "get_collection", "(", "task", "=", "task", ")", "return", "[", "isoLangs", "[", "x", ".", "id", ".", "split", "(", "'.'...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.supported_tasks
Languages that are covered by a specific task. Args: lang (string): Language code name.
polyglot/downloader.py
def supported_tasks(self, lang=None): """Languages that are covered by a specific task. Args: lang (string): Language code name. """ if lang: collection = self.get_collection(lang=lang) return [x.id.split('.')[0] for x in collection.packages] else: return [x.name.split()[0] ...
def supported_tasks(self, lang=None): """Languages that are covered by a specific task. Args: lang (string): Language code name. """ if lang: collection = self.get_collection(lang=lang) return [x.id.split('.')[0] for x in collection.packages] else: return [x.name.split()[0] ...
[ "Languages", "that", "are", "covered", "by", "a", "specific", "task", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L982-L992
[ "def", "supported_tasks", "(", "self", ",", "lang", "=", "None", ")", ":", "if", "lang", ":", "collection", "=", "self", ".", "get_collection", "(", "lang", "=", "lang", ")", "return", "[", "x", ".", "id", ".", "split", "(", "'.'", ")", "[", "0", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader.xmlinfo
Return the XML info record for the given item
polyglot/downloader.py
def xmlinfo(self, id): """Return the XML info record for the given item""" self._update_index() for package in self._index.findall('packages/package'): if package.get('id') == id: return package for collection in self._index.findall('collections/collection'): if collection.get('id') ...
def xmlinfo(self, id): """Return the XML info record for the given item""" self._update_index() for package in self._index.findall('packages/package'): if package.get('id') == id: return package for collection in self._index.findall('collections/collection'): if collection.get('id') ...
[ "Return", "the", "XML", "info", "record", "for", "the", "given", "item" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L994-L1003
[ "def", "xmlinfo", "(", "self", ",", "id", ")", ":", "self", ".", "_update_index", "(", ")", "for", "package", "in", "self", ".", "_index", ".", "findall", "(", "'packages/package'", ")", ":", "if", "package", ".", "get", "(", "'id'", ")", "==", "id",...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Downloader._set_url
Set a new URL for the data server. If we're unable to contact the given url, then the original url is kept.
polyglot/downloader.py
def _set_url(self, url): """ Set a new URL for the data server. If we're unable to contact the given url, then the original url is kept. """ original_url = self._url try: self._update_index(url) except: self._url = original_url raise
def _set_url(self, url): """ Set a new URL for the data server. If we're unable to contact the given url, then the original url is kept. """ original_url = self._url try: self._update_index(url) except: self._url = original_url raise
[ "Set", "a", "new", "URL", "for", "the", "data", "server", ".", "If", "we", "re", "unable", "to", "contact", "the", "given", "url", "then", "the", "original", "url", "is", "kept", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/downloader.py#L1013-L1023
[ "def", "_set_url", "(", "self", ",", "url", ")", ":", "original_url", "=", "self", ".", "_url", "try", ":", "self", ".", "_update_index", "(", "url", ")", "except", ":", "self", ".", "_url", "=", "original_url", "raise" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Transliterator._decoder
Transliterate a string from English to the target language.
polyglot/transliteration/base.py
def _decoder(self): """Transliterate a string from English to the target language.""" if self.target_lang == 'en': return Transliterator._dummy_coder else: weights = load_transliteration_table(self.target_lang) decoder_weights = weights["decoder"] return Transliterator._transliterate...
def _decoder(self): """Transliterate a string from English to the target language.""" if self.target_lang == 'en': return Transliterator._dummy_coder else: weights = load_transliteration_table(self.target_lang) decoder_weights = weights["decoder"] return Transliterator._transliterate...
[ "Transliterate", "a", "string", "from", "English", "to", "the", "target", "language", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/transliteration/base.py#L33-L40
[ "def", "_decoder", "(", "self", ")", ":", "if", "self", ".", "target_lang", "==", "'en'", ":", "return", "Transliterator", ".", "_dummy_coder", "else", ":", "weights", "=", "load_transliteration_table", "(", "self", ".", "target_lang", ")", "decoder_weights", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Transliterator._encoder
Transliterate a string from the input language to English.
polyglot/transliteration/base.py
def _encoder(self): """Transliterate a string from the input language to English.""" if self.source_lang == 'en': return Transliterator._dummy_coder else: weights = load_transliteration_table(self.source_lang) encoder_weights = weights["encoder"] return Transliterator._transliterate_...
def _encoder(self): """Transliterate a string from the input language to English.""" if self.source_lang == 'en': return Transliterator._dummy_coder else: weights = load_transliteration_table(self.source_lang) encoder_weights = weights["encoder"] return Transliterator._transliterate_...
[ "Transliterate", "a", "string", "from", "the", "input", "language", "to", "English", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/transliteration/base.py#L42-L49
[ "def", "_encoder", "(", "self", ")", ":", "if", "self", ".", "source_lang", "==", "'en'", ":", "return", "Transliterator", ".", "_dummy_coder", "else", ":", "weights", "=", "load_transliteration_table", "(", "self", ".", "source_lang", ")", "encoder_weights", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
Transliterator.transliterate
Transliterate the word from its source language to the target one. The method works by encoding the word into English then decoding the new Enlgish word to the target language.
polyglot/transliteration/base.py
def transliterate(self, word): """Transliterate the word from its source language to the target one. The method works by encoding the word into English then decoding the new Enlgish word to the target language. """ encoded_word = self.encoder(word) decoded_word = self.decoder(encoded_word) ...
def transliterate(self, word): """Transliterate the word from its source language to the target one. The method works by encoding the word into English then decoding the new Enlgish word to the target language. """ encoded_word = self.encoder(word) decoded_word = self.decoder(encoded_word) ...
[ "Transliterate", "the", "word", "from", "its", "source", "language", "to", "the", "target", "one", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/transliteration/base.py#L56-L64
[ "def", "transliterate", "(", "self", ",", "word", ")", ":", "encoded_word", "=", "self", ".", "encoder", "(", "word", ")", "decoded_word", "=", "self", ".", "decoder", "(", "encoded_word", ")", "return", "decoded_word" ]
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.tokens
Return a list of tokens, using this blob's tokenizer object (defaults to :class:`WordTokenizer <textblob.tokenizers.WordTokenizer>`).
polyglot/text.py
def tokens(self): """Return a list of tokens, using this blob's tokenizer object (defaults to :class:`WordTokenizer <textblob.tokenizers.WordTokenizer>`). """ seq = self.word_tokenizer.transform(Sequence(self.raw)) return WordList(seq.tokens(), parent=self, language=self.language.code)
def tokens(self): """Return a list of tokens, using this blob's tokenizer object (defaults to :class:`WordTokenizer <textblob.tokenizers.WordTokenizer>`). """ seq = self.word_tokenizer.transform(Sequence(self.raw)) return WordList(seq.tokens(), parent=self, language=self.language.code)
[ "Return", "a", "list", "of", "tokens", "using", "this", "blob", "s", "tokenizer", "object", "(", "defaults", "to", ":", "class", ":", "WordTokenizer", "<textblob", ".", "tokenizers", ".", "WordTokenizer", ">", ")", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L77-L82
[ "def", "tokens", "(", "self", ")", ":", "seq", "=", "self", ".", "word_tokenizer", ".", "transform", "(", "Sequence", "(", "self", ".", "raw", ")", ")", "return", "WordList", "(", "seq", ".", "tokens", "(", ")", ",", "parent", "=", "self", ",", "la...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.polarity
Return the polarity score as a float within the range [-1.0, 1.0]
polyglot/text.py
def polarity(self): """Return the polarity score as a float within the range [-1.0, 1.0] """ scores = [w.polarity for w in self.words if w.polarity != 0] if not scores: return 0.0 return sum(scores) / float(len(scores))
def polarity(self): """Return the polarity score as a float within the range [-1.0, 1.0] """ scores = [w.polarity for w in self.words if w.polarity != 0] if not scores: return 0.0 return sum(scores) / float(len(scores))
[ "Return", "the", "polarity", "score", "as", "a", "float", "within", "the", "range", "[", "-", "1", ".", "0", "1", ".", "0", "]" ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L93-L99
[ "def", "polarity", "(", "self", ")", ":", "scores", "=", "[", "w", ".", "polarity", "for", "w", "in", "self", ".", "words", "if", "w", ".", "polarity", "!=", "0", "]", "if", "not", "scores", ":", "return", "0.0", "return", "sum", "(", "scores", "...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.transliterate
Transliterate the string to the target language.
polyglot/text.py
def transliterate(self, target_language="en"): """Transliterate the string to the target language.""" return WordList([w.transliterate(target_language) for w in self.words], language=target_language, parent=self)
def transliterate(self, target_language="en"): """Transliterate the string to the target language.""" return WordList([w.transliterate(target_language) for w in self.words], language=target_language, parent=self)
[ "Transliterate", "the", "string", "to", "the", "target", "language", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L117-L120
[ "def", "transliterate", "(", "self", ",", "target_language", "=", "\"en\"", ")", ":", "return", "WordList", "(", "[", "w", ".", "transliterate", "(", "target_language", ")", "for", "w", "in", "self", ".", "words", "]", ",", "language", "=", "target_languag...
d0d2aa8d06cec4e03bd96618ae960030f7069a17
train
BaseBlob.entities
Returns a list of entities for this blob.
polyglot/text.py
def entities(self): """Returns a list of entities for this blob.""" start = 0 end = 0 prev_tag = u'O' chunks = [] for i, (w, tag) in enumerate(self.ne_chunker.annotate(self.words)): if tag != prev_tag: if prev_tag == u'O': start = i else: chunks.append(C...
def entities(self): """Returns a list of entities for this blob.""" start = 0 end = 0 prev_tag = u'O' chunks = [] for i, (w, tag) in enumerate(self.ne_chunker.annotate(self.words)): if tag != prev_tag: if prev_tag == u'O': start = i else: chunks.append(C...
[ "Returns", "a", "list", "of", "entities", "for", "this", "blob", "." ]
aboSamoor/polyglot
python
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/text.py#L129-L146
[ "def", "entities", "(", "self", ")", ":", "start", "=", "0", "end", "=", "0", "prev_tag", "=", "u'O'", "chunks", "=", "[", "]", "for", "i", ",", "(", "w", ",", "tag", ")", "in", "enumerate", "(", "self", ".", "ne_chunker", ".", "annotate", "(", ...
d0d2aa8d06cec4e03bd96618ae960030f7069a17