{"id":21152387,"url":"https://github.com/juliaml/valuehistories.jl","last_synced_at":"2025-03-14T14:44:05.389Z","repository":{"id":56311230,"uuid":"44478150","full_name":"JuliaML/ValueHistories.jl","owner":"JuliaML","description":"Utilities to efficiently track learning curves or other optimization information","archived":false,"fork":false,"pushed_at":"2021-02-15T09:45:04.000Z","size":143,"stargazers_count":30,"open_issues_count":3,"forks_count":13,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-10T22:43:16.386Z","etag":null,"topics":["machine-learning","monitoring-tool"],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaML.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-18T12:58:47.000Z","updated_at":"2024-10-13T11:58:17.000Z","dependencies_parsed_at":"2022-08-15T16:30:55.213Z","dependency_job_id":null,"html_url":"https://github.com/JuliaML/ValueHistories.jl","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaML%2FValueHistories.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaML%2FValueHistories.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaML%2FValueHistories.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaML%2FValueHistories.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaML","download_url":"https://codeload.github.com/JuliaML/ValueHistories.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243597782,"owners_count":20316842,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","monitoring-tool"],"created_at":"2024-11-20T10:39:31.485Z","updated_at":"2025-03-14T14:44:05.356Z","avatar_url":"https://github.com/JuliaML.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ValueHistories\n\n*Utility package for efficient tracking of optimization histories,\ntraining curves or other information of arbitrary types and at\narbitrarily spaced sampling times*\n\n| **Package License** | **PkgEval (Nanosoldier)** | **Build Status**  |\n|:------------------:|:---------------------:|:-----------------:|\n| [![License](http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE.md) | [![PkgEval][pkgeval-img]][pkgeval-url] | [![Build Status](https://travis-ci.org/JuliaML/ValueHistories.jl.svg?branch=master)](https://travis-ci.org/JuliaML/ValueHistories.jl) [![Build status](https://ci.appveyor.com/api/projects/status/8v1n9hqfnn5jslyn/branch/master?svg=true)](https://ci.appveyor.com/project/Evizero/valuehistories-jl/branch/master) [![Coverage Status](https://coveralls.io/repos/github/JuliaML/ValueHistories.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaML/ValueHistories.jl?branch=master) |\n\n[pkgeval-img]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/V/ValueHistories.svg\n[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/V/ValueHistories.html\n\n## Installation\n\nThis package is registered in `METADATA.jl` and can be installed as usual\n\n```julia\npkg\u003e add ValueHistories\n```\n\n## Overview\n\nWe provide two basic approaches for logging information over time\nor iterations. The sample points do not have to be equally spaced as\nlong as time/iteration is strictly increasing.\n\n- **Univalue histories**: Intended for tracking the evolution of\na single value over time.\n- **Multivalue histories**: Track an arbitrary amount of values over\ntime, each of which can be of a different type and associated with\na label\n\n*Note that both approaches are typestable.*\n\n### Univalue Histories\n\nThis package provide two different concrete implementations\n\n- `QHistory`: Logs the values using a `Dequeue`\n- `History`: Logs the values using a `Vector`\n\nSupported operations for univalue histories:\n\n- `push!(history, iteration, value)`: Appends a value to the history\n- `get(history)`: Returns all available observations as two vectors. The first vector contains the iterations and the second vector contains the values.\n- `enumerate(history)` Returns an enumerator over the observations (as tuples)\n- `first(history)`: First stored observation (as tuple)\n- `last(history)`: Last stored observation (as tuple)\n- `length(history)`: Number of stored observations\n- `increment!(history, iteration, value)`: Similar to `push!` but increments the `value` if the `iteration` already exists. Only supported by `History`.\n\nHere is a little example code showing the basic usage:\n\n```julia\nusing Primes\n\n# Specify the type of value you wish to track\nhistory = QHistory(Float64)\n\nfor i = 1:100\n  # Store some value of the specified type\n  # Note how the sampling times are not equally spaced\n  isprime(i) \u0026\u0026 push!(history, i, sin(.1*i))\nend\n\n# Access stored values as arrays\nx, y = get(history)\n@assert typeof(x) \u003c: Vector{Int}\n@assert typeof(y) \u003c: Vector{Float64}\n\n# You can also enumerate over the observations\nfor (x, y) in enumerate(history)\n  @assert typeof(x) \u003c: Int\n  @assert typeof(y) \u003c: Float64\nend\n\n# Let's see how this prints to the REPL\nhistory\n```\n\n```\nQHistory\n    types: Int64, Float64\n    length: 25\n```\n\nFor easy visualisation we also provide recipes for `Plots.jl`.\nNote that this is only supported for `Real` types.\n\n```julia\nusing Plots\nplot(history, legend=false)\n```\n\n![qhistory](https://rawgithub.com/JuliaML/FileStorage/master/ValueHistories/qhistory.svg)\n\n### Multivalue Histories\n\nMultivalue histories are more or less a dynamic collection of a number\nof univalue histories. Each individual univalue history is associated\nwith a symbol `key`. If the user stores a value under a `key` that\nhas no univalue history associated with it, then a new one is allocated\nand specialized for the given type.\n\nSupported operations for multivalue histories:\n\n- `push!(history, key, iteration, value)`: Appends a value to the multivalue history\n- `get(history, key)`: Returns all available observations as two vectors. The first vector contains the iterations and the second vector contains the values.\n- `enumerate(history, key)` Returns an enumerator over the observations (as tuples)\n- `first(history, key)`: First stored observation (as tuple)\n- `last(history, key)`: Last stored observation (as tuple)\n- `length(history, key)`: Number of stored observations\n- `increment!(history, key, iteration, value)`: Similar to `push!` but increments the `value` if the `key` and `iteration` combination already exists.\n\nHere is a little example code showing the basic usage:\n\n```julia\nusing ValueHistories, Primes\nhistory = MVHistory()\n\nfor i=1:100\n    x = 0.1i\n\n    # Store any kind of value without losing type stability\n    # The first push! to a key defines the tracked type\n    #   push!(history, key, iter, value)\n    push!(history, :mysin, x, sin(x))\n    push!(history, :mystring, i, \"i=$i\")\n\n    # Sampling times can be arbitrarily spaced\n    # Note how we store the sampling time as a Float32 this time\n    isprime(i) \u0026\u0026 push!(history, :mycos, Float32(x), cos(x))\nend\n\n# Access stored values as arrays\nx, y = get(history, :mysin)\n@assert length(x) == length(y) == 100\n@assert typeof(x) \u003c: Vector{Float64}\n@assert typeof(y) \u003c: Vector{Float64}\n\n# Each key can be queried individually\nx, y = get(history, :mystring)\n@assert length(x) == length(y) == 100\n@assert typeof(x) \u003c: Vector{Int64}\n@assert typeof(y) \u003c: Vector{String}\n@assert y[1] == \"i=1\"\n\n# You can also enumerate over the observations\nfor (x, y) in enumerate(history, :mycos)\n  @assert typeof(x) \u003c: Float32\n  @assert typeof(y) \u003c: Float64\nend\n\n# Let's see how this prints to the REPL\nhistory\n```\n\n```\nMVHistory{ValueHistories.History{I,V}}\n  :mysin =\u003e 100 elements {Float64,Float64}\n  :mystring =\u003e 100 elements {Int64,String}\n  :mycos =\u003e 25 elements {Float32,Float64}\n```\n\nFor easy visualisation we also provide recipes for `Plots.jl`.\nNote that this is only supported for `Real` types.\n\n```julia\nusing Plots\nplot(history)\n```\n\n![mvhistory](https://rawgithub.com/JuliaML/FileStorage/master/ValueHistories/mvhistory.svg)\n\n## License\n\nThis code is free to use under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaml%2Fvaluehistories.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliaml%2Fvaluehistories.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaml%2Fvaluehistories.jl/lists"}