Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def calculate_sklearn_scaler_output_shapes(operator):
'''
Allowed input/output patterns are
1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n]
Similar to imputer, this operator can take multiple input feature tensors and concatenate them along C-axis.
'''
check_input_and_output_numbers(operator, input_count_range=[1, None], output_count_range=1)
check_input_and_output_types(operator, good_input_types=[FloatTensorType, Int64TensorType],
good_output_types=[FloatTensorType])
# Inputs: multiple float- and integer-tensors
# Output: one float tensor
for variable in operator.inputs:
if len(variable.type.shape) != 2:
raise RuntimeError('Only 2-D tensor(s) can be input(s)')
if len(set(variable.type.shape[0] for variable in operator.inputs)) > 1:
raise RuntimeError('Batch size must be identical across inputs')
N = operator.inputs[0].type.shape[0]
C = 0
for variable in operator.inputs:
if isinstance(variable.type.shape[1], numbers.Integral):
C += variable.type.shape[1]
else:
C = 'None'
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)
def calculate_min_hash_lsh_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]
C = 1
operator.outputs[0].type = FloatTensorType([N, C])
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')])
def calculate_chi_sq_selector_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, StringTensorType])
operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
operator.outputs[0].type.shape[1] = len(operator.raw_operator.selectedFeatures)
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
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
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])
def calculate_sparkml_dct_output_shapes(operator):
check_input_and_output_numbers(operator, output_count_range=1)
check_input_and_output_types(operator, good_input_types=[FloatTensorType])
operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
def calculate_vector_slicer_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, StringTensorType])
operator.outputs[0].type = copy.deepcopy(operator.inputs[0].type)
operator.outputs[0].type.shape[1] = len(operator.raw_operator.getIndices())