Kaggle competition: New York City Taxi Trip Duration
!pip install -q torch==1.6.0
!pip install -q torchvision==0.7.0
!pip install -q albumentations==0.5.1<set_options>
train= pd.read_csv('.. /input/train.csv', index_col=0)
 test=pd.read_csv('.. /input/test.csv', index_col=0)
 print("Total number of samples in train file : ", train.shape[0])
 print("Total number of samples in test file : ", test.shape[0] )
InteractiveShell.ast_node_interactivity = "all"<define_variables>
train = train[(train.trip_duration < 5000)]
class config:
seed = 1992
num_classes = 5
batch_size = 32
image_size = 512
image_col_name = 'image_id'
class_col_name = 'label'
weights_dir = '.. /input/cassavahongnan/'
hn_test_path = '.. /input/cassava-test-images'
effnet = 'tf_efficientnet_b5_ns'
effnet_paths = ['.. /input/cassavaroots/baseline_cld_fold0_epoch8_tf_efficientnet_b4_ns_512.pth',
'.. /input/cassavaroots/baseline_cld_fold1_epoch9_tf_efficientnet_b4_ns_512.pth',
'.. /input/cassavaroots/baseline_cld_fold2_epoch9_tf_efficientnet_b4_ns_512.pth',
'.. /input/cassavaroots/baseline_cld_fold3_epoch5_tf_efficientnet_b4_ns_512.pth',
'.. /input/cassavaroots/baseline_cld_fold4_epoch11_tf_efficientnet_b4_ns_512.pth']
resnext = 'resnext50_32x4d'
resnext_paths = ['.. /input/cassavaroots/resnext50_32x4d_fold0.pth',
'.. /input/cassavaroots/resnext50_32x4d_fold1.pth',
'.. /input/cassavaroots/resnext50_32x4d_fold2.pth',
'.. /input/cassavaroots/resnext50_32x4d_fold3.pth',
'.. /input/cassavaroots/resnext50_32x4d_fold4.pth']
vit = 'ViT-B_16'
vit_image_size = 384
vit_paths = ['.. /input/cassavadocumentedweights/vit_base_16.pt']
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
 paths = {'sample_path': '.. /input/cassava-leaf-disease-classification/sample_submission.csv',
'test_path': '.. /input/cassava-leaf-disease-classification/test_images',
'model_weight_path_folder': '.. /input/efficientnet-weights'}<drop_column>
train = train.loc[(train['pickup_longitude'] > -75)&(train['pickup_longitude'] < -73)]
train = train.loc[(train['pickup_latitude'] > 40)&(train['pickup_latitude'] < 41)]
config = config<set_options>
train = train.loc[(train['dropoff_longitude'] > -75)&(train['dropoff_longitude'] < -73)]
train = train.loc[(train['dropoff_latitude'] > 40.5)&(train['dropoff_latitude'] < 41.5)]
def seed_all(seed: int):
if not seed:
seed = 10
print("[ Using Seed : ", seed, " ]")
 os.environ['PYTHONHASHSEED'] = str(seed)
 torch.manual_seed(seed)
 torch.cuda.manual_seed_all(seed)
 torch.cuda.manual_seed(seed)
 np.random.seed(seed)
 random.seed(seed)
 torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
torch.backends.cudnn.enabled = False
def seed_worker(worker_id):
worker_seed = torch.initial_seed() % 2**32
np.random.seed(worker_seed)
 random.seed(worker_seed )<define_variables>
train = train.loc[(train['passenger_count'] >= 0)&(train['passenger_count'] <= 6)]
seed_all(seed=config.seed )<define_variables>
train.isnull().sum()
sys.path.append('.. /input/pytorch-image-models/pytorch-image-models-master')
 image_size = 512
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
 OUTPUT_DIR = './'
MODEL_DIR = '.. /input/cassavaroots/'
if not os.path.exists(OUTPUT_DIR):
os.makedirs(OUTPUT_DIR)
 TRAIN_PATH = '.. /input/cassava-leaf-disease-classification/train_images'
