Esempio n. 1
0
def plot_GZX_evaluation(num_days, accuracy, precision, recall, outfile):

    set_pub()

    days = np.arange(num_days)

    fig = plt.figure(figsize=(8,8))
    ax = fig.add_subplot(111)

    ax.plot(days, accuracy, c='r', label='Accuracy')
    ax.plot(days, precision, c='g', label='Precision')
    ax.plot(days, recall, c='b', label='Recall')
    ax.legend(loc='best')

    ax.set_xlabel('Days in GZ2 project',fontsize=16,fontweight='bold')
    ax.set_ylabel('Per cent',fontsize=16,fontweight='bold')

    plt.savefig("GZX_evaluation_%s.png"%outfile)
    plt.show()
    plt.close()
Esempio n. 2
0
def plot_retired_GZ_vs_SWAP(GZX_retired, GZ2_retired, num_days,
                            outfilename=None, classifications_per_day=True, 
                            bar=False, expert=False):

    set_pub()

    #--------------------------------------------------------------
    # Make the Figure - Bar Chart

    dates = np.arange(num_days)
    width = 0.35
    

    fig = plt.figure(figsize=(15,10))
    ax = fig.add_subplot(111)

    if classifications_per_day:
        if expert: table = 'task1_expert'
        else: table = 'task1_full'

        try: 
            clicks_per_day = Table.read('%s_classbyday.txt'%table,
                                        format='ascii')
        except:
            fetch_classifications_per_day(num_days, expert=expert)

        # select only up to whatever day we're currently on
        batch = clicks_per_day[:num_days]

        # plot that shit!
        ax.plot(batch['col4'], color='black', alpha=.25)
        gzclass = ax.fill_between(dates,0,batch['col4'],facecolor='black',
                                  alpha=0.20, label='GZ2 classifications')
                                        

    GZX_retired = np.array(GZX_retired)
    GZ2_retired = GZ2_retired[:len(GZX_retired[0,:])]

    if GZX_retired.ndim == 1:
        if bar: 
            tots = ax.bar(dates, GZX_retired, width, color='orange', alpha=0.5)

        else:
            ax.plot(dates, GZX_retired, color='orange')
            tots = ax.fill_between(dates, GZX_retired, color='orange',alpha=0.5)

    else:
        detected = GZX_retired[0,:]
        rejected = GZX_retired[1,:]
        
        if bar:
            dets = ax.bar(dates, detected, width, color='orange',bottom=retired)
            rejs = ax.bar(dates, retired, width, color='yellow')

        else:
            ax.plot(dates, detected+rejected, color='orange')
            dets = ax.fill_between(dates, rejected, detected+rejected, 
                                   color='orange',alpha=0.5)

            ax.plot(dates, rejected, color='yellow')
            rejs = ax.fill_between(dates, rejected, color='yellow', alpha=0.5)


    if bar:
        orig = ax.bar(dates+width, GZ2_retired, width, color='b')

    else:
        ax.plot(dates, GZ2_retired, color='b', alpha=.65)
        orig = ax.fill_between(dates, GZ2_retired, color='b', alpha=0.4)
    
    
    #ax.set_title("Cumulative Number of Classified Subjects", weight='bold')
    ax.set_xlabel("Days in GZ2 project", fontsize=16, weight='bold')
    ax.set_ylabel("Counts", fontsize=16, weight='bold')

    ax.set_xticks(dates[::4]+width)
    ax.set_xticklabels(dates[::4])
    ax.set_xlim(0,num_days-1)
    
    if GZX_retired.ndim > 1 and classifications_per_day:
        legend = ax.legend((dets, rejs, orig, gzclass), 
                           ("GZX: 'Smooth'","GZX: 'Not'", 'GZ2', 
                            'GZ2 user votes'), loc='best')

    elif GZX_retired.ndim > 1:
        legend = ax.legend((dets[0], rejs[0], orig[0]), 
                           ("GZX: 'Smooth'","GZX: 'Not'", 'GZ2'), loc='best')

    elif GZX_retired.ndim == 1 and classifications_per_day:
        legend = ax.legend((tots, orig, gzclass), 
                           ('GZX', 'GZ2', 'GZ2 user votes'), loc='best')

    elif GZX_retired.ndim == 1:
        legend = ax.legend((tots, orig), ('GZX', 'GZ2'), loc='best')

    frame = legend.get_frame()
    frame.set_linewidth(2)
    for label in legend.get_texts():
        label.set_fontsize('large')

    plt.tight_layout()
    plt.savefig('retired_per_day_%s_%idays.png'%(outfilename, num_days))
    plt.show()

    return