• This repository has been archived on 21/May/2022
  • Stars
    star
    28
  • Rank 853,354 (Top 18 %)
  • Language
    Julia
  • License
    Other
  • Created about 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A generic and modular framework for building custom iterative algorithms in Julia

DEPRECATED

This package is deprecated.

LearningStrategies

Master Build Test Coverage Discussion
Build Status Build status codecov Gitter chat

LearningStrategies is a modular framework for building iterative algorithms in Julia.

Below, some of the key concepts are briefly explained, and a few examples are made. A more in-depth notebook can be found here

Basics

Many algorithms can be generalized to the following pseudocode:

setup
while not finished:
    (update model)
    (iteration logic)
cleanup

MetaStrategy

The core function of LearningStrategies is a straightforward abstract implementation of the above loop. A model can be learned by an LearningStrategy or a collection of strategies in a MetaStrategy.

function learn!(model, strat::LearningStrategy, data)
    setup!(strat, model[, data])
    for (i, item) in enumerate(data)
        update!(model, strat[, i], item)
        hook(strat, model[, data], i)
        finished(strat, model[, data], i) && break
    end
    cleanup!(strat, model)
    model
end
  • For a MetaStrategy, each function (setup!, update!, hook, finished, cleanup!) is mapped to the contained strategies.
  • To let item == data, pass the argument Iterators.repeated(data).

Built In Strategies

See help (i.e. ?MaxIter) for more info.

  • MetaStrategy
  • MaxIter
  • TimeLimit
  • Converged
  • ConvergedTo
  • IterFunction
  • Tracer
  • Breaker
  • Verbose

Examples

Learning with a single LearningStrategy

julia> using LearningStrategies

julia> s = Verbose(TimeLimit(2))
Verbose TimeLimit(2.0)

julia> @elapsed learn!(nothing, s)  # data == InfiniteNothing()
INFO: TimeLimit(2.0) finished
2.000225545

Learning with a MetaLearner

julia> using LearningStrategies

julia> s = strategy(Verbose(MaxIter(5)), TimeLimit(10))
MetaStrategy
  > Verbose MaxIter(5)
  > TimeLimit(10.0)

julia> learn!(nothing, s, 1:100)
INFO: MaxIter: 1/5
INFO: MaxIter: 2/5
INFO: MaxIter: 3/5
INFO: MaxIter: 4/5
INFO: MaxIter: 5/5
INFO: MaxIter(5) finished

Linear Regression Solver

using LearningStrategies
import LearningStrategies: update!, finished
import Base.Iterators: repeated

struct MyLinearModel
    coef
end

struct MyLinearModelSolver <: LearningStrategy end

update!(model, s::MyLinearModelSolver, xy) = (model.coef[:] = xy[1] \ xy[2])

finished(s::MyLinearModelSolver, model) = true

# generate some fake data
x = randn(100, 5)
y = x * range(-1, stop=1, length=5) + randn(100)

data = (x, y)

# Create the model
model = MyLinearModel(zeros(5))

# learn! the model with data (x, y)
learn!(model, MyLinearModelSolver(), repeated(data))

# check that it works
model.coef == x \ y

More Examples

There are some user contributed snippets in the examples dir.

  • dftracer.jl shows a tracer with DataFrame as underlying storage.

Acknowledgements

LearningStrategies is partially inspired by IterationManagers and (Tom Breloff's) conversations with Spencer Lyon. This functionality was previously part of the StochasticOptimization package, but was split off as a dependency.

Complex LearningStrategy examples (using previous LearningStrategies versions) can be found in StochasticOptimization and from Tom Breloff's blog posts.

Examples using the current version can be found in SparseRegression.

Primary author: Tom Breloff

More Repositories

1

MLDatasets.jl

Utility package for accessing common Machine Learning datasets in Julia
Julia
218
star
2

Reinforce.jl

Abstractions, algorithms, and utilities for reinforcement learning in Julia
Julia
201
star
3

LossFunctions.jl

Julia package of loss functions for machine learning.
Julia
146
star
4

OpenAIGym.jl

OpenAI's Gym binding for Julia
Julia
104
star
5

MLDataUtils.jl

Utility package for generating, loading, splitting, and processing Machine Learning datasets
Julia
101
star
6

TableTransforms.jl

Transforms and pipelines with tabular data in Julia
Julia
100
star
7

MLUtils.jl

Utilities and abstractions for Machine Learning tasks
Julia
99
star
8

OpenAI.jl

OpenAI API wrapper for Julia
Julia
86
star
9

LIBSVM.jl

LIBSVM bindings for Julia
Julia
85
star
10

MLDataPattern.jl

Utility package for subsetting, resampling, iteration, and partitioning of various types of data sets in Machine Learning
Julia
60
star
11

Learn.jl

JuliaML bundled in a convenient all-in-one toolkit.
Julia
57
star
12

AtariAlgos.jl

Arcade Learning Environment (ALE) wrapped as a Reinforce.jl environment
Julia
40
star
13

MLLabelUtils.jl

Utility package for working with classification targets and label-encodings
Julia
32
star
14

Transformations.jl

Static transforms, activation functions, and other implementations of LearnBase abstractions
Julia
31
star
15

StochasticOptimization.jl

Implementations of stochastic optimization algorithms and solvers
Julia
30
star
16

DensityRatioEstimation.jl

Density ratio estimation in Julia
Julia
30
star
17

ValueHistories.jl

Utilities to efficiently track learning curves or other optimization information
Julia
29
star
18

PenaltyFunctions.jl

Julia package of regularization functions for machine learning
Julia
26
star
19

MLMetrics.jl

Metrics for scoring machine learning models in Julia
Julia
25
star
20

MLPlots.jl

Plotting recipes for statistics and machine learning using Plots.jl
Julia
24
star
21

TableDistances.jl

Distances between heterogeneous tabular data
Julia
23
star
22

LearnBase.jl

Abstractions for Julia Machine Learning Packages
Julia
17
star
23

MLPreprocessing.jl

Julia
15
star
24

LIBLINEAR.jl

LIBLINEAR bindings for Julia
Julia
11
star
25

META

Discussions related to the future of Machine Learning in Julia
10
star
26

OpenAIGymAPI.jl

A Julia package providing access to the OpenAI Gym API
Julia
10
star
27

ContinuousOptimization.jl

A playground for implementations of unconstrained continuous full-batch optimization algorithms
Julia
8
star
28

TransformsBase.jl

Base package for general data transformations in Julia
Julia
7
star
29

DataScienceTraits.jl

Traits for data science
Julia
6
star
30

ObjectiveFunctions.jl

Generic definitions of objective functions using abstractions from LearnBase
Julia
5
star
31

JuliaML.github.io

The home page of the JuliaML organization
JavaScript
5
star
32

StatsLearnModels.jl

Statistical learning models for tabular data
Julia
4
star
33

Prox.jl

Bank of proximal operators to support proximal optimization algorithms
Julia
3
star
34

RankAggregation.jl

Rank aggregation in Julia
Julia
3
star
35

FileStorage

Storage for images and other binary files used throughout our documentation
Julia
2
star
36

TransformsAPI.jl

Julia API for general data transformations
Julia
2
star
37

ColumnSelectors.jl

Column selectors for tables
Julia
2
star