示例#1
0
def test_save_load_list():
    ListClass = build_composite_list(
        input_type=Tuple(MatrixContinuousDense(), CategoricalVector()),
        output_type=List(CategoricalVector()),
    )
    algorithm = ListClass(DummyAlgorithm)

    fp = BytesIO()

    Pickler(fp).dump(algorithm)
    fp.seek(0)

    algorithm2 = Unpickler(fp).load()

    assert repr(algorithm) == repr(algorithm2)
示例#2
0
def automl_fit(
    input: Path,
    output: Path = Path("automl.bin"),
    target: str = None,
    ignore_cols: List[int] = typer.Option([]),
    evaluation_timeout: int = 5 * Min,
    memory_limit: int = 4 * Gb,
    search_timeout: int = 60 * 60,
    pop_size: int = 20,
    iterations: int = 100,
    random_state: int = None,
    format: str = None,
):
    """
    🏃 Train an AutoML instance on a dataset.
    """

    try:
        dataset = _load_dataset(format, input, ignore_cols)
    except ValueError as e:
        logger.error(f"⚠️  Error: {str(e)}")
        return

    if target is None:
        target = dataset.columns[-1]

    columns = [c for c in dataset.columns if c != target]

    X = dataset[columns].values
    y = dataset[target].values

    automl = AutoML(
        output=CategoricalVector(),
        search_kwargs=dict(
            evaluation_timeout=evaluation_timeout,
            memory_limit=memory_limit,
            search_timeout=search_timeout,
            pop_size=pop_size,
        ),
        random_state=random_state,
        search_iterations=iterations,
    )

    console.print(f"🏃 Training on {len(dataset)} items.")
    automl.fit(X, y, logger=RichLogger())

    with output.open("wb") as fp:
        automl.save(fp)

    console.print(f"💾 Saving model to [green]{output.absolute()}[/].")
示例#3
0
def run_automl(X, y, name, input=None, output=CategoricalVector()):
    telegram = TelegramLogger(
        token=os.environ["TOKEN"],
        channel="@autogoal_board",
        name=name,
    )
    console = ConsoleLogger()
    progress = ProgressLogger()

    automl = AutoML(
        search_iterations=1000,
        metalearning_log=True,
        search_kwargs=dict(search_timeout=2 * 60 * 60, pop_size=50),
        errors="ignore",
        input=input,
        output=output,
        cross_validation_steps=1,
    )

    automl.fit(X, y, logger=[telegram, console, progress])
示例#4
0
# in the `contrib` library, i.e., anything that could be potentially used
# to solve an AutoML problem.

for cls in find_classes():
    print("Using: %s" % cls.__name__)

# ## Experimentation

# Instantiate the classifier.
# Note that the input and output types here are defined to match the problem statement,
# i.e., text classification.

classifier = AutoML(
    search_algorithm=PESearch,
    input=List(Sentence()),
    output=CategoricalVector(),
    search_iterations=args.iterations,
    score_metric=f1_score,
    search_kwargs=dict(
        pop_size=args.popsize,
        search_timeout=args.global_timeout,
        evaluation_timeout=args.timeout,
        memory_limit=args.memory * 1024**3,
    ),
)

# This custom logger is used for debugging purposes, to be able later to recover
# the best pipelines and all the errors encountered in the experimentation process.


class CustomLogger(Logger):
示例#5
0
 def run(self, input: DenseMatrix()) -> CategoricalVector():
     # implementation of the algorithm
     pass
示例#6
0
 def run(
     self, input: Tuple(Sentence(), List(Tuple(Entity(), Entity(), Category())))
 ) -> Tuple(List(Vector()), CategoricalVector()):
     pass
示例#7
0
 def run(
     self, input: Tuple(Tensor3(),
                        CategoricalVector())) -> CategoricalVector():
     return super().run(input)
示例#8
0
 def run(
     self, input: Tuple(MatrixContinuousDense(), CategoricalVector())
 ) -> CategoricalVector():
     return super().run(input)
示例#9
0
 def run(
     self, input: Tuple(MatrixContinuousDense(), CategoricalVector())
 ) -> CategoricalVector():
     X, y = input
     return y