High Level Interface
The following interfaces are provided by this package to interact with predictors.
add!
DiscretePredictors.add!
— Function.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' )
predict
DiscretePredictors.predict
— Function.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
info_string
DiscretePredictors.info_string
— Function.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)"
unique_string
DiscretePredictors.unique_string
— Function.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"
get_best_symbol
DiscretePredictors.get_best_symbol
— Function.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
size
Base.size
— Function.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)