Exemplo n.º 1
0
    def handle_cross_session_stats( sessions ):
        output = cStringIO.StringIO()
        writer = csv.writer( output )

        def catWrite(listA,listB):
            copy = listA[:]
            copy.extend( listB )
            writer.writerow( copy )

        catWrite( [ 'rank' ], stats.get_max_cross_session_rank_range( sessions ) )
        catWrite( [ 'avg amt runs' ], stats.get_average_amount_of_runs_at_total_rank_range( sessions ) )
        catWrite( [ 'avg gain' ], stats.get_average_cross_session_cumulated_gains_at_total_rank_range( sessions ) )
        catWrite( [ 'avg cost' ], stats.get_average_cross_session_cumulated_costs_at_total_rank_range( sessions ) )
        catWrite( [ 'avg gain SD' ], stats.get_cross_session_cumulated_gain_stddevs_at_total_rank_range( sessions ) )

        # Derived gains
        derivedGains = config.get_default_derived_gains_dict()
        for derivedGain in derivedGains.values():
            catWrite( [ 'avg ' + derivedGain.id ], stats.get_average_cross_session_derived_gains_at_total_rank_range( derivedGain.id, sessions ) )
            catWrite( [ 'avg ' + derivedGain.id + ' SD' ], stats.get_cross_session_derived_gain_stddevs_at_total_rank_range( derivedGain.id, sessions ) )

        # Per-session averages
        for runs in sessions:
            sessid = str(runs[0].get_session_id())
            catWrite( [ sessid + ' avg gain' ], stats.get_average_cumulated_gains_at_total_rank_range( runs ) )

        writer.writerow([])

        costInterval = 10
        catWrite( [ 'cost' ], stats.get_max_cross_session_cost_range( sessions, costInterval ) )
        catWrite( [ 'avg amt runs' ], stats.get_average_amount_of_runs_at_cost_range( sessions, costInterval ) )
        catWrite( [ 'avg gain' ], stats.get_average_cross_session_cumulated_gains_at_cost_range( sessions, costInterval ) )
        catWrite( [ 'avg gain SD' ], stats.get_average_cross_session_cumulated_gain_stddevs_at_cost_range( sessions, costInterval ) )

        # Derived gains
        for derivedGain in derivedGains.values():
            catWrite( [ 'avg ' + derivedGain.id ], stats.get_average_cross_session_derived_gains_at_cost_range( derivedGain.id, sessions, costInterval ) )
            catWrite( [ 'avg ' + derivedGain.id + ' SD' ], stats.get_average_cross_session_derived_gain_stddevs_at_cost_range( derivedGain.id, sessions, costInterval ) )

        # Per-session averages
        for runs in sessions:
            sessid = str(runs[0].get_session_id())
            catWrite( [ sessid + ' avg gain' ], stats.get_average_cumulated_gains_at_cost_range( runs, costInterval ) )

        writer.writerow([])

        return output.getvalue()
Exemplo n.º 2
0
def plotDerivedGainsAcrossSessions( sessions, gainIds, costIncrement ):
    for gainId in gainIds:

        yValueLists = [
            (FiguresConfig.avgPlotName, stats.get_average_cross_session_derived_gains_at_total_rank_range( gainId, sessions ) )
        ]
        yValueLists = yValueLists + [(get_session_id(runs), stats.get_average_derived_gains_at_total_rank_range(gainId, runs)) for runs in sessions]

        runValueLists = [(FiguresConfig.avgPlotName, stats.get_average_amount_of_runs_at_total_rank_range(sessions) )] + [
            (get_session_id(runs), stats.get_amount_of_runs_at_total_rank_range(runs) ) for runs in sessions]

        defaultPlot( 'rank', 'avg ' + gainId, stats.get_max_cross_session_rank_range( sessions ), yValueLists,
                 runValueLists, FiguresConfig.outputDirectory + '/' + get_filename_prefix() + 'X-session-' + gainId + 'AtRank.png', True )

        yValueLists = [
            (FiguresConfig.avgPlotName, stats.get_average_cross_session_derived_gains_at_cost_range( gainId, sessions, costIncrement ) )
        ]
        yValueLists = yValueLists + [(get_session_id(runs), stats.get_average_derived_gains_at_cost_range(gainId, runs, costIncrement)) for runs in sessions]

        runValueLists = [(FiguresConfig.avgPlotName, stats.get_average_amount_of_runs_at_cost_range(sessions, costIncrement) )] + [
            (get_session_id(runs), stats.get_amount_of_runs_at_cost_range(runs, costIncrement) ) for runs in sessions]

        defaultPlot( 'cost', 'avg ' + gainId, stats.get_max_cross_session_cost_range( sessions, costIncrement ), yValueLists,
                 runValueLists, FiguresConfig.outputDirectory + '/' + get_filename_prefix() + 'X-session-' + gainId + 'AtCost.png', True )