Mercurial > pylearn
comparison statscollector.py @ 1:2cd82666b9a7
Added statscollector and started writing dataset and learner.
author | bengioy@esprit.iro.umontreal.ca |
---|---|
date | Fri, 14 Mar 2008 11:28:08 -0400 |
parents | |
children | f62a03c9d485 |
comparison
equal
deleted
inserted
replaced
0:586dcaa4b2df | 1:2cd82666b9a7 |
---|---|
1 | |
2 from numpy import * | |
3 | |
4 class StatsCollector(object): | |
5 """A StatsCollector object is used to record performance statistics during training | |
6 or testing of a learner. It can be configured to measure different things and | |
7 accumulate the appropriate statistics. From these statistics it can be interrogated | |
8 to obtain performance measures of interest (such as maxima, minima, mean, standard | |
9 deviation, standard error, etc.). Optionally, the observations can be weighted | |
10 (yielded weighted mean, weighted variance, etc., where applicable). The statistics | |
11 that are desired can be specified among a list supported by the StatsCollector | |
12 class or subclass. When some statistics are requested, others become automatically | |
13 available (e.g., sum or mean).""" | |
14 | |
15 default_statistics = [mean,standard_deviation,min,max] | |
16 | |
17 __init__(self,n_quantities_observed, statistics=default_statistics): | |
18 self.n_quantities_observed=n_quantities_observed | |
19 | |
20 clear(self): | |
21 raise NotImplementedError | |
22 | |
23 update(self,observations): | |
24 """The observations is a numpy vector of length n_quantities_observed. Some | |
25 entries can be 'missing' (with a NaN entry) and will not be counted in the | |
26 statistics.""" | |
27 raise NotImplementedError | |
28 | |
29 __getattr__(self, statistic) | |
30 """Return a particular statistic, which may be inferred from the collected statistics. | |
31 The argument is a string naming that statistic.""" | |
32 | |
33 | |
34 | |
35 | |
36 | |
37 |