Tractables/LogicCircuits.jl

Support evaluate for one instance

Closed this issue · 1 comments

Currently evalute throws error if used on on instance for example:

circuit(data[1,:])

throw error that num_examples not defined.

One way to circument this is to do:

circuit(data[1:1,:])

But would be nice for end user to not have to deal with this.


or similarly we get similar errors for:

circuit(BitArray(undef, num_variables(circuit)))
circuit(Array{Bool}(undef, num_variables(circuit)))

More details:

MethodError: no method matching num_examples(::DataFrames.DataFrameRow{DataFrames.DataFrame,DataFrames.Index})
Closest candidates are:
  num_examples(!Matched::DataFrames.DataFrame) at /home/pasha/.julia/packages/LogicCircuits/CjRCP/src/Utils/data.jl:21
  num_examples(!Matched::AbstractArray{T,2} where T) at /home/pasha/.julia/packages/LogicCircuits/CjRCP/src/Utils/data.jl:22

Stacktrace:
 [1] evaluate(::Plain⋁Node, ::DataFrames.DataFrameRow{DataFrames.DataFrame,DataFrames.Index}) at /home/pasha/.julia/packages/LogicCircuits/CjRCP/src/queries.jl:177
 [2] (::Plain⋁Node)(::DataFrames.DataFrameRow{DataFrames.DataFrame,DataFrames.Index}) at /home/pasha/.julia/packages/LogicCircuits/CjRCP/src/queries.jl:171
 [3] top-level scope at In[138]:1

You can now do circuit(true, false, true) as well as circuit([true, false, true]) to evaluate the circuit on a single instance.