Ejemplo n.º 1
0
def run(run_name=DEFAULT_RUN_NAME, trials=5, patient_count=2000,
        num_effects=[1, 2, 4, 8], observed_variables=[50], per_effect=[5],
        effect_mag=[1], sim_model=1, systematic_bias=0.1, input_variance=0.1,
        missing_data=0):
    i = 0
    patients_list = []

    for effects in num_effects:
        for ov in observed_variables:
            # for pe in per_effect:
            for mag in effect_mag:
                for trial in range(trials):
                    patients = sim.create_patients(patient_count=patient_count,
                                                   observed_variables=ov,
                                                   systematic_bias=systematic_bias,
                                                   input_variance=input_variance,
                                                   effects=effects,
                                                   per_effect=per_effect,
                                                   effect_mag=mag,
                                                   trial=trial,
                                                   sim_model=sim_model,
                                                   missing_data=missing_data)

                    file_name = ('./data/' + run_name + '/patients/' +
                                 str(sim_model) + '_' + str(effects) + '_' +
                                 str(per_effect) + '_' + str(mag) + '_' +
                                 str(ov) + '_' + str(trial) + '.p')

                    pkl.dump(patients, open(file_name, "wb"),
                             protocol=2)
                    del patients
                    print(i)
                    i += 1
Ejemplo n.º 2
0
    def testDaRun(self):
        p = 100
        hn = 2

        patients = sim.create_patients(patient_count=p,
                                       observed_variables=100,
                                       systematic_bias=0.1,
                                       input_variance=0.1,
                                       effects=4,
                                       per_effect=5,
                                       effect_mag=5,
                                       trial=1,
                                       sim_model=1,
                                       missing_data=0)
        X = patients[:, :-1]
        y = patients[:, -1]

        dAs = {}
        dAs[p] = {}
        dAs[p][hn] = trainer.train_da(X,
                                      learning_rate=0.1,
                                      coruption_rate=0.2,
                                      batch_size=10,
                                      training_epochs=1000,
                                      n_hidden=hn,
                                      missing_data=None)

        self.assertTrue(str(dAs[p][hn].trained_cost)[:7] == str(3.78843))

        scores = classifier.classify(X, y, dAs)
        print(scores)

        da_rfc_scores = [
            1.0, 1.0, 1.0, 0.90000000000000002, 1.0, 1.0, 0.96000000000000008,
            1.0, 0.78000000000000003, 1.0
        ]
        rfc_score_name = 'da_' + str(p) + '_' + str(hn) + '_rfc'
        self.assertTrue(scores[rfc_score_name] == da_rfc_scores)
Ejemplo n.º 3
0
    def testDaRun(self):
        p = 100
        hn = 2

        patients = sim.create_patients(patient_count=p,
                                       observed_variables=100,
                                       systematic_bias=0.1,
                                       input_variance=0.1,
                                       effects=4,
                                       per_effect=5,
                                       effect_mag=5,
                                       trial=1,
                                       sim_model=1,
                                       missing_data=0)
        X = patients[:, :-1]
        y = patients[:, -1]

        dAs = {}
        dAs[p] = {}
        dAs[p][hn] = trainer.train_da(X,
                                      learning_rate=0.1,
                                      coruption_rate=0.2,
                                      batch_size=10,
                                      training_epochs=1000,
                                      n_hidden=hn,
                                      missing_data=None)

        self.assertTrue(str(dAs[p][hn].trained_cost)[:7] == str(3.78843))

        scores = classifier.classify(X, y, dAs)
        print(scores)

        da_rfc_scores = [1.0, 1.0, 1.0, 0.90000000000000002, 1.0, 1.0,
                         0.96000000000000008, 1.0, 0.78000000000000003, 1.0]
        rfc_score_name = 'da_' + str(p) + '_' + str(hn) + '_rfc'
        self.assertTrue(scores[rfc_score_name] == da_rfc_scores)