我想使用 Python 从 ROC 曲线中获得最佳阈值。我知道如何使用 coords 函数在 R 中执行此操作,但我似乎无法在 Python 中找到类似的函数。
这是我显示 ROC 曲线的方式
def plot_roc_curve(fpr,tpr, thresholds):
plt.figure()
plt.plot(fpr, tpr, color='darkorange', label='ROC curve (area = %0.2f)' % metrics.auc(fpr, tpr))
plt.plot([0, 1], [0, 1], color='navy', linestyle='--')
plt.xlim([0.0, 1.0])
plt.ylim([0.0, 1.05])
plt.xlabel('False Positive Rate')
plt.ylabel('True Positive Rate')
plt.legend(loc="lower right")
# create the axis of thresholds (scores)
ax2 = plt.gca().twinx()
ax2.plot(fpr, thresholds, markeredgecolor='r',linestyle='dashed', color='r')
ax2.set_ylabel('Threshold',color='r')
ax2.set_ylim([thresholds[-1],thresholds[0]])
ax2.set_xlim([fpr[0],fpr[-1]])
plt.savefig('roc_and_threshold.png')
plt.close()
Run Code Online (Sandbox Code Playgroud)
我想使用write()函数将struct对象写入文件.它必须是那个功能.
我在终端的输入是:./ main.c output.dat John Doe 45
当我运行程序并打开output.dat时,有一堆字母没有意义.请帮我.
我在output.dat文件中想要的输出是:John Doe 45
我的代码:
struct Person{
char* name;
char* lastName;
char* age;
};
int main(int argc, char** argv){
struct Person human;
/* get the argument values and store them into char* */
char* fileName = argv[1];
char* name = argv[2];
char* lastName = argv[3];
char* age = argv[4];
/* set the values of human object */
human.name = name;
human.lastName = lastName;
human.age = age;
/* open the file */ …Run Code Online (Sandbox Code Playgroud)