开发者社区> 问答> 正文

我的结果校验代码全11条规则python

用python写了一个检验程序,校验了所有的11条规则,供参考,同时如果校验程序有问题,也请帮忙修改一下代码

代码放在github上了,链接为: github.com/imlinhao/cn_verify

提交的结果,命名为cn_sub.csv ,运行python verify.py ,进行结果验证




展开
收起
imlinhao 2016-07-18 23:31:44 5001 0
3 条回答
写回答
取消 提交回答
  • Re我的结果校验代码全11条规则python
    第九条规则有点问题, 我做了点小修改。
    def verify9(arrange, ds_order_df, o2o_order_df):
        # use the example to verify cal functions
        #mix_path = ["A083","A083","A083","A083","A083","B5800","B7555","B7182","B8307","B8461","A083","A083","A083","B6528","S245","B3266","B3266","B2337","A083","A083","A083","A083","S294","B1940","B6104","B8926","B9072","B6103"]
        #orders = ["F6344","F6360","F6358","F6353","F6354","F6344","F6354","F6353","F6358","F6360","F6349","F6325","F6314","F6349","E0895","E0895","F6325","F6314","F6366","F6345","F6346","F6308","E1088","F6308","F6346","E1088","F6366","F6345"]  
        mix_path = arrange.Addr.tolist()
        orders = arrange.Order_id.tolist()
        mix_arrange_df = pd.DataFrame({ "Addr": mix_path, "Order_id": orders})
        mix_arrange_df["Courier_id"] = arrange.iloc[0].Courier_id
        mix_arrange_df["Arrival_time"] = arrange.iloc[0].Arrival_time
        mix_arrange_df["Departure"] = arrange.iloc[0].Departure
        mix_arrange_df["Amount"] = 0
        pre_e = mix_arrange_df.iloc[0]
        pre_addr = pre_e.Addr
        pre_order = pre_e.Order_id
        pre_departure = arrange.iloc[0].Departure
        if 'F' in pre_order:
            amount = ds_order_df[ds_order_df["Order_id"]==pre_order].Num.values[0]
        elif 'E' in pre_order:
            amount = o2o_order_df[o2o_order_df["Order_id"]==pre_order].Num.values[0]
        new_mix_arrange_df = pd.DataFrame({"Courier_id": [arrange.iloc[0].Courier_id], "Addr": [pre_addr], "Arrival_time": [arrange.iloc[0].Arrival_time], "Departure": [arrange.iloc[0].Departure], "Amount": [amount],  "Order_id": [pre_order]})
        for i in range(1, len(mix_arrange_df)):
            cur_e = mix_arrange_df.iloc
            cur_addr = cur_e.Addr
            cur_order = cur_e.Order_id
            if 'A' in cur_addr:
                arrival_time = pre_departure + cal_cost(pre_addr, cur_addr)
                amount = ds_order_df[ds_order_df["Order_id"]==cur_order].Num.values[0]
                departure = arrival_time
            elif 'B' in cur_addr and 'F' in cur_order:
                arrival_time = pre_departure + cal_cost(pre_addr, cur_addr)
                amount = -ds_order_df[ds_order_df["Order_id"]==cur_order].Num.values[0]
                departure = arrival_time + cal_proctime(abs(amount))
            elif 'B' in cur_addr and 'E' in cur_order:
                arrival_time = pre_departure + cal_cost(pre_addr, cur_addr)
                amount = -o2o_order_df[o2o_order_df["Order_id"]==cur_order].Num.values[0]
                departure = arrival_time + cal_proctime(abs(amount))
            elif 'S' in cur_addr:
                arrival_time = pre_departure + cal_cost(pre_addr, cur_addr)
                amount = o2o_order_df[o2o_order_df["Order_id"]==cur_order].Num.values[0]
                departure = max(time2min(o2o_order_df[o2o_order_df["Order_id"]==cur_order].Pickup_time.values[0]), arrival_time)
            new_mix_arrange_df = new_mix_arrange_df.append(pd.DataFrame({"Courier_id": [arrange.iloc[0].Courier_id], "Addr": [cur_addr], "Arrival_time": [arrival_time], "Departure": [departure], "Amount": [amount],  "Order_id": [cur_order]}))
            cmp_e = arrange.iloc
            if cur_addr != cmp_e.Addr or amount != cmp_e.Amount or arrival_time != cmp_e.Arrival_time or departure != cmp_e.Departure:
                return False
            pre_addr = cur_addr
            pre_departure = departure
        return True
    2016-07-20 14:18:21
    赞同 展开评论 打赏
  • Re我的结果校验代码全11条规则python
    谢谢分享
    2016-07-19 16:20:59
    赞同 展开评论 打赏
  • Re我的结果校验代码全11条规则python
    感觉过了这个校验程序,应该就会有成绩了,自己的结果刚过了校验程序,终于有成绩了

    -------------------------

    Re我的结果校验代码全11条规则python
    @marshmallow 你的修改代码已经更新上去了;

    另外求高手分享一下算cost的代码
    2016-07-19 00:26:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载