sketchgraphs.pipeline.numerical_parameters

This module implements functionality to handle numerical parameters in the sketch.

Functions

sketchgraphs.pipeline.numerical_parameters.make_quantization(values, num_points, scheme)

Find optimal centers for parameter via either uniform, K-means, or CDF-based K-means.

Obtains a quantization scheme for the given values, according to a given strategy. Several schemes are supported, although we prefer the ‘cdf’ scheme, a hybrid which avoids some issues with large outliers in the datasets faced by other schemes.

Parameters
  • values (np.array) – An array of values representing a sample of the values to quantize

  • num_points (int) – Number of points to obtain in the dictionary

  • scheme (str) – Indicates the quantization scheme to use, must be ‘uniform’, ‘kmeans’ or ‘cdf’

Returns

Array of quantization codes

Return type

np.array

sketchgraphs.pipeline.numerical_parameters.make_unique_cdf(arr)

Return ‘collapsed’ cdf of arr (identical/close arr vals all have same cdf point).

Parameters

arr (array of parameter values) –

Returns

  • sorted_arr (sorted copy of arr.)

  • cdf (collapsed cdf of arr.)

sketchgraphs.pipeline.numerical_parameters.normalize_expression(expression, parameter_id)

Converts a numerical expression into a normalized form.

Parameters
  • expression (str) – A string representing a quantity parameter value

  • parameter_id (str) – A parameterId string; must be one of ‘angle’ or ‘length’

Returns

norm_expression – Normalized expression string if successful, or None otherwise.

Return type

str or None