コード例 #1
0
 def transform(self, X, y=None):
     nyc_center = (40.7141667, -74.0063889)
     X["nyc_lat"], X["nyc_lng"] = nyc_center[0], nyc_center[1]
     args_pickup = dict(start_lat="nyc_lat", start_lon="nyc_lng",
                        end_lat="pickup_latitude", end_lon="pickup_longitude")
     args_dropoff = dict(start_lat="nyc_lat", start_lon="nyc_lng",
                         end_lat="dropoff_latitude", end_lon="dropoff_longitude")
     X['pickup_distance_to_center'] = haversine_vectorized(X, **args_pickup)
     X['dropoff_distance_to_center'] = haversine_vectorized(X, **args_dropoff)
     return X[["pickup_distance_to_center", "dropoff_distance_to_center"]]
コード例 #2
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     return pd.DataFrame(haversine_vectorized(X, 
          start_lat=self.start_lat,
          start_lon=self.start_lon,
          end_lat=self.end_lat,
          end_lon=self.end_lon))
コード例 #3
0
 def transform(self, X, y=None):
     assert isinstance(X, pd.DataFrame)
     if self.distance_type == "haversine":
         X["distance"] = haversine_vectorized(X, **dist_args)
     if self.distance_type == "euclidian":
         X["distance"] = minkowski_distance()
     return X[["distance"]]
コード例 #4
0
    def transform(self, X, y=None):
        """Returns a copy of the DataFrame X with only one column: 'distance'"""
        X['distance'] = haversine_vectorized(X,
                                             start_lat="pickup_latitude",
                                             start_lon="pickup_longitude",
                                             end_lat="dropoff_latitude",
                                             end_lon="dropoff_longitude")

        return X[['distance']]
コード例 #5
0
ファイル: encoders.py プロジェクト: Phlasse/TaxiFareModel
 def transform(self, X, y=None):
     assert isinstance(X, pd.DataFrame)
     if self.distance_type == "haversine":
         X["distance"] = haversine_vectorized(X, **DIST_ARGS)
     if self.distance_type == "euclidian":
         X["distance"] = minkowski_distance(X, p=2, **DIST_ARGS)
     if self.distance_type == "manhattan":
         X["distance"] = minkowski_distance(X, p=1, **DIST_ARGS)
     return X[["distance"]]
コード例 #6
0
ファイル: encoders.py プロジェクト: MartinJ9678/TaxiFareModel
 def transform(self, X, y=None):
     assert isinstance(X, pd.DataFrame)
     X_ = X.copy()
     X_["distance"] = haversine_vectorized(X_,
                                           start_lat=self.start_lat,
                                           start_lon=self.start_lon,
                                           end_lat=self.end_lat,
                                           end_lon=self.end_lon)
     return X_[['distance']]
コード例 #7
0
    def transform(self, X, y=None):
        jfk_center = (40.6441666667, -73.7822222222)
        X["jfk_lat"], X["jfk_lng"] = jfk_center[0], jfk_center[1]
        args_pickup = dict(start_lat="jfk_lat",
                           start_lon="jfk_lng",
                           end_lat="pickup_latitude",
                           end_lon="pickup_longitude")
        args_dropoff = dict(start_lat="jfk_lat",
                            start_lon="jfk_lng",
                            end_lat="dropoff_latitude",
                            end_lon="dropoff_longitude")
        X['pickup_distance_to_jfk'] = haversine_vectorized(X, **args_pickup)
        X['dropoff_distance_to_jfk'] = haversine_vectorized(X, **args_dropoff)

        X['from_to_airport'] = (np.logical_or(X['pickup_distance_to_jfk']<2,\
            X['dropoff_distance_to_jfk']<2))*1

        #return X[["pickup_distance_to_center", "dropoff_distance_to_center",'from_to_airport']]
        return X[['from_to_airport']]