TEST_PATH = '.. /input/cassava-leaf-disease-classification/test_images'
class CFG:
debug=False
num_workers=4
model_name='resnext50_32x4d'
size=512
batch_size=32
seed=1992
num_classes=5
target_col='label'
resnext = 'resnext50_32x4d'
n_fold=5
trn_fold=[0, 1, 2, 3, 4]
inference=True
test = pd.read_csv('.. /input/cassava-leaf-disease-classification/sample_submission.csv')
 test['filepath'] = test.image_id.apply(lambda x: os.path.join('.. /input/cassava-leaf-disease-classification/test_images', f'{x}'))
class TestDataset(Dataset):
def __init__(self, df, transform=None):
self.df = df
self.file_names = df['image_id'].values
self.transform = transform
def __len__(self):
return len(self.df)
 def __getitem__(self, idx):
file_name = self.file_names[idx]
file_path = f'{TEST_PATH}/{file_name}'
image = cv2.imread(file_path)
 image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
 if self.transform:
augmented = self.transform(image=image)
 image = augmented['image']
return image
def get_transforms(*, data):
if data == 'valid':
return A.Compose([
A.Resize(CFG.size, CFG.size),
A.Normalize(
 mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225], 
),
ToTensorV2() ,
])
 class CustomResNext(nn.Module):
def __init__(self, config, pretrained=False):
super().__init__()
self.model = timm.create_model(model_name=config.resnext, pretrained=pretrained)
 n_features = self.model.fc.in_features
self.model.fc = nn.Linear(n_features, config.num_classes)
 def forward(self, input_neurons):
output_predictions = self.model(input_neurons)
 return output_predictions
def load_state(model_path):
model = CustomResNext(CFG, pretrained=False)
 try:
model.load_state_dict(torch.load(model_path)['model'], strict=True)
 state_dict = torch.load(model_path)['model']
except:
state_dict = torch.load(model_path)['model']
state_dict = {k[7:] if k.startswith('module.')else k: state_dict[k] for k in state_dict.keys() }
return state_dict
def inference(model, states, test_loader, device):
model.to(device)
 tk0 = tqdm(enumerate(test_loader), total=len(test_loader))
probs = []
for i,(images)in tk0:
images = images.to(device)
 avg_preds = []
for state in states:
model.load_state_dict(state)
 model.eval()
with torch.no_grad() :
y_preds = model(images)
 print(y_preds)
 avg_preds.append(y_preds.softmax(1 ).to('cpu' ).numpy())
 avg_preds = np.mean(avg_preds, axis=0)
 probs.append(avg_preds)
 probs = np.concatenate(probs)
 return probs
model = CustomResNext(CFG, pretrained=False)
 states = [load_state(MODEL_DIR+f'{CFG.model_name}_fold{fold}.pth')for fold in CFG.trn_fold]
test_dataset = TestDataset(test, transform=get_transforms(data='valid'))
test_loader = DataLoader(test_dataset, batch_size=CFG.batch_size, shuffle=False,
num_workers=CFG.num_workers, pin_memory=True)
 predictions = inference(model, states, test_loader, device)
 predictions<categorify>
train.isnull().sum()
class Cassava(torch.utils.data.Dataset):
def __init__(self,
df: pd.DataFrame,
config: type,
transforms: type = None,
test: bool = False,
transform_norm: bool = False, meta_features=None):
self.df = df
self.config = config
self.transforms = transforms
self.test = test
self.transform_norm = transform_norm
self.meta_features = meta_features
if self.transforms is None:
assert self.transform_norm is False
print('Transforms is None and Transform Normalization is not '
'initialized!')
 self.image_extension = get_file_type(
 image_folder_path=config.paths['test_path'], allowed_extensions=None)
 self.df_has_ext = check_df_ext(df=self.df, col_name=config.image_col_name)
 if self.df_has_ext is True:
self.image_extension = ""
def __len__(self):

 return len(self.df)
 def __getitem__(self, idx: int):

 image_id = self.df[self.config.image_col_name].values[idx]
label = None
label = torch.zeros(1)
 if self.test:
image_path = os.path.join(
 self.config.paths['test_path'], "{}{}".format(image_id,
self.image_extension))
else:
label = self.df[self.config.class_col_name].values[idx]
label = torch.as_tensor(data=label, dtype=torch.int64, device=None)
 image_path = os.path.join(
 self.config.paths['train_path'], "{}{}".format(image_id,
self.image_extension))
image = cv2.imread(image_path)
 image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
 if self.transform_norm is False:
