featuretools.primitives.CityblockDistance#

class featuretools.primitives.CityblockDistance(unit='miles')[source]#

计算城市道路网格中各点之间的距离.

Description:

此距离使用半正矢公式计算,该公式考虑了地球的曲率. 如果任一输入数据包含 NaN,则计算的距离将为 NaN. 此计算也称为曼哈顿距离.

Parameters:

unit (str) – 确定输出的单位值.可以是英里或公里.默认为英里.

Examples

>>> 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='miles')[source]#

Methods

__init__([unit])

flatten_nested_input_types(input_types)

将嵌套的列模式输入展平成一个列表.

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()

Attributes

base_of

base_of_exclude

commutative

default_value

Default value this feature returns if no data found.

description_template

input_types

woodwork.ColumnSchema types of inputs

max_stack_depth

name

Name of the primitive

number_output_features

Number of columns in feature matrix associated with this feature

return_type

ColumnSchema type of return

stack_on

stack_on_exclude

stack_on_self

uses_calc_time

uses_full_dataframe