示例#1
0
    Y = y_frame.values
    X, Y = shuffle(X, Y, random_state=5)
    x, y = X, Y

    # y_unit
    from sympy.physics.units import eV, elementary_charge, m, pm

    y_u = eV
    # c_unit
    c = [1, 5.290 * 10**-11, 1.74, 2, 3, 4, 1 / 2, 1 / 3, 1 / 4]
    c_u = [
        elementary_charge, m, dless, dless, dless, dless, dless, dless, dless
    ]
    """preprocessing"""
    dims = [
        Dim.convert_to_Dim(i, target_units=None, unit_system="SI") for i in x_u
    ]

    x, x_dim = Dim.convert_x(x, x_u, target_units=None, unit_system="SI")
    y, y_dim = Dim.convert_xi(y, y_u)
    c, c_dim = Dim.convert_x(c, c_u)

    scal = MagnitudeTransformer(tolerate=1)

    group = 2
    n = X.shape[1]
    indexes = [_ for _ in range(n)]
    group = [indexes[i:i + group] for i in range(2, len(indexes), group)]
    x, y = scal.fit_transform_all(x, y, group=group)
    c = scal.fit_transform_constant(c)
    store.to_pkl_pd(scal, "si_transformer")
示例#2
0
from bgp.skflow import SymbolLearning

if __name__ == "__main__":

    # 数据
    data = pd.read_csv("204-6.csv")
    data_np = data.values
    x = data_np[:, 1:]
    y = data_np[:, 0]

    # 量纲
    from sympy.physics.units import kg, m, pa, J, mol, K
    from bgp.functions.dimfunc import Dim, dless

    # 由单位获得缩放因子和量纲
    gpa_dim = Dim.convert_to_Dim(1e9 * pa, unit_system="SI")
    j_d_mol_dim = Dim.convert_to_Dim(1000 * J / mol, unit_system="SI")
    K_dim = Dim.convert_to_Dim(K, unit_system="SI")
    kg_d_m3_dim = Dim.convert_to_Dim(kg / m**3, unit_system="SI")

    # 忽视缩放因子
    y_dim = dless
    x_dim = [
        dless, gpa_dim[1], j_d_mol_dim[1], K_dim[1], dless, kg_d_m3_dim[1]
    ]

    # 符号集合
    pset0 = SymbolSet()
    pset0.add_features(x, y, x_dim=x_dim, y_dim=y_dim)
    pset0.add_operations(
        power_categories=(2, 3, 0.5),