Example #1
0
#                                                  [-3, [0]],
#                                                  [-2, [1]],
#                                                  [-1, [2]]],
#                               operate_linkage=[[-1, -2], ],
#                               # variable_linkage = None
#                               )
#
#     result = mainPart(X, y, pset1, pop_n=500, random_seed=2, cxpb=0.8, mutpb=0.1, ngen=20,
#                        inter_add=True, iner_add=False, random_add=False, score=[explained_variance_score, r2_score])
#     ret = result[2][1]

if __name__ == "__main__":
    store = Store(
        r'C:\Users\Administrator\Desktop\band_gap_exp_last\4.symbollearning')
    data_cluster = Call(
        r'C:\Users\Administrator\Desktop\band_gap_exp_last\1.generate_data',
        r'C:\Users\Administrator\Desktop\band_gap_exp_last\3.MMGS')

    all_import_structure = data_cluster.csv.all_import_structure
    data_import = all_import_structure

    select_gs = [
        'destiny', 'energy cohesive brewer', 'distance core electron(schubert)'
    ]
    select_gs = ['destiny'
                 ] + [j + "_%i" % i for j in select_gs[1:] for i in range(2)]

    data216_import = data_import.iloc[np.where(
        data_import['group_number'] == 216)[0]]
    data225_import = data_import.iloc[np.where(
        data_import['group_number'] == 225)[0]]
from featurebox.selection.exhaustion import Exhaustion
from featurebox.selection.quickmethod import dict_method_reg
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call
from featurebox.tools.show import BasePlot
from featurebox.tools.tool import name_to_name

