Kaggle competition: Kobe Bryant Shot Selection
facedet = BlazeFace().to(gpu)
 facedet.load_weights("/kaggle/input/blazeface-pytorch/blazeface.pth")
 facedet.load_anchors("/kaggle/input/blazeface-pytorch/anchors.npy")
 _ = facedet.train(False )<load_pretrained>
BE_data = pd.read_csv('.. /input/kobe-bryant-shot-selection/data.csv.zip')
 BE_sample = pd.read_csv('.. /input/kobe-bryant-shot-selection/sample_submission.csv.zip' )
frames_per_video = 90
video_reader = VideoReader()
video_read_fn = lambda x: video_reader.read_frames(x, num_frames=frames_per_video)
 face_extractor = FaceExtractor(video_read_fn, facedet )<define_variables>
delete_columns = ['shot_distance',
'game_date']
BE_data.drop(delete_columns, axis=1, inplace=True)
 le = LabelEncoder()
BE_data["action_type"] = le.fit_transform(BE_data["action_type"])
 BE_data["season"] = le.fit_transform(BE_data["season"])
 BE_data["combined_shot_type"] = le.fit_transform(BE_data["combined_shot_type"])
 BE_data["shot_type"] = le.fit_transform(BE_data["shot_type"])
 BE_data["shot_zone_area"] = le.fit_transform(BE_data["shot_zone_area"])
 BE_data["shot_zone_basic"] = le.fit_transform(BE_data["shot_zone_basic"])
 BE_data["shot_zone_range"] = le.fit_transform(BE_data["shot_zone_range"])
 BE_data["team_name"] = le.fit_transform(BE_data["team_name"])
 BE_data["opponent"] = le.fit_transform(BE_data["opponent"] )
input_size = 250<normalization>
BE_data["matchup"]=BE_data["matchup"].map({ "LAL @ ATL": 3111.71, "LAL @ BKN" : 3940.98, "LAL @ BOS" : 4171.64,
"LAL @ CHA" : 3406.51, "LAL @ CHH" : 3406.51, "LAL @ CHI" : 2802.76,
"LAL @ CLE" : 3293.8, "LAL @ DAL" : 1992.7, "LAL @ DEN" : 1336.99,
"LAL @ DET" : 3187.13, "LAL @ GSW" : 556.05, "LAL @ HOU" : 2209.31,
"LAL @ IND" : 2908.74, "LAL @ LAC" : 0, "LAL @ MEM" : 2577.17,
"LAL @ MIA" : 3760.32, "LAL @ MIL" : 2804.07, "LAL @ MIN" : 2450.08,
"LAL @ NJN" : 3941, "LAL @ NOH" : 2687.88, "LAL @ NOP" : 2687.88,
"LAL @ NYK" : 3938.9, "LAL @ OKC" : 1898.97, "LAL @ ORL" : 3538.33,
"LAL @ PHI" : 3845.69, "LAL @ PHX" : 576.62, "LAL @ POR" : 1331.11,
"LAL @ SAC" : 581.69, "LAL @ SAS" : 1940.71, "LAL @ SEA" : 1898.99,
"LAL @ TOR" : 3497.01, "LAL @ UTA" : 935.07, "LAL @ VAN" : 3695.84,
"LAL @ WAS" : 3695.84
})
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
normalize_transform = Normalize(mean, std )<choose_model_class>
BE_test = BE_data
BE_train = BE_data
BE_test = BE_test[BE_test["shot_made_flag"].isnull() ]
BE_train.dropna(subset=['shot_made_flag'], inplace=True)
 X_train = BE_train.drop('shot_made_flag', axis=1 )
class MyResNeXt(models.resnet.ResNet):
def __init__(self, training=True):
super(MyResNeXt, self ).__init__(block=models.resnet.Bottleneck,
layers=[3, 4, 6, 3],
groups=32,
width_per_group=4)
 self.fc = nn.Linear(2048, 1 )<load_pretrained>
y_train = BE_train['shot_made_flag']
X_test = BE_test.drop('shot_made_flag', axis=1)
 Y_train = BE_train['shot_made_flag']
checkpoint = torch.load("/kaggle/input/deepfakes-inference-demo/resnext.pth", map_location=gpu)
 model = MyResNeXt().to(gpu)
 model.load_state_dict(checkpoint)
 _ = model.eval()
del checkpoint<predict_on_test>
model = XGBClassifier(n_estimators=20, random_state=71)
 model.fit(X_train, Y_train)
 pred = model.predict_proba(X_test)[:, 1]
sub_data = pd.DataFrame({'shot_id':X_test['shot_id'], 'shot_made_flag':pred} )
<predict_on_test><EOS> 
submission = sub_data
submission.to_csv('submission_first.csv', index=False )