image = image.astype(np.float32)/ 255.0
if self.transforms is not None:
image = self.transforms.augment(image)
 else:
image = torch.as_tensor(data=image,
dtype=torch.float32,
device=None)
 if self.meta_features is not None:
meta = np.array(self.df.iloc[idx][self.meta_features].values, dtype=np.float32)
 return image_id,(image, meta), label
return image_id, image, label<normalization>
train.duplicated().sum()
class Augmentation(ABC):
@abstractmethod
def augment(image):

 class AlbumentationsAugmentation(Augmentation):
def __init__(self, transforms: albumentations.core.composition.Compose):
self.transforms = transforms
def augment(self, image):
albu_dict = {"image": image}
transform = self.transforms(**albu_dict)
 return transform["image"]
def get_albu_transforms(config):
transforms_test = albumentations.Compose(
 [
albumentations.Resize(height=config.image_size, width=config.image_size, p=1.0),
albumentations.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], max_pixel_value=255.0, p=1.0),
ToTensorV2(p=1.0),
],
p=1.0, 
)
 transforms_tta = albumentations.Compose(
 [
albumentations.RandomResizedCrop(height=config.image_size, width=config.image_size, p=1.0),
albumentations.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], max_pixel_value=255.0, p=1.0),
ToTensorV2(p=1.0),
],
p=1.0, 
)
 return transforms_test, transforms_tta
def get_albu_transforms_vit(config):
transforms_test = albumentations.Compose(
 [
albumentations.RandomResizedCrop(height=config.vit_image_size, width=config.vit_image_size, p=1.0),
albumentations.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], max_pixel_value=255.0, p=1.0),
ToTensorV2(p=1.0),
],
p=1.0, 
)
 transforms_tta = albumentations.Compose(
 [
albumentations.RandomResizedCrop(height=config.vit_image_size, width=config.vit_image_size, p=1.0),
albumentations.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225], max_pixel_value=255.0, p=1.0),
ToTensorV2(p=1.0),
],
p=1.0, 
)
 return transforms_test, transforms_tta<choose_model_class>
train = train.drop_duplicates()
train.duplicated().sum()
class CustomEfficientNet(nn.Module):
def __init__(self, config: type, pretrained: bool=True):
super().__init__()
self.config = config
self.model = geffnet.create_model(
 model_weight_path_folder=config.paths['model_weight_path_folder'],
model_name=config.effnet,
pretrained=pretrained)
 n_features = self.model.classifier.in_features
self.model.classifier = nn.Linear(n_features, config.num_classes)
 def forward(self, input_neurons):
output_predictions = self.model(input_neurons)
 return output_predictions
class CustomResNext(nn.Module):
def __init__(self, config, pretrained=False):
super().__init__()
self.model = timm.create_model(model_name=config.resnext, pretrained=pretrained)
 n_features = self.model.fc.in_features
self.model.fc = nn.Linear(n_features, config.num_classes)
 def forward(self, input_neurons):
output_predictions = self.model(input_neurons)
 return output_predictions
class enet_v2(nn.Module):
def __init__(self, backbone, out_dim, pretrained=False):
super(enet_v2, self ).__init__()
self.enet = timm.create_model(backbone, pretrained=pretrained)
 in_ch = self.enet.classifier.in_features
self.myfc = nn.Linear(in_ch, out_dim)
 self.enet.classifier = nn.Identity()
def forward(self, x):
x = self.enet(x)
 x = self.myfc(x)
 return x
vit_model = VisionTransformer.from_name('ViT-B_16', num_classes=config.num_classes )<load_from_csv>
train.drop(["store_and_fwd_flag"], axis=1, inplace=True)
 test.drop(["store_and_fwd_flag"], axis=1, inplace=True )
sample = pd.read_csv('.. /input/cassava-leaf-disease-classification/sample_submission.csv' )<find_best_model_class>
plg, plt = 'pickup_longitude', 'pickup_latitude'
dlg, dlt = 'dropoff_longitude', 'dropoff_latitude'
pdt, ddt = 'pickup_datetime', 'dropoff_datetime'
def inference_by_fold(config, model, states_dicts, test_loader,tta_test_loader=None,use_tta=False):
model.to(config.device)
 model.eval()
