Esempio n. 1
0
import flor

with flor.Experiment('plate_demo') as ex:
    ex.groundClient('ground')

    ones = ex.literal([1, 2, 3], "ones")
    ones.forEach()

    tens = ex.literal([10, 100], "tens")
    tens.forEach()

    @flor.func
    def multiply(x, y):
        z = x * y
        print(z)
        return z

    doMultiply = ex.action(multiply, [ones, tens])
    product = ex.artifact('product.txt', doMultiply)

product.parallelPull()
# product.plot()
Esempio n. 2
0
#!/usr/bin/env python3
import flor
import numpy as np

with flor.Experiment("twitter_demo") as ex:
    tweets = ex.artifact('tweets.csv', 'tweets_loc')

    frac = ex.literal(0.75, 'frac')
    split_seed = ex.literal(42, 'seed')

    from split import split
    do_split = ex.action(split, [tweets, frac, split_seed])
    training_tweets = ex.artifact('training_tweets.pkl', 'tweet_df', do_split)
    testing_tweets = ex.artifact('testing_tweets.pkl', 'test_df', do_split)

    alpha = ex.literalForEach(np.linspace(0.2, 1.0, 2).tolist(), 'alpha')

    from train_model import train
    do_train = ex.action(train, [training_tweets, alpha])
    model = ex.artifact('model.pkl', 'intermediary', do_train)

    from test_model2 import test
    do_test = ex.action(test, [model, testing_tweets])
    model_accuracy = ex.literal(name='model_accuracy', parent=do_test)

model_accuracy.pull()
Esempio n. 3
0
import flor

@flor.func
def action(literal, artifact, **kwargs):
    with open(artifact, 'w') as f:
        f.write('Hello\n')

with flor.Experiment('code') as ex:
    lit = ex.literal(v=0, name='literal')

    do_action = ex.action(action, [lit, ])
    art = ex.artifact('artifact', 'artifact', do_action)

art.plot()
Esempio n. 4
0
#!/usr/bin/env python3
import flor
import numpy as np

ex = flor.Experiment("twitter_demo")
ex.groundClient('ground')

tweets = ex.artifact('tweets.csv')

frac = ex.literal(0.75, 'frac')
split_seed = ex.literal(42, 'split_seed')

from split import split

do_split = ex.action(split, [tweets, frac, split_seed])
training_tweets = ex.artifact('training_tweets.pkl', do_split)
testing_tweets = ex.artifact('testing_tweets.pkl', do_split)

alpha = ex.literal(np.linspace(0.0, 1.0, 8).tolist(), 'alpha')
alpha.forEach()

from train_model import train

do_train = ex.action(train, [training_tweets, alpha])
model = ex.artifact('model.pkl', do_train)

from test_model import test

do_test = ex.action(test, [model, testing_tweets])
model_accuracy = ex.artifact('model_accuracy.txt', do_test)
Esempio n. 5
0
#!/usr/bin/env python3
import flor

with flor.Experiment('stream') as ex:

    @flor.func
    def repeat(data, order, dest, **kwargs):
        with open(data, 'r') as f:
            with open(dest, 'w') as o:
                for line in f:
                    o.write("{}: {}\n".format(order, line))
                    o.write("{}: {}\n".format(order, line))

    order = ex.literalForEach(["first", "second"], "order")
    data = ex.artifact('data.txt', 'data')

    do_repeat = ex.action(repeat, [data, order])
    dest = ex.artifact('dest.txt', 'dest', do_repeat)

dest.plot()
dest.pull()
Esempio n. 6
0
#!/usr/bin/env python3
import flor

ex = flor.Experiment('twitter')

ex.groundClient('ground')

training_tweets = ex.artifact('training_tweets.csv')

from clean import clean
do_tr_clean = ex.action(clean, [training_tweets])
clean_training_tweets = ex.artifact('clean_training_tweets.pkl', do_tr_clean)

from train_model import train
do_train = ex.action(train, [clean_training_tweets, 0.0001])
intermediary = ex.artifact('intermediary.pkl', do_train)

testing_tweets = ex.artifact('testing_tweets.csv')

do_te_clean = ex.action(clean, [testing_tweets])
clean_testing_tweets = ex.artifact('clean_testing_tweets.pkl', do_te_clean)

from test_model import test
do_test = ex.action(test, [intermediary, clean_testing_tweets])
model_accuracy = ex.artifact('model_accuracy.txt', do_test)

model_accuracy.pull()
model_accuracy.plot()
Esempio n. 7
0
import flor

with flor.Experiment('coarse') as ex:
    
    ex.groundClient('ground')
    
    @flor.func
    def run_existing_pipeline(path_to_data, kernel):
        import math
        import numpy as np
        import pandas as pd
        from sklearn import metrics
        from sklearn.svm import SVR
        from sklearn.model_selection import train_test_split

        def manhattan_distance(x1, y1, x2, y2):
            return abs(x1 - x2) + abs(y1 - y2)

        def roundtime(tstring):
            hours, mins, secs = tstring.split(':')
            if int(mins) >= 30:
                if hours == '23':
                    return '00'
                else:
                    return str(int(hours) + 1)
            else:
                return hours

        def weekday(start):
            from datetime import datetime
            fmt = '%Y-%m-%d %H:%M:%S'
Esempio n. 8
0
@flor.func
def instantiate_agent(**kwargs):
    try:
        ray.get([])
    except:
        ray.init()

    register_env("my_env", lambda ec: pong_py.PongJSEnv())
    trainer = ppo.PPOAgent(env="my_env", config={"env_config": {}})
    return trainer


@flor.func
def write_literal(literal, artifact_path, **kwargs):
    with open(artifact_path, 'wb') as f:
        cloudpickle.dump(literal, f)


with flor.Experiment('nonserial_literal') as ex:
    do_instantiate_agent = ex.action(instantiate_agent)
    trainer = ex.literal(name="literal", parent=do_instantiate_agent)

    do_write_literal = ex.action(write_literal, [
        trainer,
    ])
    serialized_trainer = ex.artifact("trainer.pkl", 'artifact_path',
                                     do_write_literal)

serialized_trainer.plot()
serialized_trainer.pull()
Esempio n. 9
0
#!/usr/bin/env python3
import flor

ex = flor.Experiment('plate_demo')

ex.groundClient('ground')

ones = ex.literal([1, 2, 3], "ones")
ones.forEach()

tens = ex.literal([10, 100], "tens")
tens.forEach()

@flor.func
def multiply(x, y):
    z = x*y
    print(z)
    return z

doMultiply = ex.action(multiply, [ones, tens])
product = ex.artifact('product.txt', doMultiply)

product.plot()
product.pull()