Esempio n. 1
0
        print("Number of data used for testing", len(csv.index))

    # DATA PREPARATION:
    # 1. cut to certain Pitching position?
    if len(cfg.position) > 0:
        assert cfg.position == "Windup" or cfg.position == "Stretch", "Wrong pitching position filtering in config file"
        csv = csv[csv["Pitching Position (P)"] == cfg.position]
        print("Only pitching position ", cfg.position, "included in data")

    # 2. the pitch type "eephus" is excluded because it only occurs once in the data
    if label_name == "Pitch Type":
        csv = csv[csv["Pitch Type"] != "Eephus"]

    # 3. cut to the 5 players with most data
    if cfg.five_players:
        csv = Tools.cut_csv_to_pitchers(csv)
        print("Only the five players with most data are included")

    # GET DATA
    data, labels = Tools.get_data_from_csv(csv,
                                           label_name,
                                           min_length=cfg.nr_frames)
    print("Data shape:", data.shape)
    # data = np.load("data_test.npy")
    # labels = np.load("labels_test.npy")

    # 4. Change labels to super classes (only for the pitch type!)
    if cfg.super_classes:
        labels = Tools.labels_to_classes(labels)
        print("Labels are transformed to superclasses")