with torch.no_grad() :
all_folds_preds = []
all_folds_tta_preds = []
for fold_num, state in enumerate(states_dicts):
if 'model_state_dict' in state:
model.load_state_dict(state['model_state_dict'])
 elif 'model' in state:
state = state['model']
state = {k[7:] if k.startswith('module.')else k: state[k] for k in state.keys() }
model.load_state_dict(state)
 else:
model.load_state_dict(state)
 current_fold_preds = []
current_fold_tta_preds = []
for data_test in tqdm(test_loader):
_, images, _ = data_test
images = images.to(config.device ).float()
logits = model(images)
 softmax_preds = torch.nn.Softmax(dim=1 )(input=logits ).to('cpu' ).numpy()
current_fold_preds.append(softmax_preds)
 current_fold_preds = np.concatenate(current_fold_preds, axis = 0)
 all_folds_preds.append(current_fold_preds)
 if use_tta:
for data_test_tta in tqdm(tta_test_loader):
_, tta_images, _ = data_test_tta
tta_images = tta_images.to(config.device ).float()
tta_logits = model(tta_images)
 tta_softmax_preds = torch.nn.Softmax(dim=1 )(input=tta_logits ).to('cpu' ).numpy()
combined_preds = np.mean([softmax_preds, tta_softmax_preds], axis=0)
 current_fold_tta_preds.append(combined_preds)
 current_fold_tta_preds = np.concatenate(current_fold_tta_preds, axis=0)
 all_folds_tta_preds.append(current_fold_tta_preds)
 avg_preds = np.mean(all_folds_preds, axis=0)if not use_tta else np.mean(all_folds_tta_preds, axis=0)
 return avg_preds<define_variables>
def haversine(lon1, lat1, lon2, lat2):

 lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
 dlon = lon2 - lon1
dlat = lat2 - lat1
a = sin(dlat/2)**2 + cos(lat1)* cos(lat2)* sin(dlon/2)**2
c = 2 * asin(sqrt(a))
km = 6371* c
return km
def euclidian_distance(x):
x1, y1 = np.float64(x[plg]), np.float64(x[plt])
 x2, y2 = np.float64(x[dlg]), np.float64(x[dlt])
 return haversine(x1, y1, x2, y2 )
pred_resnext = submission(config, base_model_name=config.resnext)
 pred_resnext 
<save_to_csv>
%time
train['distance'] = train[[plg, plt, dlg, dlt]].apply(euclidian_distance, axis=1 )
sample[config.class_col_name] = predictions_ensemble.argmax(1)
 sample[[config.image_col_name, config.class_col_name]].to_csv('submission.csv', index=False)
 display(sample.head() )<define_variables>
%time
test['distance'] = test[[plg, plt, dlg, dlt]].apply(euclidian_distance, axis=1 )
all_preds_list = \
[np.array([[0.01, 0.02, 0.03, 0.9 , 0.04],
[0.02, 0.8 , 0.05, 0.06, 0.07],
[0.01, 0.8 , 0.03, 0.09, 0.07]]),
np.array([[0.03, 0.05 , 0.01 , 0.88 , 0.03],
[0.01 , 0.82 , 0.02 , 0.07 , 0.08],
[0.005 , 0.81 , 0.0205, 0.0555, 0.109]]),
np.array([[0.05, 0.03, 0.08, 0.83, 0.01],
[0.05, 0.89, 0.01, 0.02, 0.03],
[0.03, 0.78, 0.05, 0.02, 0.12]]),
np.array([[0.02, 0.01, 0.03, 0.92, 0.02],
[0.05, 0.85, 0.01, 0.01, 0.08],
[0.02, 0.88, 0.03, 0.05, 0.02]]),
np.array([[0.01, 0.02, 0.02, 0.93, 0.02],
[0.03, 0.76, 0.06, 0.06, 0.09],
[0.02, 0.83, 0.01, 0.07, 0.07]])]
np.mean(all_preds_list, axis=None)
 np.mean(all_preds_list, axis=0)
 np.mean(all_preds_list, axis=1 )<define_variables>
