class StepTwo(Transform): bar = InputTag("bar") bongo = InputTag("bongo") baz = OutputTag("baz") def script(self): pass
class StepThree(Transform): baz = InputTag("baz") bingo = InputTag("bingo") bop = OutputTag("bop") def script(self): pass
class BasicStep(Transform): foo = InputTag("foo") bar = InputTag("bar") baz = OutputTag("baz") def script(self): pass
class StepThree(Transform): baz = InputTag("baz") bleep = InputTag("bleep") boppo = OutputTag("boppo") def script(self): with self.baz.open() as f: data = f.read() with self.bleep.open() as f: data2 = f.read() with self.boppo.open() as f: f.write(data + " " + data2)
class Predict(Transform): to_predict_on = InputTag("to_predict_on") model = InputTag("model") predictions = OutputTag("predictions") def script(self): with self.model.openbin() as f: model = pickle.load(f) with self.to_predict_on.openbin() as f: X = pd.read_pickle(f) predictions = model.predict(X) with self.predictions.openbin() as f: pickle.dump(predictions, f)
class BasicStep(Transform): foo = InputTag("foo") bar = InputTag("bar") baz = OutputTag("baz") def script(self): with self.foo.open() as f: assert f.read() == "foo contents" with self.bar.open() as f: assert f.read() == "bar contents" with self.baz.open() as f: f.write("baz contents")
class StepOne(Transform): foo = InputTag("foo") bar = OutputTag("bar") bingo = OutputTag("bingo") def script(self): pass
class Two(Transform): foo = InputTag("foo") baz = OutputTag("baz") def script(self): self.foo.touch() pass
class Train(Transform): train_df = InputTag("train_df") train_labels = InputTag("train_labels") model = OutputTag("model") def script(self): with self.train_df.openbin() as f: X = pd.read_pickle(f) with self.train_labels.openbin() as f: y = pd.read_pickle(f) # Create a classifier: a support vector classifier classifier = svm.SVC(gamma=0.001) model = classifier.fit(X, y.values.ravel()) with self.model.openbin() as f: pickle.dump(model, f)
class StepTwo(Transform): bar = InputTag("bar") baz = OutputTag("baz") def script(self): with self.bar.open() as f: data = f.read() with self.baz.open() as f: f.write(data)
class StepOne(Transform): foo = InputTag("foo") bar = OutputTag("bar") def script(self): with self.foo.open() as f: data = f.read() with self.bar.open() as f: f.write(data)
class BasicStep(Transform): foo = InputTag("foo") baz = OutputTag("baz") def script(self): self.foo.touch() self.baz.touch() assert self.foo.ref.opened == True assert self.baz.ref.opened == True
class Concat(Transform): source = InputTag("source") copied = OutputTag("fileset::copied") def script(self): with self.source.open() as f: content = f.read() for ref in self.copied: with ref.open() as f: f.write(content)
class EvaluateResults(Transform): predictions = InputTag("predictions") test_labels = InputTag("test_labels") accuracy = OutputTag("accuracy") def script(self): with self.predictions.openbin() as f: pred = pd.read_pickle(f) with self.test_labels.openbin() as f: real = list(pd.read_pickle(f)["label"]) total = len(pred) correct = 0 for i in range(total): if pred[i] == real[i]: correct = correct + 1 accuracy = round(correct * 1.0 / total, 4) with self.accuracy.open() as f: f.write(str(accuracy))
class BuildDf(Transform): raw_images = InputTag("raw_images") df = OutputTag("df") labels = OutputTag("labels") def script(self): with self.raw_images.open() as f: data = np.genfromtxt(f, delimiter=",") labels = data[:, -1].astype(int) images = data[:, 0:-1] / 16.0 df = pd.DataFrame(images) labels_df = pd.DataFrame(data={"label": list(labels)}) with self.df.openbin() as f: df.to_pickle(f) with self.labels.openbin() as f: labels_df.to_pickle(f)
from tinybaker import InputTag, OutputTag, cli infile = InputTag("infile") outfile = OutputTag("outfile") def script(): with infile.open() as f: contents = f.read() with outfile.open() as f: f.write(contents + " but different") if __name__ == "__main__": cli(locals())
class One(Transform): foo = InputTag("foo") baz = OutputTag("baz") def script(self): pass
class StepFour(Transform): bop = InputTag("bop") bip = OutputTag("bip") def script(self): pass