568. ICR - Identifying Age-Related Conditions | icr-identify-age-related-conditions
我非常惊讶自己在最终榜单上的排名,名次提升了3283位 :D
本次挑战的难点在于可用数据行数非常有限,这给建立合适的交叉验证方案带来了巨大挑战。
最终选择了基于Alpha列的分层抽样策略作为交叉验证方法。
我的解决方案核心采用了对比学习方法。选择对比学习的原因是能够通过生成大量模拟数据来弥补观测数据的稀缺性。
该方法很大程度借鉴了SetFit框架(文末附参考链接)。
使用的模型是LGBM,该模型从所有特征的绝对差值出发,判断两个特征是否属于同一类别。在计算绝对差值的初始特征基础上,还添加了以下特征:
模型训练时,正负样本对按1:5比例采样(类别0 vs 类别1)以保持数据平衡。每个观测值会从同类和异类中随机选取若干样本,并移除重复组合。
采用AUC指标确定最佳训练轮数。
推理阶段执行以下后处理:
最终概率计算公式:prob = prob_1 / (prob_0 + prob_1),其中prob_0和prob_1分别是前两步概率的平均值。这样每个观测需要执行617次预测。
以下是新观测与训练集比对的核心函数:
def get_retrieval_dataset(
test: pd.DataFrame, target_example: pd.DataFrame,
feature_list: list
) -> Tuple[pd.DataFrame, list]:
test_shape = test.shape[0]
target_example_shape = target_example.shape[0]
test_x = test[feature_list].to_numpy('float32')
target_example = np.concatenate(
[
target_example
for _ in range(test_shape)
], axis=0
)
test_x = np.repeat(test_x, target_example_shape, axis=0)
index_test = np.repeat(test.index.values, target_example_shape, axis=0)
retrieval_dataset = fe_pipeline(
dataset_1=target_example,
dataset_2=test_x, feature_list=feature_list,
)
retrieval_dataset['rows'] = index_test
return retrieval_dataset