warnings.filterwarnings("ignore")
"""
this is a description
"""
if __name__ == "__main__":
    store = Store(
        r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum\method', )
    data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp')
    data_import = data.csv().all_import
    name_init, abbr_init = data.pickle_pd().name_and_abbr

    select = [
        'cell volume', 'electron density', 'lattice constants a',
        'lattice constants c', 'radii covalent', 'radii ionic(shannon)',
        'distance core electron(schubert)', 'latent heat of fusion',
        'energy cohesive brewer', 'total energy',
        'charge nuclear effective(slater)', 'valence electron number',
        'electronegativity(martynov&batsanov)', 'volume atomic(villars,daams)'
    ]

    select = [
        'cell volume',
        'electron density',
Example #3
0
"""

"""

import numpy as np
import pandas as pd
import sympy
from featurebox.combination.symbolbase import calculateExpr, getName

from featurebox.tools.exports import Store
from featurebox.tools.imports import Call

if __name__ == "__main__":
    store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp_last\4.symbollearning')
    data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp_last\1.generate_data',
                r'C:\Users\Administrator\Desktop\band_gap_exp_last\3.MMGS',
                r'C:\Users\Administrator\Desktop\band_gap_exp_last\2.correction_analysis')

    all_import_structure = data.csv.all_import_structure
    data_import = all_import_structure
    data216_import = data_import.iloc[np.where(data_import['group_number'] == 216)[0]]
    data225_import = data_import.iloc[np.where(data_import['group_number'] == 225)[0]]
    data221_import = data_import.iloc[np.where(data_import['group_number'] == 221)[0]]
    data216_225_221import = pd.concat((data216_import, data225_import, data221_import))

    list_name = data.csv.list_name
    list_name = list_name.values.tolist()
    list_name = [[i for i in _ if isinstance(i, str)] for _ in list_name]
    # grid = itertools.product(list_name[2],list_name[12],list_name[32])

    select = ['volume', 'radii covalent', 'electronegativity(martynov&batsanov)', 'electron number']
Example #4
0
import numpy as np
import pandas as pd
import sklearn
from sklearn import svm
from sklearn.model_selection import GridSearchCV, LeaveOneOut
from sklearn.preprocessing import MinMaxScaler

from featurebox.selection.backforward import BackForward
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call

warnings.filterwarnings("ignore")

# 数据导入
store = Store(r'/data/home/wangchangxin/data/zlj/')
data = Call(r'/data/home/wangchangxin/data/zlj/', index_col=None)
all_import = data.xlsx().data

x_name = all_import.index.values
y = all_import["y"].values
x_frame = all_import.drop("y", axis=1)
x = x_frame.values
# # 预处理
# minmax = MinMaxScaler()
# x = minmax.fit_transform(x)
# 数据划分
xtrain, xtest = x[3:], x[:3]
ytrain, ytest = y[3:], y[:3]

xtrain, ytrain = sklearn.utils.shuffle(xtrain, ytrain, random_state=3)
Example #5
0
import numpy as np
from featurebox.symbol.base import SymbolSet, SymbolTree
from featurebox.symbol.functions.dimfunc import Dim, dless
from featurebox.symbol.calculation.translate import group_str, compile_context, general_expr_dict
from featurebox.symbol.flow import MutilMutateLoop, OnePointMutateLoop
from featurebox.symbol.preprocess import MagnitudeTransformer
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call
from featurebox.tools.tool import tt

if __name__ == "__main__":
    import os

    os.chdir(r'band_gap')

    data = Call()
    all_import = data.csv().all_import
    name_and_abbr = data.csv().name_and_abbr

    store = Store()

    data_import = all_import
    data225_import = data_import

    select = [
        'cell volume', 'cell density', 'lattice constants a',
        'lattice constants c', 'covalent radii', 'ionic radii(shannon)',
        'core electron distance(schubert)', 'fusion enthalpy',
        'cohesive energy(Brewer)', 'total energy',
        'effective nuclear charge(slater)', 'valence electron number',
        'electronegativity(martynov&batsanov)', 'atomic volume(villars,daams)'
Example #6
0
import pandas as pd
from sklearn import preprocessing, utils
from sklearn.model_selection import GridSearchCV

from featurebox.selection.quickmethod import dict_method_reg
from featurebox.selection.sum import SUM
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call
from featurebox.tools.tool import name_to_name

warnings.filterwarnings("ignore")

if __name__ == '__main__':
    store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum\10times100')
    data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum\method',
                r"C:\Users\Administrator\Desktop\band_gap_exp\3.sum\10times100",
                r'C:\Users\Administrator\Desktop\band_gap_exp')
    data_import = data.csv().all_import
    name_init, abbr_init = data.pickle_pd().name_and_abbr

    select = ['volume', 'destiny', 'lattice constants a', 'lattice constants c', 'radii covalent',
              'radii ionic(shannon)',
              'distance core electron(schubert)', 'latent heat of fusion', 'energy cohesive brewer', 'total energy',
              'charge nuclear effective(slater)', 'valence electron number', 'electronegativity(martynov&batsanov)',
              'volume atomic(villars,daams)']

    select = ['volume', 'destiny'] + [j + "_%i" % i for j in select[2:] for i in range(2)]

    data216_import = data_import.iloc[np.where(data_import['group_number'] == 216)[0]]
    data225_import = data_import.iloc[np.where(data_import['group_number'] == 225)[0]]
    data216_225_import = pd.concat((data216_import, data225_import))
Example #7
0
    # x2 = x[:, 2]
    # x3 = x[:, 3]
    #
    # t = expr01
    # func0 = sympy.utilities.lambdify(terminals, t)
    # re = func0(*x.T)
    # p = BasePlot(font=None)
    # p.scatter(y, re, strx='Experimental $E_{gap}$', stry='Calculated $E_{gap}$')
    # import matplotlib.pyplot as plt
    #
    # plt.show()


if __name__ == '__main__':
    store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\4.symbol')
    data = Call(r'C:\Users\Administrator\Desktop\c', index_col=None)
    data_import = data.xlsx().sr

    X = data_import["delt_x"].values
    input_x = data_import[["delt_x", "G"]].values

    Pexp = data_import["Pexp"].values
    Pmix = data_import["Pmix"].values

    G = data_import["G"].values
    y = data_import["PG_y"].values
    y = y * G
    testfunc = input_x[:, 0] * input_x[:, 1]
    t = np.corrcoef(y, input_x[:, 0] * input_x[:, 1])

    dim1 = Dim([0, 0, 0, 0, 0, 0, 0])
Example #8
0
    stats1.register("max", np.max)

    stats2 = Statistics(lambda ind: 0 if ind else 0)
    stats2.register("countable_number", np.sum)
    stats = MultiStatistics(score1=stats1, score2=stats2)

    population, logbook = eaSimple(pop, toolbox, cxpb=cxpb, mutpb=mutpb, ngen=ngen, stats=stats,
                                   halloffame=hof, pset=pset, store=store)

    return hof


if __name__ == '__main__':
    # 输入
    store = Store(r'D:\sy')
    data = Call(r'D:\sy')

    data_import = data.xlsx().featuredata
    name_abbr = data_import.columns.values
    x_name = name_abbr[:-1]
    # data_import = data_import.iloc[np.where(data_import['f1'] <= 1)[0]]

    X_frame = data_import[x_name]
    y_frame = data_import['y']

    X = X_frame.values
    y = y_frame.values

    # 处理
    # scal = preprocessing.MinMaxScaler()
    # X = scal.fit_transform(X)
Example #9
0
#
#                         ],
#                         definate_variable=[[-5, [0]],
#                                            [-4, [1]],
#                                            [-3, [2]],
#                                            [-2, [3]],
#                                            [-1, [4]]],
#                         operate_linkage=[[-1, -2], [-3, -4]],
#                         variable_linkage=None)
#     result = mainPart(X, y, pset, pop_n=500, random_seed=1, cxpb=0.8, mutpb=0.6, ngen=20, tournsize=3, max_value=10,
#                       double=False, score=[r2_score, custom_loss_func], target_dim=target_dim)

# 5
if __name__ == '__main__':
    store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\4.symbol')
    data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp')
    data_import = data.csv().all_import
    name_init, abbr_init = data.name_and_abbr

    select = ['latent heat of fusion', 'valence electron number']

    X_frame_abbr = name_to_name(name_init, abbr_init, search=select, search_which=1, return_which=2,
                                two_layer=False)

    select = [j + "_%i" % i for j in select[:] for i in range(2)]

    select_abbr = [j + "_%i" % i for j in X_frame_abbr[:] for i in range(2)]

    data225_import = data_import.iloc[np.where(data_import['group_number'] == 225)[0]]

    X_frame = data225_import[select]
Example #10
0
from featurebox.combination.dimanalysis import dimension_check
from featurebox.selection.quickmethod import dict_method_reg
from featurebox.selection.sum import SUM
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call
from featurebox.tools.tool import name_to_name

warnings.filterwarnings("ignore")
"""
this is a description
"""
if __name__ == "__main__":
    store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum\sub')
    data = Call(
        r'C:\Users\Administrator\Desktop\band_gap_exp',
        r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum\method',
    )
    data_import = data.csv().all_import
    name_init, abbr_init = data.pickle_pd().name_and_abbr

    select = [
        'cell volume', 'electron density', 'lattice constants a',
        'lattice constants c', 'radii covalent', 'radii ionic(shannon)',
        'distance core electron(schubert)', 'latent heat of fusion',
        'energy cohesive brewer', 'total energy',
        'charge nuclear effective(slater)', 'valence electron number',
        'electronegativity(martynov&batsanov)', 'volume atomic(villars,daams)'
    ]

    select = ['cell volume', 'electron density'
              ] + [j + "_%i" % i for j in select[2:] for i in range(2)]
Example #11
0
# -*- coding: utf-8 -*-

# @Time    : 2019/12/20 15:11
# @Email   : [email protected]
# @Software: PyCharm
# @License: BSD 3-Clause
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call

store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\4.symbol', )
data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp\4.symbol')
store.to_csv(data.filename)
Example #12
0
# @Project : feature_toolbox
# @FileName: 1.1add_compound_features.py
# @Software: PyCharm

import pandas as pd
import pymatgen as mg

from featurebox.featurizers.voronoifeature import count_voronoinn
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call
"""
this is a description
"""
store = Store(
    r'C:\Users\Administrator\Desktop\band_gap_exp_last\1.generate_data')
data = Call(
    r'C:\Users\Administrator\Desktop\band_gap_exp_last\1.generate_data')

com_data = pd.read_excel(
    r'C:\Users\Administrator\Desktop\band_gap_exp_last\init_band_data.xlsx',
    sheet_name='binary_4_structure',
    header=0,
    skiprows=None,
    index_col=0,
    names=None)
composition = pd.Series(map(eval, com_data['composition']))
composition_mp = pd.Series(map(mg.Composition, composition))
"""for element site"""
com_mp = pd.Series([i.to_reduced_dict for i in composition_mp])
# com_mp = composition_mp
all_import = data.csv.all_import
id_structures = data.id_structures
Example #13
0
from pymatgen import Composition
from sklearn.ensemble import RandomForestRegressor, AdaBoostRegressor
from sklearn.feature_selection import RFECV
from sklearn.linear_model import BayesianRidge
from sklearn.model_selection import GridSearchCV
from sklearn.preprocessing import MinMaxScaler
from sklearn.tree import DecisionTreeRegressor

from featurebox.featurizers.compositionfeaturizer import WeightedAverage
from featurebox.selection.corr import Corr
from featurebox.tools.exports import Store
from featurebox.tools.imports import Call

# 数据导入
store = Store(r'C:\Users\Administrator\Desktop\skk')
data = Call(r'C:\Users\Administrator\Desktop\skk')
all_import = data.csv().skk

# """for element site"""
element_table = pd.read_excel(
    r'C:\Users\Administrator\Desktop\band_gap_exp\element_table.xlsx',
    header=4,
    skiprows=0,
    index_col=0)
element_table = element_table.iloc[5:, 7:]

# 其他数据获取
feature_select = [
    'lattice constants a',
    'lattice constants b',
    'lattice constants c',