我已经使用 DecisionTree 模块在 Julia 中训练了一个修剪过的决策树模型。我现在想保存这个模型以供以后用于其他数据集。

我尝试将模型转换为数据数组以使用 writetable() 导出,并且尝试使用 writedlm() 导出,但这些都不起作用。当我查看模型的类型时,我发现它是一个 DecisionTree.Node 类型。我不知道如何使用它,也无法导出/保存它。

In:DataFrame(PrunedModel)
Out:LoadError: MethodError: `convert` has no method matching convert(::Type{DataFrames.DataFrame}, ::DecisionTree.Node)
This may have arisen from a call to the constructor DataFrames.DataFrame(...),
since type constructors fall back to convert methods.
Closest candidates are:
  call{T}(::Type{T}, ::Any)
  convert(::Type{DataFrames.DataFrame}, !Matched::Array{T,2})
  convert(::Type{DataFrames.DataFrame}, !Matched::Dict{K,V})
  ...
while loading In[22], in expression starting on line 1
 in call at essentials.jl:56

In:typeof(PrunedModel)
Out:DecisionTree.Node

我有什么想法可以保存这个模型以备后用吗?

最佳答案

如果我正确理解这是一个 Julia 对象,您应该尝试使用 JLD.jl 包将对象保存到磁盘并重新加载,保留类型信息。

关于export - 保存决策树模型以供以后在 Julia 中应用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37779600/

10-12 16:32