一种类型的keras模型中具有不同输入(分子指纹)的集成堆栈模型

问题描述 投票:-1回答:1

我是CHEMIST,还在学习ML ...

我已经使用不同类型的分子指纹作为特征预测特征,使用角膜训练了7种不同的模型……但是准确性并不那么好。

所以使用了我在网上找到的教程

def optimized_weights(prd,y_fold):
    # define bounds on each weight
    bound_w = [(0.0, 1.0) for _ in range(n_members) ]
    # arguments to the loss function
    search_arg = (prd ,y_fold)
    # global optimization of ensemble weights

    result = differential_evolution(loss_function, bound_w,search_arg,  maxiter=2000, tol=0.0001)
    # get the chosen weights
    weights = normalize(result['x'])
    return weights



def weighted_accuracy(prd,weights,y_fold):
    summed = tensordot(prd, weights, axes=((0),(0)))

    yhat=np.round(summed)

    score = accuracy_score(y_fold,yhat )
    f1 = f1_score(y_fold,yhat)
    fpr, tpr, thresholds = roc_curve(y_fold,summed,pos_label=1)
    auc_test = auc(fpr, tpr)

    conf_matrix=confusion_matrix(y_fold,yhat)
    total=sum(sum(conf_matrix))
    sensitivity = conf_matrix[0,0]/(conf_matrix[0,0]+conf_matrix[0,1])


    specificity = conf_matrix[1,1]/(conf_matrix[1,0]+conf_matrix[1,1])

    return score,auc_test,sensitivity,specificity,f1

对于加权平均整体模型,我使用80%的数据和20%的训练模型来通过使用differential_evolution(来自scipy)来找到最佳权重,以获取最大准确性,但是我认为这种准确性偏向于测试数据...

我还对5倍交叉验证重复了相同的过程,并确定了平均准确性。可以接受...如果没有,请告诉我该怎么办

谢谢

python machine-learning keras weighted-average ensemble-learning
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.