全国高校绿色计算大赛 预赛第三阶段(Python)(随机数)

只提交了随机数 (真心不会 T-T )

import csv
import random

import pandas as pd
import numpy as np


# 预测结果文件:src/step1/ground_truth/test_prediction.csv
def getPrediction():

    train = pd.read_csv("D:\\inputFiles\\inputFiles\\train.csv")
    test = pd.read_csv("D:\\inputFiles\\inputFiles\\test.csv")

    testt = 'D:\\inputFiles\\inputFiles\\test.csv'

    outt = 'D:\\inputFiles\\inputFiles\\test_prediction.csv'
    out = open(outt, 'a', newline='')
    csv_write = csv.writer(out, dialect='excel')
    sortedValues = ['ID', ' TARGET']
    csv_write.writerow(sortedValues)

    column = []
    with open(testt, 'r') as csvfile:
        reader = csv.reader(csvfile)
        column = [row[0] for row in reader]

    # round(random.uniform(0,1),1)

    for i in range(len(column)-1):
        ans = []
        ans.append(column.__getitem__(i+1))
        ans.append(round(random.uniform(0,0.9),1))
        csv_write.writerow(ans)


if __name__ == '__main__':
    getPrediction()



posted @ 2018-10-29 10:00  somliy  阅读(538)  评论(0编辑  收藏  举报