High Level Interface

High Level Interface

The following interfaces are provided by this package to interact with predictors.

add!

add!( p::Predictor{SymbolType}, s::SymbolType)

Adds a symbols s to the prediction model.

Example

julia> p = LZ78{Char}()
DiscretePredictors.LZ78{Char}([*] (0)
, Char[], Char[])

julia> add!( p, 'd' )
source

predict

predict( p::Predictor{SymbolType} )

Returns a dictionary of Dict{SymbolType,Float64} with probabilities of next symbol.

Examples

julia> p = LZ78{Int}()
DiscretePredictors.LZ78{Int}([*] (0)
, Int[], Int[])

julia> add!( p, 2 )

julia> add!( p, 3 )

julia> predict( p )
Dict{Int,Float64} with 2 entries:
  2 => 0.5
  3 => 0.5
source

info_string

info_string( p::Predictor{SymbolType} )

Returns a string with information about the predictor p.

Example

julia> p = DG{Char}(4)
DiscretePredictors.DG{Char}([*] (0)
, Char[], 4)

julia> info_string( p )
"DG(4)"
source

unique_string

unique_string( p::Predictor{SymbolType} )

Returns an unique string to identify the predictor; Useful for naming log files.

Example

julia> p = DG{Char}(4)
DiscretePredictors.DG{Char}([*] (0)
, Char[], 4)

julia> unique_string( p )
"DG_04"
source

get_best_symbol

get_best_symbol( p::Predictor{SymbolType} [,default_sym = nothing] )

Returns the most probable symbol from predictor p on current context. If no symbol to predict, then returns default_sym.

Example

julia> p = DG{Int}(4)
DiscretePredictors.DG{Int}([*] (0)
, Int[], 4)

julia> get_best_symbol( p )

julia> get_best_symbol( p, 2 )
2
source

size

Base.sizeFunction.
size( p::Predictor{SymbolType} )

Returns the number of nodes in the model of predictor p including root node.

Example

julia> p = KOM{Int}(3)
DiscretePredictors.KOM{Int}([*] (0)
, Int[], 3)

julia> add!(p,1); add!(p,3); add!(p,2); add!(p,2); add!(p,1)

julia> size( p )
13

julia> p.model
[*] (5)
+---[2] (2)
     +---[2] (1)
          +---[1] (1)
     +---[1] (1)
+---[3] (1)
     +---[2] (1)
          +---[2] (1)
               +---[1] (1)
+---[1] (2)
     +---[3] (1)
          +---[2] (1)
               +---[2] (1)
source