class_docstr: Plots training parameters (loss, f-score, and accuracy) and training weights over time.
  
  Input files are the output files 'loss.tsv' and 'weights.txt' from
  training either a sequence tagger or text classification model.
class_docstr_tok: ["Plots","training","parameters","(","loss",",","f-score",",","and","accuracy",")","and","training","weights","over","time",".","Input","files","are","the","output","files","'loss.tsv","'","and","'weights.txt","'","from","training","either","a","sequence","tagger","or","text","classification","model","."]
code: def _extract_evaluation_data(
      file_name: Union[str, Path], score: str = "F1"
  ) -> dict:
      file_name = Path(file_name)
  
      training_curves: Dict[str, Dict[str, List[float]]] = {
          "train": {"loss": [], "score": []},
          "test": {"loss": [], "score": []},
          "dev": {"loss": [], "score": []},
      }
  
      with open(file_name) as f:
          tsvin = csv.reader(f, delimiter="\t")
  
          # determine the column index of loss, f-score and accuracy for
          # train, dev and test split
          row = next(tsvin)
  
          score = score.upper()
  
          if f"TEST_{score}" not in row:
              log.warning("-" * 100)
              log.warning(
                  f"WARNING: No {score} found for test split in this data."
              )
              log.warning(
                  f"Are you sure you want to plot {score} and not another value?"
              )
              log.warning("-" * 100)
  
          TRAIN_SCORE = (
              row.index(f"TRAIN_{score}")
              if f"TRAIN_{score}" in row
              else None
          )
          DEV_SCORE = (
              row.index(f"DEV_{score}")
              if f"DEV_{score}" in row
              else None
          )
          TEST_SCORE = (
              row.index(f"TEST_{score}")
              if f"TEST_{score}" in row
              else None
          )
  
          # then get all relevant values from the tsv
          for row in tsvin:
              if TRAIN_SCORE is not None and row[TRAIN_SCORE] != "_":
                  training_curves["train"]["score"].append(
                      float(row[TRAIN_SCORE])
                  )
  
              if DEV_SCORE is not None and row[DEV_SCORE] != "_":
                  training_curves["dev"]["score"].append(
                      float(row[DEV_SCORE])
                  )
  
              if TEST_SCORE is not None and row[TEST_SCORE] != "_":
                  training_curves["test"]["score"].append(
                      float(row[TEST_SCORE])
                  )
  
      return training_curves
  
file_path: flair/flair/visual/training_curves.py
imports: import csv
  import logging
  import math
  from collections import defaultdict
  from pathlib import Path
  from typing import Dict, List, Union
  import matplotlib.pyplot
  import numpy
label_desc: Use image node_id 1 for calling the Plotter obj's underlying member method code with example usage: obj._extract_evaluation_data(file_name, score) and returns: training_curves