featuretools.primitives.CityblockDistance#
- class featuretools.primitives.CityblockDistance(unit='miles')[源]#
计算城市道路网格中点之间的距离。
- 描述
此距离使用 Haversine 公式计算,该公式考虑了地球的曲率。如果任何输入数据包含 NaN,则计算出的距离将为 NaN。此计算也称为曼哈顿距离(Mahnattan distance)。
- 参数:
unit (str) – 确定输出的单位值。可以是 miles(英里)或 kilometers(千米)。默认为 miles。
示例
>>> cityblock_distance = CityblockDistance() >>> DC = (38, -77) >>> Boston = (43, -71) >>> NYC = (40, -74) >>> distances_mi = cityblock_distance([DC, DC], [NYC, Boston]) >>> np.round(distances_mi, 3).tolist() [301.519, 672.089]
我们还可以更改计算距离时使用的单位。
>>> cityblock_distance_kilometers = CityblockDistance(unit='kilometers') >>> distances_km = cityblock_distance_kilometers([DC, DC], [NYC, Boston]) >>> np.round(distances_km, 3).tolist() [485.248, 1081.622]
方法
__init__
([unit])flatten_nested_input_types
(input_types)将嵌套的列 schema 输入展平为单个列表。
generate_name
(base_feature_names)generate_names
(base_feature_names)get_args_string
()get_arguments
()get_description
(input_column_descriptions[, ...])get_filepath
(filename)get_function
()属性
base_of
base_of_exclude
commutative
default_value
如果未找到数据,此特征返回的默认值。
description_template
input_types
输入的 woodwork.ColumnSchema 类型
max_stack_depth
name
基本原语的名称
number_output_features
与此特征关联的特征矩阵中的列数
return_type
返回的 ColumnSchema 类型
stack_on
stack_on_exclude
stack_on_self
uses_calc_time
uses_full_dataframe