本笔记来源于B站Up主: 有Li 的影像组学的系列教学视频
本节(29)主要讲解: 用pingouin
包进行ICC的计算
- ICC的wikipedia定义
In statistics, the intraclass correlation, or the intraclass correlation coefficient (ICC), is a descriptive statistic that can be used when quantitative measurements are made on units that are organized into groups. It describes how strongly units in the same group resemble each other. While it is viewed as a type of correlation, unlike most other correlation measures it operates on data structured as groups, rather than data structured as paired observations.
1.导入包
pip install pingouin # for the first time
import pingouin as pg
import pandas as pd
import numpy as np
import os
- 调取内置数据集
data = pg.read_dataset('icc')
print(data)
数据格式大概是这个样子:
- 计算ICC
icc = pg.intraclass_corr(data = data, targets = "Wine", raters = "Judge",
ratings = "Scores")
print(icc)
输出结果如下:
- 实战
folderPath = "C:/Users/RONG/Desktop/ICC_calculation/"
data_1 = pd.read_excel(os.path.join(folderPath,"ICC_reader_1.xlsx"))
data_2 = pd.read_excel(os.path.join(folderPath,"ICC_reader_2.xlsx"))
data_1.insert(0,"reader",np.ones(data_1.shape[0]))
data_2.insert(0,"reader",np.ones(data_2.shape[0])*2)
data_1.insert(0,"target",range(data_1.shape[0]))
data_2.insert(0,"target",range(data_2.shape[0]))
data = pd.concat([data_1,data_2]) # make a data frame like the test data
icc = pg.intraclass_corr(data = data, targets = "target", raters = "reader",ratings = "featureA")
print(icc)
-
以上 ICC_reader_1.xlsx 及处理后的数据形式为:
在影像组学实际应用中,应用for循环进行批量化计算各个feature的ICC值。