train[pdt] = train[pdt].apply(lambda x : datetime.strptime(x, "%Y-%m-%d %H:%M:%S"))
train[ddt] = train[ddt].apply(lambda x : datetime.strptime(x, "%Y-%m-%d %H:%M:%S"))
fold_1_pred_1 = np.array([[0.01, 0.02, 0.03, 0.9, 0.04], [0.02, 0.8, 0.05, 0.06, 0.07]])
 fold_1_pred_2 = np.array([[0.01, 0.8, 0.03, 0.09, 0.07]])
 fold_2_pred_1 = np.array([[0.03, 0.05, 0.01, 0.88, 0.03], [0.01, 0.82, 0.02, 0.07, 0.08]])
 fold_2_pred_2 = np.array([[0.005, 0.81, 0.0205, 0.0555, 0.109]])
 fold_3_pred_1 = np.array([[0.05, 0.03, 0.08, 0.83, 0.01], [0.05, 0.89, 0.01, 0.02, 0.03]])
 fold_3_pred_2 = np.array([[0.03, 0.78, 0.05, 0.02, 0.12]])
 fold_4_pred_1 = np.array([[0.02, 0.01, 0.03, 0.92, 0.02], [0.05, 0.85, 0.01, 0.01, 0.08]])
 fold_4_pred_2 = np.array([[0.02, 0.88, 0.03, 0.05, 0.02]])
 fold_5_pred_1 = np.array([[0.01, 0.02, 0.02, 0.93, 0.02], [0.03, 0.76, 0.06, 0.06, 0.09]])
 fold_5_pred_2 = np.array([[0.02, 0.83, 0.01, 0.07, 0.07]] )<define_variables>