コード例 #8
0
ファイル: encoders.py プロジェクト: HarryLawes/taxi_fare
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance_to_center'"""
     nyc_center = (40.7141667, -74.0063889)
     X["nyc_latitude"], X["nyc_longitude"] = nyc_center[0], nyc_center[1]
     args = dict(start_lat="nyc_latitude",
                 start_lon="nyc_longitude",
                 end_lat="pickup_latitude",
                 end_lon="pickup_longitude")
     X['distance_to_center'] = haversine_vectorized(X, **args)
     return X[['distance_to_center']]
コード例 #9
0
ファイル: encoders.py プロジェクト: timcrowe91/TaxiFareModel
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     assert isinstance(X, pd.DataFrame)
     X_temp = X.copy()
     X_temp['distance'] = haversine_vectorized(X_temp,
                                               start_lat=self.start_lat,
                                               start_lon=self.start_lon,
                                               end_lat=self.end_lat,
                                               end_lon=self.end_lon)
     return X_temp[['distance']]
コード例 #10
0
ファイル: encoders.py プロジェクト: Zekumi/TaxiFareModel
    def transform(self, X, y=None):
        """Returns a copy of the DataFrame X with only one column: 'distance'"""
        X['distance'] = haversine_vectorized(X,
                                             start_lat=self.start_lat,
                                             start_lon=self.start_lon,
                                             end_lat=self.end_lat,
                                             end_lon=self.end_lon)

        X = X.reset_index(drop=True)
        return X[['distance']]
コード例 #11
0
ファイル: encoders.py プロジェクト: timcrowe91/TaxiFareModel
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     assert isinstance(X, pd.DataFrame)
     X_temp = X.copy()
     X_temp['nyc_lat'] = 40.7141667
     X_temp['nyc_lon'] = -74.0063889
     X_temp['distance_to_center'] = haversine_vectorized(
         X_temp,
         start_lat=self.nyc_lat,
         start_lon=self.nyc_lon,
         end_lat=self.end_lat,
         end_lon=self.end_lon)
     return X_temp[['distance_to_center']]
コード例 #12
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     return pd.DataFrame(haversine_vectorized (X.copy(),self.start_lat,self.start_lon,self.end_lat,self.end_lon))\
                         .rename(columns={0:"distance"})
コード例 #13
0
ファイル: encoders.py プロジェクト: LeoThr/TaxiFare
 def transform(self, X, y=None):
     a = haversine_vectorized(X)
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     return pd.DataFrame(a)
コード例 #14
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only 1 column: 'distance'"""
     df = pd.DataFrame(haversine_vectorized(X.copy()))
     df.columns = ['distance']
     return df
コード例 #15
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     assert isinstance(X,pd.DataFrame)
     X_ = X.copy() 
     X_['distance'] = haversine_vectorized(X_)
     return X_[['distance']]
コード例 #16
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     return pd.DataFrame(haversine_vectorized(X.copy()),columns=['distance']) \
                         .sort_index()
コード例 #17
0
ファイル: encoders.py プロジェクト: GhislainVig/TaxiFareModel
 def transform(self, X, y=None):
     return pd.DataFrame(haversine_vectorized(X))
コード例 #18
0
def test_haversine():
    df = get_data(nrows=1)
    assert round(haversine_vectorized(df)[0], 2) == 1.03, "Distance not right"
コード例 #19
0
ファイル: encoders.py プロジェクト: acedb/TaxiFareModel
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     X_ = X.copy()
     X_["distance"] = haversine_vectorized(X_)
     distance = pd.DataFrame(X_["distance"])
     return distance
コード例 #20
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     X = X.copy()
     X['distance'] = haversine_vectorized(X)
     return X[['distance']]
コード例 #21
0
 def transform(self, X, y=None):
     """Returns a copy of the DataFrame X with only one column: 'distance'"""
     a = pd.DataFrame()
     a['distance'] = haversine_vectorized(X)
     return a