mismatching types (confusion matrix)

85 views
Skip to first unread message

Sebastian

unread,
Nov 20, 2016, 1:32:22 AM11/20/16
to julia-users
I am new to julia so i might ask a strange question.
So far i've been programming quite smoothly, but type managing leads me astray.

I have 1d arrays i want to apply a confusion matrix function to from the MLBase library.
http://mlbasejl.readthedocs.io/en/latest/perfeval.html

However i have unmatching types.

typeof(y1)

Array{String,1}:

typeof(y2)
Array{Any,1}


When i apply the confusion matrix on those variables:

k=4
confusmat
(k, y1, y2)


i get:

LoadError: MethodError: no method matching confusmat(::Int64, ::Array{String,1}, ::Array{Any,1})
Closest candidates are:



So now i probably need to convert y2 to a Array{String,1}
I can't find out how to convert y2 to Array{String,1}
Can anyone please help?

Mauro

unread,
Nov 20, 2016, 7:51:23 AM11/20/16
to julia...@googlegroups.com
On Sat, 2016-11-19 at 12:46, Sebastian <in...@quandbee.com> wrote:
> I am new to julia so i might ask a strange question.
> So far i've been programming quite smoothly, but type managing leads me
> astray.

Good to have you on board! Note that most discussion has moved to
https://discourse.julialang.org/, better post there in the future.

> I have 1d arrays i want to apply a confusion matrix function to from the
> MLBase library.
> http://mlbasejl.readthedocs.io/en/latest/perfeval.html
>
> However i have unmatching types.
>
> typeof(y1)
>
> Array{String,1}:
>
> typeof(y2)
> Array{Any,1}
>
>
> When i apply the confusion matrix on those variables:
>
> k=4
> confusmat(k, y1, y2)
>
>
> i get:
>
> LoadError: MethodError: no method matching confusmat(::Int64,
> ::Array{String,1}, ::Array{Any,1})
> Closest candidates are:
>
>
>
> So now i probably need to convert y2 to a Array{String,1}
> I can't find out how to convert y2 to Array{String,1}
> Can anyone please help?

julia> Any["dasf"]
1-element Array{Any,1}:
"dasf"

julia> convert(Vector{String}, ans)
1-element Array{String,1}:
"dasf"


But probably you should make sure that y2 is Vector{String} from the
start. (Note Vector{String}==Array{String,1})
Reply all
Reply to author
Forward
0 new messages