作为python工具箱的计算实验设计与分析。
pydace的Python项目详细描述
说明
本项目改编自汉斯·布鲁恩·尼尔森、S_ren Nymand和Lophaven Jacob S_ndergaard的作品。
注释
这是一个非常依赖线性代数解算器的实现(最小二乘解算器、Cholesky和QR 分解等)因此,强烈建议您的numpy库集成到 BLAS library(例如:英特尔MKL、OpenBLAS、ATLAS等) 以达到满意的计算性能。
为了方便起见,Anaconda处理了如何将numpy与那些库结合起来的细节
安装
通过pypi存储库安装:
pip install pydace
通过conda安装
conda install -c felipes21 pydace
用法
DACE模型示例
importnumpyasnpimportscipy.ioassiofrompydaceimportDaceimportmatplotlib.pyplotasplt# Load the training and validation data. (Here we are using a file from the# github repo located in the folder pydace\tests with the name # 'doe_final_infill_mat'mat_contents=sio.loadmat('doe_final_infill.mat')design_data=mat_contents['MV']# design sitesobserved_data=mat_contents['CV']# experiment results# define the hyperparameters bounds and initial estimatetheta0=1*np.ones((design_data.shape[1],))lob=1e-5*np.ones(theta0.shape)upb=1e5*np.ones(theta0.shape)# select the training and validation datadesign_val=design_data[:99,:]observed_val=observed_data[:99,:]design_train=design_data[100:,:]observed_train=observed_data[100:,:]# build the univariate kriging models with a first order polynomial # regression and a gaussian regression modelobserved_prediction=np.empty(observed_val.shape)forjinnp.arange(design_data.shape[1]):# initialize the dace objectdace_obj=Dace('poly1','corrgauss',optimizer='boxmin')# fit the training data using the default hyperparameter optimizerdace_obj.fit(design_train,observed_train[:,j],theta0,lob,upb)# predict the validation dataobserved_prediction[:,[j]],*_=dace_obj.predict(design_val)# labels for the observed datavar_labels=['L/F','V/F','xD','xB','J','QR']# plot the validation dataforvarinnp.arange(design_data.shape[1]):plt.figure(var+1)plt.plot(observed_val[:,var],observed_prediction[:,var],'b+')plt.xlabel(var_labels[var]+' - Observed')plt.ylabel(var_labels[var]+' - Kriging Prediction')plt.show()
实验数据生成设计示例
利用拉丁超立方体的变异减少技术也可以生成实验数据的设计 已在此工具箱中实现的采样(lhs)。
假设我们有一个4维问题(即4个设计/输入变量)。它们由以下界限定义。
如果我们想在这些边界内建立一个拉丁超立方体,我们将执行以下操作:
importnumpyasnpfrompydace.aux_functionsimportlhsdesignlb=np.array([8.5,0.,102.,0.])ub=np.array([20.,100.,400.,400.])lhs=lhsdesign(53,lb,ub,include_vertices=False)
与我联系/交谈
我的电子邮件是felipe.lima@eq.ufcg.edu.br。随时都可以联系我,如果我懒的话就唠叨我。