Exemplo n.º 1
0
def calculate_sparkml_scaler_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(
        operator, good_input_types=[FloatTensorType, Int64TensorType])

    input_shape = copy.deepcopy(operator.inputs[0].type.shape)
    operator.outputs[0].type = FloatTensorType(input_shape)
Exemplo n.º 2
0
def calculate_one_vs_rest_output_shapes(operator):
    check_input_and_output_numbers(operator, input_count_range=1, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType, Int64TensorType])
    if len(operator.inputs[0].type.shape) != 2:
        raise RuntimeError('Input must be a [N, C]-tensor')

    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = Int64TensorType(shape=[N])
Exemplo n.º 3
0
def calculate_sparkml_naive_bayes_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=2)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType],
                                 good_output_types=[FloatTensorType,FloatTensorType])
    N = operator.inputs[0].type.shape[0]
    C = operator.raw_operator.numClasses
    operator.outputs[0].type = FloatTensorType([N, 1])
    operator.outputs[1].type = FloatTensorType([N, C])
Exemplo n.º 4
0
def calculate_bucketizer_output_shapes(operator):
    check_input_and_output_numbers(operator,
                                   input_count_range=1,
                                   output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[FloatTensorType],
                                 good_output_types=[FloatTensorType])
    input_type = copy.deepcopy(operator.inputs[0].type)
    for output in operator.outputs:
        output.type = input_type
Exemplo n.º 5
0
def calculate_sparkml_polynomial_expansion_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(
        operator, good_input_types=[FloatTensorType, Int64TensorType])

    N = operator.inputs[0].type.shape[0]
    C = get_combinations_count(operator.inputs[0].type.shape[1],
                               operator.raw_operator.getDegree())
    operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
    operator.outputs[0].type.shape = [N, C]
Exemplo n.º 6
0
def calculate_imputer_output_shapes(operator):
    check_input_and_output_numbers(
        operator, output_count_range=[1, len(operator.outputs)])
    check_input_and_output_types(
        operator,
        good_input_types=[FloatTensorType, Int64TensorType],
        good_output_types=[FloatTensorType, Int64TensorType])
    input_type = copy.deepcopy(operator.inputs[0].type)
    for output in operator.outputs:
        output.type = input_type
Exemplo n.º 7
0
def calculate_gbt_classifier_output_shapes(operator):
    check_input_and_output_numbers(operator,
                                   input_count_range=1,
                                   output_count_range=[1, 2])
    check_input_and_output_types(
        operator, good_input_types=[FloatTensorType, Int64TensorType])
    if len(operator.inputs[0].type.shape) != 2:
        raise RuntimeError('Input must be a [N, C]-tensor')

    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = Int64TensorType(shape=[N])
    if isinstance(operator.raw_operator, GBTClassificationModel):
        class_count = 2
        operator.outputs[1].type = FloatTensorType([N, class_count])
Exemplo n.º 8
0
def calculate_decision_tree_classifier_output_shapes(operator):
    check_input_and_output_numbers(operator,
                                   input_count_range=1,
                                   output_count_range=[1, 2])
    check_input_and_output_types(
        operator, good_input_types=[FloatTensorType, Int64TensorType])
    if len(operator.inputs[0].type.shape) != 2:
        raise RuntimeError('Input must be a [N, C]-tensor')

    N = operator.inputs[0].type.shape[0]

    class_count = operator.raw_operator.numClasses
    operator.outputs[0].type = Int64TensorType(shape=[N])
    operator.outputs[1].type = FloatTensorType([N, class_count])
Exemplo n.º 9
0
def calculate_sparkml_tokenizer_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator,
                                 good_input_types=[StringTensorType])
    operator.outputs[0].type = StringTensorType()
Exemplo n.º 10
0
def calculate_sparkml_pca_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])
    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = FloatTensorType([N, operator.raw_operator.getOrDefault('k')])
Exemplo n.º 11
0
def calculate_element_wise_product_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[FloatTensorType])
    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = FloatTensorType(
        [N, operator.inputs[0].type.shape[1]])
Exemplo n.º 12
0
def calculate_decision_tree_regressor_output_shapes(operator):
    check_input_and_output_numbers(operator,
                                   input_count_range=1,
                                   output_count_range=1)
    N = operator.inputs[0].type.shape[0]
    operator.outputs[0].type = FloatTensorType(shape=[N, 1])
Exemplo n.º 13
0
def calculate_sparkml_stop_words_remover_output_shapes(operator):
    check_input_and_output_numbers(operator, output_count_range=1)
    check_input_and_output_types(operator, good_input_types=[StringTensorType])
    input_shape = copy.deepcopy(operator.inputs[0].type.shape)
    operator.outputs[0].type = StringTensorType(input_shape)