zoukankan      html  css  js  c++  java
  • 代码2

    mode给出模型计算出的test数据的similarity值,target是test数据本身给出的标准值,需要计算mode和target中00,01,10,11的个数

    这个的zip还要清理一下

    >>>a = [1,2,3]

    >>>b = [9,6,1]

    >>>for (i,j) in zip(a,b):

    >>> print i+j

    10

    8

    4

    错误代码:

    mode=open('/home/xbwang/Desktop/0.1another-results-dependency.1l.150d.epoch-1.0.35192.10005.pred','r')
    target=open('/home/xbwang/xingyu/data/sick/test/sim.txt','r')
    count00=0
    count01=0
    count10=0
    count11=0
    for tscore,mscore in zip(mode,target):
        #print(tscore)
        #print(mscore)
        #if(tscore == '0
    '):
            #print('yes')
    #if(tscore == '0'):
         #print('yes')
    if(tscore=='0' and mscore=='0'): count00=count00+1 elif(tscore=='0' and mscore=='1'): count01=count01+1 elif(tscore=='1' and mscore=='0'): count10=count10+1 elif(tscore=='1' and mscore=='1'): count11=count11+1 print('count00:%d'%count00+' ') print('count01:%d'%count01+' ') print('count10:%d'%count10+' ') print('count11:%d'%count11+' ')

    错误:print出来的值为0,0,0,0

    正确代码:

    mode=open('/home/xbwang/Desktop/0.1another-results-dependency.1l.150d.epoch-1.0.35192.10005.pred','r')
    target=open('/home/xbwang/xingyu/data/sick/test/sim.txt','r')
    count00=0
    count01=0
    count10=0
    count11=0
    for tscore,mscore in zip(mode,target):
        #print(tscore)
        #print(mscore)
        #if(tscore == '0
    '):
            #print('yes')
        if(tscore=='0
    ' and mscore=='0
    '):
            count00=count00+1
        elif(tscore=='0
    ' and mscore=='1
    '):
            count01=count01+1
        elif(tscore=='1
    ' and mscore=='0
    '):
            count10=count10+1
        elif(tscore=='1
    ' and mscore=='1
    '):
            count11=count11+1
    print('count00:%d'%count00+'
    ')
    print('count01:%d'%count01+'
    ')
    print('count10:%d'%count10+'
    ')
    print('count11:%d'%count11+'
    ')
  • 相关阅读:
    [原]跟我学silverlight系列教程[1]—wpf/silverlight体系架构和运行机制
    [转载]My97DatePicker在Frame中无法打开站点
    sql select的时候按特定的顺序排序
    javascript获取滚动条位置
    sql2005 数据库没有完全关闭,无法重新生成日志
    .Net framework
    输出datagrid的内容到excel
    IIS中网站出错
    [原]跟我学silverlight系列教程
    SharePoint2010 的ADFS2.0设置
  • 原文地址:https://www.cnblogs.com/ymjyqsx/p/6238143.html
Copyright © 2011-2022 走看看