以下的代码用于处理Yahoo的数据使其成为lightGBM使用的格式
最开始vaild.txt数据集的格式:
label \t qid:id \t feature
1 qid:19945 1:0.74142 6:0.90265 7:0.8087 8:0.79522 9:0.80003 11:0.56756 12:0.064688 17:0.073248
处理之后:
.vaild格式
label " " feature
1 1:0.74142 6:0.90265 7:0.8087 8:0.79522 9:0.80003 11:0.56756 12:0.064688 17:0.073248 20:0.93213 21:0.12578 27:0.18431 28:0.75984 30:0.75616 32:0.80374
.vaild.group和.vaild.query的格式一样
size1
size2
表示每个组的数据是哪一些
def convert(input_filename, out_data_filename, out_query_filename, out_query_filename2):
input = open(input_filename,"r")
output_feature = open(out_data_filename,"w")
output_query = open(out_query_filename,"w")
output_query2 = open(out_query_filename2,