density returns the density score which measures the goodness of the labelling density compared to the user defined target based on the want parameter given to talbotLinHanrahan.
(have, want int, dMin, dMax, lMin, lMax float64)
| 240 | // the labelling density compared to the user defined target |
| 241 | // based on the want parameter given to talbotLinHanrahan. |
| 242 | func density(have, want int, dMin, dMax, lMin, lMax float64) float64 { |
| 243 | rho := float64(have-1) / (lMax - lMin) |
| 244 | rhot := float64(want-1) / (math.Max(lMax, dMax) - math.Min(dMin, lMin)) |
| 245 | if d := rho / rhot; d >= 1 { |
| 246 | return 2 - d |
| 247 | } |
| 248 | return 2 - rhot/rho |
| 249 | } |
| 250 | |
| 251 | // maxDensity returns the maximum density score achievable for have and want. |
| 252 | func maxDensity(have, want int) float64 { |
no test coverage detected