""" this is a description """ import numpy as np import pandas as pd from bgp.selection.corr import Corr from mgetool.exports import Store from mgetool.imports import Call from mgetool.tool import name_to_name # import seaborn as sns if __name__ == "__main__": store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\2.corr') data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp') all_import = data.csv().all_import name_init, abbr_init = data.pickle_pd().name_and_abbr data_import = all_import data225_import = data_import.iloc[np.where( data_import['group_number'] == 225)[0]] X_frame = data225_import.drop(['exp_gap', 'group_number'], axis=1) y_frame = data225_import['exp_gap'] X = X_frame.values y = y_frame.values """calculate corr""" corr = Corr(threshold=0.90, muti_grade=2, muti_index=[2, len(X)]) corr.fit(X_frame) cof_list = corr.count_cof()
# ], # definate_variable=[ # [-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]] data216_225_import = pd.concat((data216_import, data225_import)) X_frame = data225_import[select_gs] y_frame = data225_import['exp_gap'] X = X_frame.values
import numpy as np import pandas as pd from bgp.selection.ugs import UGS from mgetool.exports import Store from mgetool.imports import Call from mgetool.quickmethod import dict_method_reg from mgetool.tool import name_to_name from sklearn import preprocessing, utils from sklearn.model_selection import GridSearchCV warnings.filterwarnings("ignore") if __name__ == '__main__': store = Store(r'C:\Users\Administrator\Desktop\band_gap_exp\3.sum') data = Call(r'C:\Users\Administrator\Desktop\band_gap_exp') data_import = data.csv.all_import name_init, abbr_init = data.csv.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))
# 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])
from featurebox.selection.corr import Corr from mgetool.exports import Store from mgetool.imports import Call from mgetool.show import corr_plot from mgetool.tool import name_to_name # import seaborn as sns if __name__ == "__main__": import os os.chdir(r'band_gap') store = Store() data = Call() all_import = data.csv().all_import name_and_abbr = data.csv().name_and_abbr data_import = all_import data225_import = data_import X_frame = data225_import.drop(['exp_gap'], axis=1) y_frame = data225_import['exp_gap'] X = X_frame.values y = y_frame.values # # """calculate corr""" corr = Corr(threshold=0.90, muti_grade=2, muti_index=[2, len(X)]) corr.fit(X_frame) cof_list = corr.count_cof() #
import warnings import matplotlib.pyplot as plt import numpy as np import sklearn from bgp.selection.backforward import BackForward from mgetool.exports import Store from mgetool.imports import Call from sklearn import svm from sklearn.model_selection import GridSearchCV, LeaveOneOut 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)
from bgp.selection.quickmethod import dict_method_reg from bgp.selection.sum import SUM from mgetool.exports import Store from mgetool.imports import Call from mgetool.tool import name_to_name from sklearn import utils from sklearn.model_selection import GridSearchCV 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)]
exps1 = exps1.subs(subbb1) exps1 = exps1.subs(subbb2) # exps1 = sympy.simplify(exps1) exps2 = exps2.subs(subbb1) exps2 = exps2.subs(subbb2) # exps2 = sympy.simplify(exps2) exps3 = exps3.subs(subbb1) exps3 = exps3.subs(subbb2) # exps3 = sympy.simplify(exps3) from mgetool.imports import Call data = Call(r'C:\Users\Administrator\Desktop\cl', index_col=None) values_data = data.xlsx().values_data E_values = values_data["E"].values Rct_values = values_data["Rct"].values Rp_values = values_data["Rp"] taup_values = (values_data["Rp"] * values_data["Cp"]).values R0_values = -(Rct_values**2 + Rct_values * Rp_values) / Rp_values F_values = 96485 T_values = 298 R_values = 8.314 q_values = 8 * 10e-5 beta_values = 0.5 std_Rct = np.std(Rct_values) std_taup = np.std(taup_values)
import pandas as pd from bgp.featurizers.compositionfeaturizer import WeightedAverage from bgp.selection.corr import Corr from mgetool.exports import Store from mgetool.imports import Call 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 # 数据导入 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',
import numpy as np from mgetool.exports import Store from mgetool.imports import Call from mgetool.tool import tt from bgp.base import SymbolSet from bgp.skflow import SymbolLearning if __name__ == "__main__": import os os.chdir(r'band_gap') data = Call() name_and_abbr = data.csv().name_and_abbr SL_data = data.SL_data si_transformer = data.si_transformer store = Store() x, x_dim, y, y_dim, c, c_dim, X, Y = SL_data x_g = np.arange(x.shape[1]) x_g = list(x_g[1:]) x_g = x_g.reshape(-1, 2) pset0 = SymbolSet() pset0.add_features(x, y, x_dim=x_dim, y_dim=y_dim, x_group=x_g) pset0.add_constants(c, c_dim=c_dim, c_prob=0.05) pset0.add_operations(power_categories=(2, 3, 0.5, 1 / 3, 4, 1 / 4), # categories=("Mul",), categories=("Add", "Mul", "Sub", "Div", "exp", "ln"),
""" import numpy as np import pandas as pd import sympy from bgp.combination.symbolbase import calculateExpr, getName from mgetool.exports import Store from mgetool.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
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)
import pandas as pd from bgp.selection.quickmethod import dict_method_reg from bgp.selection.sum import SUM from mgetool.exports import Store from mgetool.imports import Call from mgetool.tool import name_to_name from sklearn import preprocessing, utils from sklearn.model_selection import GridSearchCV 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)]
# @Project : feature_toolbox # @FileName: 1.1add_compound_features.py # @Software: PyCharm import pandas as pd import pymatgen as mg from bgp.featurizers.voronoifeature import count_voronoinn from mgetool.exports import Store from mgetool.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 structures = id_structures vor_area = count_voronoinn(structures, mess="area") vor_dis = count_voronoinn(structures, mess="face_dist") vor = pd.DataFrame() vor.insert(0, 'vor_area0', vor_area[:, 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)]