JuliaStats / MLBase.jl

A set of functions to support the development of machine learning algorithms
MIT License
185 stars 63 forks source link

add common class encodings as wrapper for labelmap #21

Closed Evizero closed 9 years ago

Evizero commented 9 years ago

I am tinkering on a package where I need these and I though these classes would be a better fit here. I included the tests as well. If there is interest I will also adapt the documentation accordingly.

I included these encodings as wrappers around labelmap:

It allows you to do things like

t = ["y", "n", "k", "y"]
y = ["n", "y", "y", "k", "n"]

encoding = OneOfKClassEncoding(t)
pred = labelencode(encoding, y)

where the pred would end up being

@test pred ==
  [0  1  0;
   1  0  0;
   1  0  0;
   0  0  1;
   0  1  0]

and of course labeldecode would bring you back to the input

@test labeldecode(encoding, pred) == y

let me know what you think.

Evizero commented 9 years ago

Since there seems to be very little activity here, I'm going to move along separately from this package