test[pdt] = test[pdt].apply(lambda x : datetime.strptime(x, "%Y-%m-%d %H:%M:%S"))
all_folds_preds = []
fold_1_preds = []
fold_1_preds = [fold_1_pred_1, fold_1_pred_2]
fold_1_preds before np.concatenate
',fold_1_preds)
 fold_1_preds = np.concatenate(fold_1_preds, axis=0)
 fold_1_preds_ = np.concatenate([fold_1_pred_1, fold_1_pred_2], axis=0)
 ',fold_1_preds)
 ',fold_1_preds_)
 all_folds_preds.append(fold_1_preds)
 print('All Folds Pred list after Fold 1 is
{}
'.format(all_folds_preds))
fold_2_preds = []
fold_2_preds = [fold_2_pred_1, fold_2_pred_2]
fold_2_preds = np.concatenate(fold_2_preds, axis=0)
 all_folds_preds.append(fold_2_preds)
 print('All Folds Pred list after Fold 1+2 is
{}
'.format(all_folds_preds))
fold_3_preds = []
fold_3_preds = [fold_3_pred_1, fold_3_pred_2]
fold_3_preds = np.concatenate(fold_3_preds, axis=0)
 all_folds_preds.append(fold_3_preds)
 print('All Folds Pred list after fold 1+2+3 is
{}
'.format(all_folds_preds))
fold_4_preds = []
fold_4_preds = [fold_4_pred_1, fold_4_pred_2]
fold_4_preds = np.concatenate(fold_4_preds, axis=0)
 all_folds_preds.append(fold_4_preds)
 print('All Folds Pred list after fold 1+2+3+4 is
{}
'.format(all_folds_preds))
fold_5_preds = []
fold_5_preds = [fold_5_pred_1, fold_5_pred_2]
fold_5_preds
fold_5_preds = np.concatenate(fold_5_preds, axis=0)
 fold_5_preds
all_folds_preds.append(fold_5_preds)
 print('All Folds Pred list after fold 1+2+3+4+5 is
{}
'.format(all_folds_preds))
avg_pred_without_concat = np.mean(all_folds_preds, axis=0)
 print('Average predictions is
{}'.format(avg_pred_without_concat)) 
<load_pretrained>
train['month'] = train[pdt].apply(lambda x : x.month)
 train['week_day'] = train[pdt].apply(lambda x : x.weekday())
 train['day_month'] = train[pdt].apply(lambda x : x.day)
 train['pickup_time_minutes'] = train[pdt].apply(lambda x : x.hour * 60.0 + x.minute )
def inference_by_fold(model, states_dicts, test_loader, device):
model.to(device)
 model.eval()
with torch.no_grad() :
all_folds_preds = []
for fold_num, state in enumerate(states_dicts):
if 'model_state_dict' not in state:
model.load_state_dict(state)
 else:
model.load_state_dict(state['model_state_dict'])
 current_fold_preds = []
for data in tqdm(test_loader, position=0, leave=True):
img_ids, images, labels = data
images = images.to(device)
 logits = model(images)
 softmax_preds = torch.nn.Softmax(dim=1 )(input=logits ).to('cpu' ).numpy()
current_fold_preds.append(softmax_preds)
 current_fold_preds = np.concatenate(current_fold_preds, axis = 0)
 all_folds_preds.append(current_fold_preds)
 avg_preds = np.mean(all_folds_preds, axis=0)
 return avg_preds<load_from_csv>
test['month'] = test[pdt].apply(lambda x : x.month)
 test['week_day'] = test[pdt].apply(lambda x : x.weekday())
 test['day_month'] = test[pdt].apply(lambda x : x.day)
 test['pickup_time_minutes'] = test[pdt].apply(lambda x : x.hour * 60.0 + x.minute )
<define_search_model>
features_train = ["vendor_id", "passenger_count", "pickup_longitude", "pickup_latitude", "dropoff_longitude", "dropoff_latitude", "distance", "month", "week_day", "day_month", "pickup_time_minutes"]
X_train = train[features_train]
y_train = np.log1p(train["trip_duration"])
 features_test = ["vendor_id", "passenger_count", "pickup_longitude", "pickup_latitude", "dropoff_longitude", "dropoff_latitude", "distance", "month", "week_day", "day_month", "pickup_time_minutes"]
X_test = test[features_test]
class TheModelClass(nn.Module):
def __init__(self):
super(TheModelClass, self ).__init__()
self.conv1 = nn.Conv2d(in_channels=3, out_channels =6, kernel_size =5)
 self.pool = nn.MaxPool2d(2, 2)
 self.conv2 = nn.Conv2d(6, 16, 5)
 self.fc1 = nn.Linear(16 * 5 * 5, 120)
 self.fc2 = nn.Linear(120, 84)
 self.fc3 = nn.Linear(84, 10)
 def forward(self, x):
x = self.pool(F.relu(self.conv1(x)))
 x = self.pool(F.relu(self.conv2(x)))
 x = x.view(-1, 16 * 5 * 5)
 x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
x = self.fc3(x)
 return x
model = TheModelClass()
optimizer = torch.optim.SGD(model.parameters() , lr=0.001, momentum=0.9)
 print("Model's state_dict:")
 for param_tensor in model.state_dict() :
print(param_tensor, "\t", model.state_dict() [param_tensor].size())
 print("Optimizer's state_dict:")
 for var_name in optimizer.state_dict() :
print(var_name, "\t", optimizer.state_dict() [var_name])
<define_search_space>
from xgboost.sklearn import XGBRegressor
import scipy.stats as st
from sklearn.metrics import accuracy_score
def count_parameters(model):
table = PrettyTable(["Modules", "Parameters"])
 total_params = 0
for name, parameter in model.named_parameters() :
if not parameter.requires_grad: continue
param = parameter.numel()
table.add_row([name, param])
 total_params+=param
print(table)
 print(f"Total Trainable Params: {total_params}")
 return total_params
count_parameters(model)
<init_hyperparams>
reg=XGBRegressor(learning_rate=0.1, n_estimators=100, max_depth=50, n_jobs=1 )
<load_pretrained>
reg.fit(X_train, y_train )
<set_options>
log_pred = reg.predict(X_test)
 y_pred = np.exp(log_pred)- np.ones(len(log_pred))
%matplotlib inline
warnings.filterwarnings("ignore" )<categorify>
my_submission = pd.DataFrame({'id': test.index, 'trip_duration': y_pred})
 my_submission.head()
<feature_engineering><EOS> 
my_submission.to_csv("submission.csv", index=False )