def test_cox_cc_runs(numpy): data = make_dataset(False).apply(lambda x: x.float()).to_numpy() if not numpy: data = data.to_tensor() net = tt.practical.MLPVanilla(data[0].shape[1], [4], 1, False, output_bias=False) model = CoxPH(net) fit_model(data, model) model.compute_baseline_hazards() assert_survs(data[0], model)
def test_cox_time_runs(numpy): input, target = make_dataset(False).apply(lambda x: x.float()).to_numpy() labtrans = CoxTime.label_transform() target = labtrans.fit_transform(*target) data = tt.tuplefy(input, target) if not numpy: data = data.to_tensor() net = MLPVanillaCoxTime(data[0].shape[1], [4], False) model = CoxTime(net) fit_model(data, model) model.compute_baseline_hazards() assert_survs(data[0], model)
def test_pmf_runs(numpy, num_durations): data = make_dataset(True) input, target = data labtrans = PMF.label_transform(num_durations) target = labtrans.fit_transform(*target) data = tt.tuplefy(input, target) if not numpy: data = data.to_tensor() net = tt.practical.MLPVanilla(input.shape[1], [4], labtrans.out_features) model = PMF(net) fit_model(data, model) assert_survs(input, model) model.duration_index = labtrans.cuts assert_survs(input, model) cdi = model.interpolate(3, 'const_pdf') assert_survs(input, cdi)
def test_pc_hazard_runs(numpy, num_durations): data = make_dataset(True) input, (durations, events) = data durations += 1 target = (durations, events) labtrans = PCHazard.label_transform(num_durations) target = labtrans.fit_transform(*target) data = tt.tuplefy(input, target) if not numpy: data = data.to_tensor() net = tt.practical.MLPVanilla(input.shape[1], [4], num_durations) model = PCHazard(net) fit_model(data, model) assert_survs(input, model) model.duration_index = labtrans.cuts assert_survs(input, model)