text_html_output_1.png
import numpy as np

import pandas as pd

df = pd.read_csv('../input/train.csv')

df_ = df.drop(['id', 'vendor_id', 'store_and_fwd_flag'], axis=1)

time = df_.set_index('trip_duration')
cols = ['passenger_count', 'Turno', 'Dia', 'Mês', 'Dia_Semana']

df_.drop(['dropoff_datetime', 'pickup_datetime', 'Hora', 'Data'], axis=1, inplace=True)

def distancia(pickup_lat, pickup_lon, dropoff_lat, dropoff_lon):
    R_terra = 6371
    inicio_lat, inicio_lon, fim_lat, fim_lon = map(np.radians, [pickup_lat, pickup_lon, dropoff_lat, dropoff_lon])
    dlat = fim_lat - inicio_lat
    dlon = fim_lon - inicio_lon
    d = np.sin(dlat / 2.0) ** 2 + np.cos(inicio_lat) * np.cos(fim_lat) * np.sin(dlon / 2.0) ** 2
    return 2 * R_terra * np.arcsin(np.sqrt(d))

df_['Duração'] = df_['trip_duration']
df_.drop(['trip_duration'], axis=1, inplace=True)

X = df_.values[:, :-1]
y = np.log(df_.values[:, -1] + 1)

y.min()

y[0:5]