1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 __all__ = [
26 'Predictor',
27 'Dataset',
28 'DataGenerator',
29 'OnlineLearningInterface',
30 'PredictPdfInterface',
31 ]
32
33 from numpy import array
34
35
36
37
38
42
43
44
45
46
49 self.input_shape = input_shape
50
51
52
53
54
56
58 """EarlyPrediction
59
60 An EarlyPrediction exception is raised when the output can be
61 predicted early.
62 """
63 - def __init__(self, output, *args, **kwds):
64 self.output = output
65 self.args = args
66 self.kwds = kwds
67
69 return repr([self.output, self.args, self.kwds])
70
71
72 - def predict(self, input_point, *args, **kwds):
73 """Predict the output outcome of an input point."""
74 raise NotImplementedError, "Method predict() has not been implemented."
75
76 - def test(self, input_data, *args, **kwds):
77 """Predict the output outcomes of an array of input points."""
78 return array([self.predict(x, *args, **kwds) for x in input_data])
79
80
81
82
83
85
87 """Predict the output class pdf given an input point."""
88 raise NotImplementedError, "Method predict_pdf() has not been implemented."
89
90 - def predict(self, input_point, *args, **kwds):
91 """Predict the output outcome of an input point."""
92 return self.predict_pdf(input_point, *args, **kwds).argmax()
93
94 - def test_pdf(self, input_data, *args, **kwds):
95 return array([self.predict_pdf(x, *args, **kwds) for x in input_data])
96
97
98
99
100
102
103 - def learn(self, input_point, *args, **kwds):
104 """Learn incrementally with a new input point."""
105 raise NotImplementedError, "Method learn() has not been implemented."
106