# How do I compute a multiclass F-score using MLJ?

**URL:** <https://discourse.julialang.org/t/how-do-i-compute-a-multiclass-f-score-using-mlj/78579>\
**Category:** Machine Learning\
**Created:** [March 28, 2022, 12:53am UTC](https://discourse.julialang.org/t/how-do-i-compute-a-multiclass-f-score-using-mlj/78579 "2022-03-28T00:53:35Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ven-k](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ven-k/32/11915_2.png) [@ven-k](https://discourse.julialang.org/u/ven-k)\
**Post date:** [April 2, 2022, 3:58pm UTC](https://discourse.julialang.org/t/how-do-i-compute-a-multiclass-f-score-using-mlj/78579/5 "2022-04-02T15:58:42Z")

</div>

If you want to access the per class weighted FScore in the example above by @ablaom,

```julia
julia> m_no_avg = MulticlassFScore(average=no_avg)
MulticlassFScore(β = 1.0,average = MLJBase.NoAvg(),return_type = LittleDict)

julia> class_w = LittleDict('a' => 0.1, 'b' => 0.4, 'c' => 0.5)
LittleDict{Char, Float64, Vector{Char}, Vector{Float64}} with 3 entries:
  'a' => 0.1
  'b' => 0.4
  'c' => 0.5

julia> f1_no_avg = m_no_avg(y1, y2, class_w)
LittleDict{String, Float64, Vector{String}, Vector{Float64}} with 3 entries:
  "a" => 0.06
  "b" => 0.0
  "c" => 0.0

julia> m(y1, y2, class_w) # By default, macro_avg is used and notice that its same as mean(f1_no_avg)
0.02

```

MLJBase considers this family of multiclass scores to be of:

- micro\_avg → M(ulticlass)TP, MTN… are computed across classes and then the MRecall, MFScore… are computed
- macro\_avg → MTP, MTN… are computed per class and MRecall, MFScore… are also computed per class and averaged value is returned
- no\_avg → MTP, MTN… are computed per class and per class MRecall, MFScore are returned

Further the weighted scores are supported for both `average=macro_avg` and `average=no_avg` to suit our broader design of package and stay flexible (most scores return vector, as it’s convenient to check per-class values and apply aggregation if necessary).

As class info is not available with `micro_avg`, it’s promoted to `macro_avg` whenever weights are passed.

---

_[View the full topic](https://discourse.julialang.org/t/how-do-i-compute-a-multiclass-f-score-using-mlj/78579)._
