使用SPSSAU进行Roc联合诊断

191 篇文章 30 订阅
161 篇文章 21 订阅

1.基本思想

在一些医学临床研究中,有很多影响因素(或者指标)会对诊断起着作用。比如‘低出生体重儿’的出生,受到产妇年龄,产妇体重,产妇在妊娠期间是否吸烟,是否患有高血压共4项指标的影响。

如果单独使用ROC曲线进行诊断,可以分别得到各个指标对于‘低出生体重儿’的诊断预测。但是该4项指标合计在一起的时候,联合诊断效果如何,是否可以使用一个整体汇总指标来标识出‘4个指标’。

思想上,如何将‘4个指标’合并成一个,通常是使用二元logit回归,将4个指标作为X,将‘低出生体重儿’作为Y进行二元logit回归,并且得到‘预测值’,该‘预测值’即为4个指标的整体汇总指标值,然后将该’预测值‘作为检验变量X,然后将’低出生体重儿’作为状态变量Y进行分析即可。

2、SPSSAU操作

本案例涉及部分数据如下图:

 

  • 针对‘低出生体重儿’,数字1表示低出生体重儿,0代表不是[特别注意,此处只能为01变量,因为进行二元Logit分析时有此要求,以及ROC曲线时也最好为01变量便于理解];
  • 产妇年龄和产妇体重均为对应真实数据;
  • 数字0代表不吸烟,数字1代表吸烟;
  • 数字0代表无高血压,数字1代表有高血压。

操作上分为两步,第一步是进行二元logit回归如下图所示:

 

将4项指标放入X框中,将低出生体重儿放入Y框中。并且选中‘保存残差和预测值’,一定需要选中该项。点击开始分析后,标题框中会新出现类似“BinaryLogit_Prediction_****”的标题,其用于标识预测值,另外还有一个标题类似“BinaryLogit_Residual_****”用来表示残差。

 

接下来进行ROC诊断分析,将‘预测值’ 作为检验变量X,然后将‘低出生体重儿’作为状态变量Y进行分析,操作如下图:

 

上图中需要说明,SPSSAU系统中针对状态变量Y,其默认切割点为1,即数字等于1时为‘阳性’,反之数字不等于1则为‘阴性’,此数字标识需要在前期确认好,包括进行二元logit回归,如果不是这样,可以使用SPSSAU数据编码功能进行设置。最终得到ROC联合诊断结果,具体结果不再进行阐述说明。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用GBDT进行二分类并绘制ROC曲线,需要进行以下步骤: 1. 导入所需库和数据集。我们可以使用sklearn中的make_classification函数生成一个二分类的数据集。 ```python from sklearn.datasets import make_classification import pandas as pd X, y = make_classification(n_samples=1000, n_classes=2, random_state=42) df = pd.DataFrame(X, columns=['feature_1', 'feature_2', 'feature_3', 'feature_4']) df['target'] = y ``` 2. 将数据集划分为训练集和测试集。 ```python from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) ``` 3. 使用sklearn中的GradientBoostingClassifier进行模型训练。 ```python from sklearn.ensemble import GradientBoostingClassifier model = GradientBoostingClassifier(n_estimators=100, learning_rate=0.1, max_depth=3, random_state=42) model.fit(X_train, y_train) ``` 4. 使用sklearn中的roc_curve函数计算ROC曲线的假正率(FPR)和真正率(TPR)。 ```python from sklearn.metrics import roc_curve y_pred_proba = model.predict_proba(X_test)[:, 1] fpr, tpr, thresholds = roc_curve(y_test, y_pred_proba) ``` 5. 使用matplotlib绘制ROC曲线。 ```python import matplotlib.pyplot as plt plt.plot(fpr, tpr) plt.plot([0, 1], [0, 1], 'k--') plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.title('ROC Curve') plt.show() ``` 完整代码如下: ```python from sklearn.datasets import make_classification import pandas as pd from sklearn.model_selection import train_test_split from sklearn.ensemble import GradientBoostingClassifier from sklearn.metrics import roc_curve import matplotlib.pyplot as plt X, y = make_classification(n_samples=1000, n_classes=2, random_state=42) df = pd.DataFrame(X, columns=['feature_1', 'feature_2', 'feature_3', 'feature_4']) df['target'] = y X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) model = GradientBoostingClassifier(n_estimators=100, learning_rate=0.1, max_depth=3, random_state=42) model.fit(X_train, y_train) y_pred_proba = model.predict_proba(X_test)[:, 1] fpr, tpr, thresholds = roc_curve(y_test, y_pred_proba) plt.plot(fpr, tpr) plt.plot([0, 1], [0, 1], 'k--') plt.xlabel('False Positive Rate') plt.ylabel('True Positive Rate') plt.title('ROC Curve') plt.show() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值