Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
same order as the training data.
Returns
-------
DataFrame
Note
-----
If X is a DataFrame, the order of the columns do not matter. But
if X is an array, then the column ordering is assumed to be the
same as the training dataset.
"""
if isinstance(X, pd.DataFrame):
order = self.params_.index
X = X[order]
check_for_numeric_dtypes_or_raise(X)
X = X.astype(float)
index = _get_index(X)
X = normalize(X, self._norm_mean.values, 1)
return pd.DataFrame(np.dot(X, self.params_), index=index)
def _check_values_pre_fitting(self, X, T, E, W):
check_low_var(X)
check_for_numeric_dtypes_or_raise(X)
check_nans_or_infs(T)
check_nans_or_infs(X)
# check to make sure their weights are okay
if self.weights_col:
if (W.astype(int) != W).any() and not self.robust:
warnings.warn(
"""It appears your weights are not integers, possibly propensity or sampling scores then?
It's important to know that the naive variance estimates of the coefficients are biased. Instead a) set `robust=True` in the call to `fit`, or b) use Monte Carlo to
estimate the variances. See paper "Variance estimation when using inverse probability of treatment weighting (IPTW) with survival analysis"
""",
StatisticalWarning,
)
if (W <= 0).any():
raise ValueError("values in weight column %s must be positive." % self.weights_col)
def _check_values_pre_fitting(self, df, T, E, weights, entries):
utils.check_for_numeric_dtypes_or_raise(df)
utils.check_nans_or_infs(df)
utils.check_nans_or_infs(T)
utils.check_nans_or_infs(E)
utils.check_positivity(T)
if self.weights_col:
if (weights.astype(int) != weights).any() and not self.robust:
warnings.warn(
dedent(
"""It appears your weights are not integers, possibly propensity or sampling scores then?
It's important to know that the naive variance estimates of the coefficients are biased. Instead a) set `robust=True` in the call to `fit`, or b) use Monte Carlo to
estimate the variances. See paper "Variance estimation when using inverse probability of treatment weighting (IPTW) with survival analysis"""
),
utils.StatisticalWarning,
)
if (weights <= 0).any():
def _check_values(self, df, events, start, stop):
# check_for_overlapping_intervals(df) # this is currently too slow for production.
check_nans_or_infs(df)
check_low_var(df)
check_complete_separation_low_variance(df, events, self.event_col)
check_for_numeric_dtypes_or_raise(df)
check_for_immediate_deaths(events, start, stop)
check_for_instantaneous_events_at_time_zero(start, stop)
check_for_instantaneous_events_at_death_time(events, start, stop)