NaiveBayes.HybridNB
— TypeInitialize a HybridNB
model with continuous and/or discrete features
Constructors
HybridNB(labels::AbstractVector, kde_names::AbstractVector, discrete_names::AbstractVector)
HybridNB(labels::AbstractVector, kde_names::AbstractVector)
HybridNB(labels::AbstractVector, num_kde::Int, num_discrete::Int)
Arguments
labels
: An AbstractVector{Any} of feature labelskde_names
: An AbstractVector{Any} of the names of continuous featuresdiscrete_names
: An AbstractVector{Any} of the names of discrete featuresnum_kde
: Number of continuous featuresnum_discrete
: Number of discrete features
NaiveBayes.HybridNB
— MethodHybridNB(labels::Vector{Int64}) -> model_h
HybridNB(labels::Vector{Int64}, AstractString) -> model_h
A constructor for both types of features
NaiveBayes.MultinomialNB
— MethodMultinomial Naive Bayes classifier
classes : array of objects Class names n_vars : Int64 Number of variables in observations alpha : Number (optional, default 1) Smoothing parameter. E.g. if alpha equals 1, each variable in each class is believed to have 1 observation by default
NaiveBayes.NBModel
— TypeBase type for Naive Bayes models. Inherited classes should have at least following fields: ccounts::Dict{C, Int64} - count of ocurrences of each class nobs::Int64 - total number of observations
NaiveBayes.ePDF
— Typea wrapper around key value pairs for a discrete probability distribution
NaiveBayes.ePDF
— MethodConstructor of ePDF
NaiveBayes.logprob_x_given_c
— MethodCalculate log P(x|C)
NaiveBayes.logprob_x_given_c
— MethodCalculate log P(x|C)
NaiveBayes.logprob_x_given_c
— MethodCalculate log P(x|C)
NaiveBayes.logprob_x_given_c
— MethodCalculate log P(x|C)
NaiveBayes.num_samples
— Methodcompute the number of samples
NaiveBayes.predict_logprobs
— Methodpredict_logprobs(m::HybridNB, features_c::Vector{Vector{Float64}, features_d::Vector{Vector{Int})
Return the log-probabilities for each column of X, where each row is the class
NaiveBayes.predict_logprobs
— MethodPredict log probabilities for all classes
NaiveBayes.predict_logprobs
— MethodPredict log probabilities for all classes
NaiveBayes.predict_proba
— Methodpredict_proba{V<:Number}(m::HybridNB, f_c::Vector{Vector{Float64}}, f_d::Vector{Vector{Int64}})
Predict log-probabilities for the input features. Returns tuples of predicted class and its log-probability estimate.
NaiveBayes.predict_proba
— MethodPredict logprobs, return tuples of predicted class and its logprob
NaiveBayes.probability
— Methodquery the ePDF to get the probability of n
NaiveBayes.restructure_matrix
— Methodrestructure_matrix(M::Matrix) -> V::Dict{Symbol, Vector}
Restructure a matrix as vector of vectors
NaiveBayes.sum_log_x_given_c!
— Methodcomputes log[P(x⃗ⁿ|c)] ≈ ∑ᵢ log[p(xⁿᵢ|c)]
NaiveBayes.to_matrix
— Methodto_matrix(D::Dict{Symbol, Vector}}) -> M::Matrix
convert a dictionary of vectors into a matrix
NaiveBayes.train
— Methodtrain(HybridNB, continuous, discrete, labels) -> model2
StatsBase.fit
— Methodfit(m::HybridNB, f_c::Vector{Vector{Float64}}, f_d::Vector{Vector{Int64}}, labels::Vector{Int64})
Train NB model with discrete and continuous features by estimating P(x⃗|c)
StatsBase.fit
— Methodfit(m::HybridNB, f_c::Matrix{Float64}, labels::Vector{Int64})
Train NB model with continuous features only
StatsBase.predict
— Methodpredict(m::HybridNB, f_c::Vector{Vector{Float64}}, f_d::Vector{Vector{Int64}}) -> labels
Predict hybrid naive bayes for continuos featuers only
StatsBase.predict
— MethodPredict kde naive bayes for continuos featuers only