I’m doing a framework for recommendation systems called Persa.jl (https://github.com/filipebraida/Persa.jl). My idea is that the core is a module and it’s possible to extend this framework to solve a Collaborative Filtering problem (such as cold start, noise, etc) and also be able to create/implement new prediction models.
Currently, I’ve created a wrapper for the suprise-python framework and use their models.
I would like to remove from Persa.jl project and create a separate project.
Here’s an example:
Surprise
type GlobalMean2 <: Persa.CFModel
μ::Float64
end
GlobalMean2{T<:Persa.CFDatasetAbstract}(dataset::T) = GlobalMean2(Persa.mean(dataset))
function Persa.train!{T<:Persa.CFDatasetAbstract}(model::Surprise.GlobalMean2, dataset::T)
end
Persa.predict(model::Surprise.GlobalMean2, user::Int, item::Int) = model.μ
Persa.canPredict(model::Surprise.GlobalMean2, user::Int, item::Int) = true
end
When I call it, Julia gives an error saying that it cannot convert the input parameter (Surprise.GlobalMean2 (ds_train)).
In fact, what I would like to do would be module inheritance.
That’s usually done by writing the interface on abstract types, and allowing other modules to create their own concrete instances and overload specific methods as necessary. It’s not clear to me what exactly you’re trying to do.
I would like to create a wrapper that use framework Persa.jl. So, I create a type and a function to wrapper a function of the python-surprise package.
Code:
type SurpriseKNNBaseline <: SurpriseModel
object::PyObject
preferences::Persa.RatingPreferences
k::Int
min_k::Int
end
function SurpriseKNNBaseline(dataset::Persa.CFDatasetAbstract; k = 40, min_k = 1)
return SurpriseKNNBaseline(surprise.KNNBaseline(k = k, min_k = min_k), dataset.preferences, k , min_k);
end
This construction gives me this error:
MethodError: Cannot `convert` an object of type Persa.RatingPreferences{Float64} to an object of type Persa.RatingPreferences{Float64}
This may have arisen from a call to the constructor Persa.RatingPreferences{Float64}(...),
since type constructors fall back to convert methods.
in #SurpriseKNNWithMeans#3(::Int64, ::Int64, ::Type{T}, ::Persa.CFDataset) at methods.jl:40
in (::Core.#kw#Type)(::Array{Any,1}, ::Type{Surprise.SurpriseKNNWithMeans}, ::Persa.CFDataset) at <missing>:0
in include_string(::String, ::String) at loading.jl:441
in eval(::Module, ::Any) at boot.jl:234
in (::Atom.##65#68)() at eval.jl:102
in withpath(::Atom.##65#68, ::Void) at utils.jl:30
in withpath(::Function, ::Void) at eval.jl:38
in macro expansion at eval.jl:101 [inlined]
in (::Atom.##64#67{Dict{String,Any}})() at task.jl:60