Exemple #1
0
        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()

    from sklearn.linear_model import LinearRegression
Exemple #2
0
                        tq=True,
                        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)
Exemple #3
0
        ],
        cal_dim=True,
        inner_add=True,
        out_add=False,
        n_jobs=10,
    )
    #
    # 方式选择4,系数加在公式内层,不考虑量纲计算,
    # sl = SymbolLearning(loop="MultiMutateLoop", pop=200, gen=10, random_state=1,pset=pset0,
    #                     classification=True, scoring=[metrics.accuracy_score, ], score_pen=[1, ],
    #                     cal_dim=False,
    #                     inner_add=False, out_add=False,
    #                     n_jobs = 2,)
    # #
    # # 方式选择5,,公式项全部展开,每一项前面加系数(非常复杂),不考虑量纲计算,
    # pset0.y_dim = None
    # sl = SymbolLearning(loop="MultiMutateLoop", pop=1000, gen=20, random_state=1,pset=pset0,
    #                     classification=True, scoring=[metrics.accuracy_score, ], score_pen=[1, ],
    #                     cal_dim=False, flat_add=True, out_add=False,
    #                     n_jobs = 10,)
    #
    # # 方式选择6,,公式项全部展开,每一项前面加系数(非常复杂),不考虑量纲计算, 公式复杂度不限制
    # pset0.y_dim = None
    # sl = SymbolLearning(loop="MultiMutateLoop", pop=1000, gen=10, random_state=1, max_value=7,pset=pset0,
    #                     classification=True, scoring=[metrics.accuracy_score, ], score_pen=[1, ],
    #                     cal_dim=False, flat_add=True, out_add=False,
    #                     n_jobs = 10,)
    sl.fit(x, y)
    pre_y = sl.predict(x)
    print(sl.expr)