Esempio n. 1
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")

    ## POSSIBLE TO SHIFT AND FLIP DATA TO TRAIN ON MORE GENERAL DATA
    # data_old, _ = Tools.shift_data(data, labels, shift_labels = False, max_shift=30)
    # data_new = Tools.flip_x_data(data_old.copy()) #[:len(data_old)//2]
    # data = np.append(data_new, data_old, axis=0)
    # labels = np.append(labels, labels, axis=0)