MCPcopy Index your code
hub / github.com/lazyprogrammer/machine_learning_examples / Model

Class Model

rl/approx_prediction.py:43–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41
42
43class Model:
44 def __init__(self, grid):
45 # fit the featurizer to data
46 samples = gather_samples(grid)
47 # self.featurizer = Nystroem()
48 self.featurizer = RBFSampler()
49 self.featurizer.fit(samples)
50 dims = self.featurizer.n_components
51
52 # initialize linear model weights
53 self.w = np.zeros(dims)
54
55 def predict(self, s):
56 x = self.featurizer.transform([s])[0]
57 return x @ self.w
58
59 def grad(self, s):
60 x = self.featurizer.transform([s])[0]
61 return x
62
63
64if __name__ == '__main__':

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected