Exemple #1
0
    # try with different random_state.
    for i in range(1, 10):
        stop = lambda ind: ind.fitness.values[0] >= 0.95
        sl = SymbolLearning(loop="MultiMutateLoop", pset=pset0, gen=20, pop=1000, hall=1, batch_size=40, re_hall=3,
                            n_jobs=12, mate_prob=0.9, max_value=h_bgp, initial_min=2, initial_max=h_bgp,
                            mutate_prob=0.8, tq=False, dim_type="coef", stop_condition=stop,
                            re_Tree=0, store=False, random_state=4, verbose=True,
                            # stats=None,
                            stats={"fitness_dim_max": ["max"], "dim_is_target": ["sum"], "h_bgp": ["mean"]},
                            add_coef=True, inter_add=True, out_add=True, cal_dim=True, vector_add=True,
                            personal_map=False)
        tt.t
        sl.fit()
        tt.t
        tt.p
        score = sl.score(x, y, "r2")
        print(sl.expr)
        y_pre = sl.predict(x)
        break

    # just for shown
    # y_pre = si_transformer.scale_y * y_pre
    # ssc = Dim.inverse_convert(y_dim, target_units=eV)[0]
    # y_pre = y_pre * ssc
    #
    # p = BasePlot(font=None)
    # p.scatter(Y, y_pre, strx='Experimental $E_{gap}$', stry='Calculated $E_{gap}$')
    # import matplotlib.pyplot as plt
    #
    # plt.show()
Exemple #2
0
                        dim_type="coef",
                        stop_condition=stop,
                        re_Tree=0,
                        random_state=0,
                        verbose=True,
                        add_coef=True,
                        inter_add=True,
                        cal_dim=False,
                        inner_add=True,
                        personal_map=False)

    # sl.fit()
    print(sl.expr)

    y_pre = sl.predict(X)
    score_all = sl.score(X, y, "r2")

    p = BasePlot(font=None)
    p.scatter(y,
              y_pre,
              strx='Experimental $E_{gap}$',
              stry='Calculated $E_{gap}$')
    import matplotlib.pyplot as plt

    plt.show()

    y_pre = sl.predict(X_test)
    score_test = sl.score(X_test, y_test, "r2")

    p = BasePlot(font=None)
    p.scatter(y_test,
Exemple #3
0
                        n_jobs=16,
                        initial_max=2,
                        max_value=4,
                        store=True,
                        stats={"fitness_dim_max": ("max", )})
    sl.fit(
        x,
        y,
        x_dim=[pa_dim, dless, dless, dless, dless, dless, dless],
        y_dim=pa_dim,
        power_categories=(2, 3, 0.5, 0.33),
        categories=("Add", "Mul", "Sub", "Div"),
    )

    print(sl.expr)
    r2 = sl.score(x, y, "r2")
    mae = sl.score(x, y, "neg_mean_absolute_error")
    pre_y = sl.predict(x)

    r = np.corrcoef(np.vstack((pre_y, y)))[1, 0]

    error = np.mean(np.abs((y - pre_y) / y))

    r2 = sl.score(x, y, "r2")
    mae = sl.score(x, y, "neg_mean_absolute_error")
    sl.loop.cpset.cv = 5
    r2_cv = sl.cv_result(refit=False)
    print("r:{},error:{},r2:{},MAE:{},r2_cv:{}".format(r, error, r2, mae,
                                                       r2_cv[0]))

    data = sl.loop.top_n(20, ascending=False)