alternativeSpecies property

Map<String, double> get alternativeSpecies

Gets alternative species with their probabilities.

Returns a map of alternative species (excluding the top prediction) with their probability scores, sorted by probability.

Implementation

Map<String, double> get alternativeSpecies {
  final alternatives = Map<String, double>.from(probabilities);
  alternatives.remove(scientificName);

  final sorted = alternatives.entries.toList()
    ..sort((a, b) => b.value.compareTo(a.value));

  return Map.fromEntries(sorted);
}