示例#1
0
    class StepOne(Transform):
        foo = InputTag("foo")
        bar = OutputTag("bar")
        bingo = OutputTag("bingo")

        def script(self):
            pass
示例#2
0
    class StepTwo(Transform):
        bar = InputTag("bar")
        bongo = InputTag("bongo")
        baz = OutputTag("baz")

        def script(self):
            pass
示例#3
0
    class StepThree(Transform):
        baz = InputTag("baz")
        bingo = InputTag("bingo")
        bop = OutputTag("bop")

        def script(self):
            pass
示例#4
0
    class BasicStep(Transform):
        foo = InputTag("foo")
        bar = InputTag("bar")
        baz = OutputTag("baz")

        def script(self):
            pass
示例#5
0
    class Two(Transform):
        foo = InputTag("foo")
        baz = OutputTag("baz")

        def script(self):
            self.foo.touch()
            pass
示例#6
0
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)
示例#7
0
    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)
示例#8
0
    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)
示例#9
0
    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
示例#10
0
    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)
示例#11
0
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)
示例#12
0
    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")
示例#13
0
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)
示例#14
0
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)
示例#15
0
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))
示例#16
0
    class One(Transform):
        foo = InputTag("foo")
        baz = OutputTag("baz")

        def script(self):
            pass
示例#17
0
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())
示例#18
0
    class StepFour(Transform):
        bop = InputTag("bop")
        bip = OutputTag("bip")

        def script(self):
            pass