• Stars
    star
    29
  • Rank 832,432 (Top 17 %)
  • Language
    Julia
  • License
    Other
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

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

Repository Details

Utilities to efficiently track learning curves or other optimization information

ValueHistories

Utility package for efficient tracking of optimization histories, training curves or other information of arbitrary types and at arbitrarily spaced sampling times

Package License PkgEval (Nanosoldier) Build Status
License PkgEval Build Status Build status Coverage Status

Installation

This package is registered in METADATA.jl and can be installed as usual

pkg> add ValueHistories

Overview

We provide two basic approaches for logging information over time or iterations. The sample points do not have to be equally spaced as long as time/iteration is strictly increasing.

  • Univalue histories: Intended for tracking the evolution of a single value over time.
  • Multivalue histories: Track an arbitrary amount of values over time, each of which can be of a different type and associated with a label

Note that both approaches are typestable.

Univalue Histories

This package provide two different concrete implementations

  • QHistory: Logs the values using a Dequeue
  • History: Logs the values using a Vector

Supported operations for univalue histories:

  • push!(history, iteration, value): Appends a value to the history
  • get(history): Returns all available observations as two vectors. The first vector contains the iterations and the second vector contains the values.
  • enumerate(history) Returns an enumerator over the observations (as tuples)
  • first(history): First stored observation (as tuple)
  • last(history): Last stored observation (as tuple)
  • length(history): Number of stored observations
  • increment!(history, iteration, value): Similar to push! but increments the value if the iteration already exists. Only supported by History.

Here is a little example code showing the basic usage:

using Primes

# Specify the type of value you wish to track
history = QHistory(Float64)

for i = 1:100
  # Store some value of the specified type
  # Note how the sampling times are not equally spaced
  isprime(i) && push!(history, i, sin(.1*i))
end

# Access stored values as arrays
x, y = get(history)
@assert typeof(x) <: Vector{Int}
@assert typeof(y) <: Vector{Float64}

# You can also enumerate over the observations
for (x, y) in enumerate(history)
  @assert typeof(x) <: Int
  @assert typeof(y) <: Float64
end

# Let's see how this prints to the REPL
history
QHistory
    types: Int64, Float64
    length: 25

For easy visualisation we also provide recipes for Plots.jl. Note that this is only supported for Real types.

using Plots
plot(history, legend=false)

qhistory

Multivalue Histories

Multivalue histories are more or less a dynamic collection of a number of univalue histories. Each individual univalue history is associated with a symbol key. If the user stores a value under a key that has no univalue history associated with it, then a new one is allocated and specialized for the given type.

Supported operations for multivalue histories:

  • push!(history, key, iteration, value): Appends a value to the multivalue history
  • get(history, key): Returns all available observations as two vectors. The first vector contains the iterations and the second vector contains the values.
  • enumerate(history, key) Returns an enumerator over the observations (as tuples)
  • first(history, key): First stored observation (as tuple)
  • last(history, key): Last stored observation (as tuple)
  • length(history, key): Number of stored observations
  • increment!(history, key, iteration, value): Similar to push! but increments the value if the key and iteration combination already exists.

Here is a little example code showing the basic usage:

using ValueHistories, Primes
history = MVHistory()

for i=1:100
    x = 0.1i

    # Store any kind of value without losing type stability
    # The first push! to a key defines the tracked type
    #   push!(history, key, iter, value)
    push!(history, :mysin, x, sin(x))
    push!(history, :mystring, i, "i=$i")

    # Sampling times can be arbitrarily spaced
    # Note how we store the sampling time as a Float32 this time
    isprime(i) && push!(history, :mycos, Float32(x), cos(x))
end

# Access stored values as arrays
x, y = get(history, :mysin)
@assert length(x) == length(y) == 100
@assert typeof(x) <: Vector{Float64}
@assert typeof(y) <: Vector{Float64}

# Each key can be queried individually
x, y = get(history, :mystring)
@assert length(x) == length(y) == 100
@assert typeof(x) <: Vector{Int64}
@assert typeof(y) <: Vector{String}
@assert y[1] == "i=1"

# You can also enumerate over the observations
for (x, y) in enumerate(history, :mycos)
  @assert typeof(x) <: Float32
  @assert typeof(y) <: Float64
end

# Let's see how this prints to the REPL
history
MVHistory{ValueHistories.History{I,V}}
  :mysin => 100 elements {Float64,Float64}
  :mystring => 100 elements {Int64,String}
  :mycos => 25 elements {Float32,Float64}

For easy visualisation we also provide recipes for Plots.jl. Note that this is only supported for Real types.

using Plots
plot(history)

mvhistory

License

This code is free to use under the terms of the MIT license.

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

LearningStrategies.jl

A generic and modular framework for building custom iterative algorithms in Julia
Julia
28
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