Functions

Summary

function

class parent

truncated documentation

_1d_problem

__pep8

_additional_imports

Adds additional imports for experimental models.

_analyse_tree

Extract information from a tree.

_analyse_tree_h

Extract information from a tree in a HistGradientBoosting.

_apply_optimisation_on_graph

Applies an optimisation function fct on a graph and not on the model.

_apply_remove_node_fct_node

Applies an optimizing function on a subgraphs.

_argmax

_argmax_use_numpy_select_last_index

_argmin

_argmin_use_numpy_select_last_index

_array_feature_extrator

Implementation of operator ArrayFeatureExtractor with numpy.

_asv_class_name

_batchnorm_test_mode

_build_schemas

_call_conv_runtime_opset

_call_runtime

Private.

_capture_output

_check_run_benchmark

_clean_script

Comments out all lines containing .show().

_clean_values_optim

_compare_expected

Compares the expected output against the runtime outputs. This is specific to onnxruntime or mlprodict. …

_coor_to_str

_create_asv_benchmark_file

Creates a benchmark file based in the information received through the argument. It uses template TemplateBenchmark. …

_create_column

Creates a column from values with dtype

_create_node_id

_custom_parser_xgboost

Custom parser for XGBClassifier and LGBMClassifier.

_dict2str

_dictionary2str

_display_code_lines

_dispsimple

_dofit_model

_dropout

_elem_type_as_str

_enumerate_asv_benchmark_all_models

Loops over all possible models and fills a folder with benchmarks following asv concepts.

_enumerate_classes

Extracts the classes of a file.

_enumerate_fit_info

Extracts the name of the fitted models and the data used to train it.

_enumerate_validated_operator_opsets_ops

_enumerate_validated_operator_opsets_version

_figures2dict

Converts the data from list to dictionaries.

_finalize

_format_dict

Formats a dictionary as code.

_get_doc_template

_get_info_lgb

Get informations from and lightgbm trees.

_get_info_xgb

Get informations from and lightgbm trees.

_get_ir_version

_get_problem_data

_get_typed_class_attribute

Converts an attribute into a C++ value.

_global_average_pool

_guess_noshape

_guess_type

_handle_init_files

Returns created, location_model, prefix_import.

_has_decision_function

_has_predict_proba

_has_transform_model

_hash_obj_content

Hash the content of an object.

_jsonify

_make_att_graph

_make_callable

Same function as make_callable() but deals with function which an undefined number of arguments.

_make_node

Constructs a NodeProto.

_make_opset

_measure_time

Measures the execution time for a function.

_merge_options

_model_name

Extracts the main component of a model, removes suffixes such Classifier, Regressor, CV.

_model_outputs

Retrieves the outputs of one particular models.

_modify_dimension

Modifies the number of features to increase or reduce the number of features.

_multiply_time_kwargs

Multiplies values in time_kwargs following strategy time_kwargs_fact for a given model inst.

_noshapevar

_numpy_array

Single function to create an array.

_numpy_dot_inplace_left

Subpart of @see fn numpy_dot_inplace.

_numpy_dot_inplace_right

Subpart of @see fn numpy_dot_inplace.

_op_type_domain_classifier

Defines op_type and op_domain based on dtype.

_op_type_domain_classifier

Defines op_type and op_domain based on dtype.

_op_type_domain_regressor

Defines op_type and op_domain based on dtype.

_op_type_domain_regressor

Defines op_type and op_domain based on dtype.

_pad_impl

_parse_node

Parses nodes.

_parse_tree_structure

The pool of all nodes’ indexes created when parsing a single tree. Different tree use different pools.

_pool_get_output_shape

_pool_impl

_post_process_output

Applies post processings before running the comparison such as changing type from list to arrays.

_problem_for_cl_decision_function

Returns X, y, intial_types, method, name, X runtime for a scoring problem. It is based on Iris dataset.

_problem_for_cl_decision_function_binary

Returns X, y, intial_types, method, name, X runtime for a scoring problem. Binary classification. It is based …

_problem_for_clnoproba

Returns X, y, intial_types, method, name, X runtime for a scoring problem. It is based on Iris dataset.

_problem_for_clnoproba_binary

Returns X, y, intial_types, method, name, X runtime for a scoring problem. Binary classification. It is based …

_problem_for_clustering

Returns X, intial_types, method, name, X runtime for a clustering problem. It is based on Iris dataset.

_problem_for_clustering_scores

Returns X, intial_types, method, name, X runtime for a clustering problem, the score part, not the cluster. It …

_problem_for_dict_vectorizer

Returns a problem for the sklearn.feature_extraction.DictVectorizer.

_problem_for_feature_hasher

Returns a problem for the sklearn.feature_extraction.DictVectorizer.

_problem_for_label_encoder

Returns a problem for the sklearn.preprocessing.LabelEncoder.

_problem_for_mixture

Returns X, y, intial_types, method, node name, X runtime for a m-cl classification problem. It is based on Iris …

_problem_for_numerical_scoring

Returns X, y, intial_types, method, name, X runtime for a scoring problem. It is based on Iris dataset.

_problem_for_numerical_trainable_transform

Returns X, intial_types, method, name, X runtime for a transformation problem. It is based on Iris dataset.

_problem_for_numerical_trainable_transform_cl

Returns X, intial_types, method, name, X runtime for a transformation problem. It is based on Iris dataset.

_problem_for_numerical_transform

Returns X, intial_types, method, name, X runtime for a transformation problem. It is based on Iris dataset.

_problem_for_numerical_transform_positive

Returns X, intial_types, method, name, X runtime for a transformation problem. It is based on Iris dataset.

_problem_for_one_hot_encoder

Returns a problem for the sklearn.preprocessing.OneHotEncoder.

_problem_for_outlier

Returns X, intial_types, method, name, X runtime for a transformation problem. It is based on Iris dataset.

_problem_for_predictor_binary_classification

Returns X, y, intial_types, method, node name, X runtime for a binary classification problem. It is based on Iris …

_problem_for_predictor_multi_classification

Returns X, y, intial_types, method, node name, X runtime for a m-cl classification problem. It is based on Iris …

_problem_for_predictor_multi_classification_label

Returns X, y, intial_types, method, node name, X runtime for a m-cl classification problem. It is based on Iris …

_problem_for_predictor_multi_regression

Returns X, y, intial_types, method, name, X runtime for a mregression problem. It is based on Iris dataset.

_problem_for_predictor_regression

Returns X, y, intial_types, method, name, X runtime for a regression problem. It is based on Iris dataset.

_problem_for_tfidf_transformer

Returns a problem for the :epkg:`sklearn:feature_extraction:text:TfidfTransformer`.

_problem_for_tfidf_vectorizer

Returns a problem for the :epkg:`sklearn:feature_extraction:text:TfidfVectorizer`.

_raw_score_binary_classification

_read_patterns

Reads the testing pattern.

_reduce_infos

Produces agregates features.

_register_converters_lightgbm

This functions registers additional converters for lightgbm.

_register_converters_mlinsights

This functions registers additional converters for mlinsights.

_register_converters_xgboost

This functions registers additional converters for xgboost.

_rename_graph_input

Renames an input and adds an Identity node to connect the dots.

_rename_graph_output

Renames an output and adds an Identity node to connect the dots.

_rename_node_input

Renames an input from a node.

_rename_node_output

Renames an output from a node.

_replace

_replace_tensor_type

_retrieve_class_parameters

Imports files in bdir, compile files and extra metadata from them.

_retrieve_problems_extra

Use by enumerate_compatible_opset().

_run_skl_prediction

_save_model_dump

_select_pattern_problem

Selects a benchmark type based on the problem kind.

_setup_hook

If this function is added to the module, the help automation and unit tests call it first before anything goes on …

_shape_exc

_sklearn_subfolder

Returns the list of subfolders for a model.

_sparse_array

Single function to create an sparse array (coo_matrix).

_summary_report_indices

_to_array

_translate_split_criterion

_try_onnx

Tries onnx conversion.

_type_to_string

Converts a type into a readable string.

_update_test_metadata

_validate_runtime_dict

_validate_runtime_separate_process

_var_as_dict

Converts a protobuf object into something readable. The current implementation relies on json. That’s not …

_vcelu1

add_model_import_init

Modifies a template such as TemplateBenchmarkClassifier with code associated to the model model.

analyze_model

Returns informations, statistics about a model, its number of nodes, its size…

annotate_heatmap

Annotates a heatmap. See plot_benchmark_metrics() for an example.

astype_range

Computes ranges for every number in an array once converted into float32. The function returns two matrices which …

asv2csv

Converts results produced by asv into csv.

asv_bench

Creates an asv benchmark in a folder but does not run it.

benchmark_fct

Benchmarks a function which takes an array as an input and changes the number of rows.

benchmark_replay

The command rerun a benchmark if models were stored by command line vaidate_runtime.

benchmark_version

Returns the list of ONNX version to benchmarks. Following snippet of code shows which version is current done.

binary_array_to_string

Used to compare decision path.

build_custom_scenarios

Defines parameters values for some operators.

build_custom_scenarios

Defines parameters values for some operators.

build_key_split

Used for documentation.

calculate_lightgbm_output_shapes

Shape calculator for LightGBM Booster (see lightgbm).

change_input_first_dimension

Some models are converted under the assumption batch prediction is not necessary. This function changes the first …

change_style

Switches from AaBb into aa_bb.

check

Checks the library is working. It raises an exception. If you want to disable the logs:

check_is_almost_equal

Checks that two floats or two arrays are almost equal.

check_model_representation

Checks that a trained model can be exported in a specific list of formats and produces the same outputs if the representation …

check_type

Raises an exception if the model is not of the expected type.

clean_error_msg

Removes EOL from error messages in dataframes.

compare_backend

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output. …

compare_outputs

Compares expected values and output. Returns None if no error, an exception message otherwise.

compare_runtime

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output …

compare_runtime

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output …

compare_runtime_session

The function compares the expected output (computed with the model before being converted to ONNX) and the ONNX output …

compile_c_function

Compiles a C function with cffi. It takes one features vector.

compose_page_onnxrt_ops

Writes page Python Runtime for ONNX operators.

compute_benchmark

Compares the processing time several functions.

convert_lightgbm

This converters reuses the code from LightGbm.py

convert_model

Runs the appropriate conversion method.

convert_score_cdist_sum

Converts function score_cdist_sum() into ONNX.

convert_scorer

Converts a scorer into ONNX assuming there exists a converter associated to it. The function wraps the function …

convert_transfer_transformer

Converters for TransferTransformer.

convert_validate

Converts a model stored in pkl file and measure the differences between the model and the ONNX predictions.

convert_xgboost

This converters reuses the code from XGBoost.py

converter_lightgbm_concat

Converter for operator LightGBMConcat.

create_asv_benchmark

Creates an asv benchmark in a folder but does not run it.

create_tensor

Creates a tensor.

custom_einsum

Experimental implementation of operator Einsum when it does a matrix multiplication. Case: bsnh,btnh->bnts with …

custom_pad

Implements function pad in python, only …

custom_scorer_transform_converter

Selects the appropriate converter for a @see cl CustomScorerTransform.

custom_scorer_transform_parser

This function updates the inputs and the outputs for a @see cl CustomScorerTransform.

custom_scorer_transform_shape_calculator

Computes the output shapes for a @see cl CustomScorerTransform.

debug_dump

Dumps an object for debug purpose.

debug_onnx_object

__dict__ is not in most of onnx objects. This function uses function dir to explore this object.

debug_print

Displays informations on an object.

default_time_kwargs

Returns default values number and repeat to measure the execution of a function.

display_onnx

Returns a shortened string of the model.

dump_binary_classification

Trains and dumps a model for a binary classification problem. The function trains a model and calls dump_data_and_model(). …

dump_data_and_model

Saves data with pickle, saves the model with pickle and onnx, runs and saves the predictions for the given model. …

dump_into_folder

Dumps information when an error was detected using pickle.

dump_multilabel_classification

Trains and dumps a model for a binary classification problem. The function trains a model and calls dump_data_and_model(). …

dump_multiple_classification

Trains and dumps a model for a binary classification problem. The function trains a model and calls dump_data_and_model(). …

dump_multiple_regression

Trains and dumps a model for a multi regression problem. The function trains a model and calls dump_data_and_model(). …

dump_one_class_classification

Trains and dumps a model for a One Class outlier problem. The function trains a model and calls dump_data_and_model(). …

dump_single_regression

Trains and dumps a model for a regression problem. The function trains a model and calls dump_data_and_model(). …

enumerate_benchmark_replay

Replays a benchmark stored with function enumerate_validated_operator_opsets

enumerate_compatible_opset

Lists all compatible opsets for a specific model.

enumerate_export_asv_json

Looks into asv results and wraps all of them into a dataframe or flat data.

enumerate_fitted_arrays

Enumerate all fitted arrays included in a scikit-learn object.

enumerate_model_node_outputs

Enumerates all the nodes of a model.

enumerate_models

Enumerates models with models.

enumerate_pipeline_models

Enumerates all the models within a pipeline.

enumerate_random_inputs

Enumerates random matrices.

enumerate_validated_operator_opsets

Tests all possible configurations for all possible operators and returns the results.

enumerate_visual_onnx_representation_into_rst

Returns content for pages such as linear_model.

evaluate_condition

Evaluates a condition such as StrictVersion(onnxruntime.__version__) <= StrictVersion('0.1.3')

expand_onnx_options

Expands shortened options. Long names hide some part of graphs in asv benchmark. This trick converts a string …

export_asv_json

Looks into asv results and wraps all of them into a dataframe or flat data.

extract_information_from_filename

Returns a dictionary with information extracted from a filename. An example is better:

extract_options

Extracts comparison option from filename. As example, Binarizer-SkipDim1 means options SkipDim1 is enabled. …

filter_rows

Used for documentation.

find_missing_sklearn_imports

Finds in scikit-learn the missing pieces.

find_sklearn_module

Finds the corresponding modulee for an element of scikit-learn.

find_suitable_problem

Defines suitables problems for additional converters.

find_suitable_problem

Determines problems suitable for a given scikit-learn operator. It may be

fit_classification_model

Fits a classification model.

fit_classification_model_simple

Fits a classification model.

fit_multilabel_classification_model

Fits a classification model.

fit_regression_model

Fits a regression model.

fix_missing_imports

The execution of a file through function exec does not import new modules. They must be there when it is …

from_bytes

Retrieves an array from bytes then protobuf.

gather_numpy

Gathers values along an axis specified by dim. For a 3-D tensor the output is specified by:

gather_numpy_2

get_default_context

Returns a default context useful for most of the conversion from a function using numpy into ONNX.

get_default_context_cpl

Returns a default useful context to compile the converter returned by translate_fct2onnx().

get_defined_inputs

Retrieves defined inputs in already declared variables bsed on their names.

get_defined_outputs

Gets types of predefined outputs when they cannot be inferred. Some part of it should be automated based on type …

get_inputs_from_data

Produces input data for onnx runtime.

get_ir_version_from_onnx

Retuns the current onnx IR_VERSION based on the installed version of onnx.

get_opset_number_from_onnx

Retuns the current onnx opset based on the installed version of onnx.

get_opset_number_from_onnx

Retuns the current onnx opset based on the installed version of onnx.

get_rst_doc

Returns a documentation in RST format for all OnnxOperator.

guess_initial_types

Guesses initial types from an array or a dataframe.

guess_schema_from_data

Guesses initial types from a dataset.

guess_schema_from_model

Guesses initial types from a model.

heatmap

Creates a heatmap from a numpy array and two lists of labels. See plot_benchmark_metrics() for an example.

identify_interpreter

Identifies the interpreter for a scikit-learn model.

inspect_sklearn_model

Inspects a scikit-learn model and produces some figures which tries to represent the complexity of it.

interpret_options_from_string

Converts a string into a dictionary.

ir_version

Returns the preferred IR_VERSION.

iris_data

Returns (X, y) for iris data.

is_backend_enabled

Tells if a backend is enabled. Raises an exception if backend != ‘onnxruntime’. Unit tests only test models against …

lightgbm_parser

Agnostic parser for LightGBM Booster.

load_audit

Use to test conversion of sklearn.ensemble.GradientBoostingClassifier into ONNX.

load_data_and_model

Loads every file in a dictionary {key: filename}. The extension is either pkl and onnx and determines how it …

load_ipython_extension

To allow the call %load_ext mlprodict

load_op

Sets up a class for a specific ONNX operator.

load_op

Gets the operator related to the onnx node.

load_op

Gets the operator related to the onnx node.

main

Implements python -m mlprodict <command> <args>.

make_callable

Creates a callable function able to cope with default values as the combination of functions compile and exec

make_n_rows

Multiplies or reduces the rows of x to get exactly n rows.

make_readable_title

Creates a readable title based on the test information.

max_depth

Retrieves the max depth assuming the estimator is a decision tree.

measure_relative_difference

Measures the relative difference between predictions between two ways of computing them. The functions returns nan …

measure_time

Measures a statement and returns the results as a dictionary.

merge_benchmark

Merges several benchmarks run with command line validate_runtime.

merge_results

Merges results by name. The first ones are used to keep the order.

modify_tree_for_rule_in_set

LightGBM produces sometimes a tree with a node set to use rule == to a set of values (= in set), the values …

modules_list

Returns modules and versions currently used.

new_convert_sklearn_decision_tree_classifier

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_decision_tree_regressor

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_gradient_boosting_classifier

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_gradient_boosting_regressor

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_random_forest_classifier

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_random_forest_regressor

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_svm_classifier

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

new_convert_sklearn_svm_regressor

Rewrites the converters implemented in sklearn-onnx to support an operator supporting doubles.

numpy_dot_inplace

Implements a dot product, deals with inplace information.

numpy_max

Returns the maximum of an array. Deals with text as well.

numpy_max

Returns the maximum of an array. Deals with text as well.

numpy_min

Returns the minimum of an array. Deals with text as well.

numpy_min

Returns the maximum of an array. Deals with text as well.

numpy_min_max

Returns the minimum of an array. Deals with text as well.

onnx_optim

Optimises an ONNX model.

onnx_optimisations

Calls several possible optimisations including onnx_remove_node().

onnx_remove_node

Removes as many nodes as possible without changing the outcome. It applies onnx_remove_node_identity(), then …

onnx_remove_node_identity

Removes as many Identity nodes as possible. The function looks into every node and subgraphs if recursive is …

onnx_remove_node_redundant

Removes redundant part of the graph. A redundant part is a set of nodes which takes the same inputs and produces …

onnx_shaker

Shakes a model ONNX. Explores the ranges for every prediction. Uses astype_range()

onnx_statistics

Computes statistics on ONNX models, extracts informations about the model such as the number of nodes.

onnx_stats

Computes statistics on an ONNX model.

onnxview

Displays an ONNX graph into a notebook.

pairwise_array_distances

Computes pairwise distances between two lists of arrays l1 and l2. The distance is 1e9 if shapes are not equal.

parser_transfer_transformer

Parser for TransferTransformer.

plot_benchmark_metrics

Plots a heatmap which represents a benchmark. See example below.

plot_validate_benchmark

Plots a graph which summarizes the performances of a benchmark validating a runtime for ONNX.

proto2dtype

Converts a proto type into a numpy type.

proto2vars

Converts proto values to Variables.

py_make_float_array

Creates an array with a single element from a constant.

py_mul

Function for python operator *.

py_opp

Function for python unary operator -.

py_pow

Function for python operator **.

pycelu

Computes function celu(x).

register_converters

This functions registers additional converters to the list of converters sklearn-onnx declares.

register_onnx_magics

Register magics function, can be called from a notebook.

register_operator

Registers a new runtime operator.

register_rewritten_operators

Registers modified operators and returns the old values.

register_scorers

Registers operators for @see cl CustomScorerTransform.

reshape_reference_implementation

score_cdist_sum

Computes the sum of pairwise distances between expected_values and predictions. It has no particular purpose …

select_model_inputs_outputs

Takes a model and changes its outputs.

set_n_jobs

Looks into model signature and add parameter n_jobs if available. The function does not overwrite the parameter.

set_random_state

Sets all possible parameter random_state to 0.

shape_calculator_lightgbm_concat

Shape calculator for operator LightGBMConcat.

shape_calculator_transfer_transformer

Shape calculator TransferTransformer.

shorten_onnx_options

Shortens onnx options into a string. Long names hide some part of graphs in asv benchmark.

side_by_side_by_values

Compares the execution of two sessions. It calls method OnnxInference.run

sizeof_dtype

sklearn2graph

Converts any kind of scikit-learn model into a grammar model.

sklearn_decision_tree_regressor

Converts a DecisionTreeRegressor

sklearn_linear_regression

Converts a linear regression

sklearn_logistic_regression

Interprets a logistic regression

sklearn_operators

Builds the list of operators from scikit-learn. The function goes through the list of submodule and get …

sklearn_standard_scaler

Converts a standard scaler

split_columns_subsets

Functions used in the documentation to split a dataframe by columns into multiple dataframe to reduce the scrolling. …

squareform_pdist

Replacements for squareform

summary_report

Finalizes the results computed by function enumerate_validated_operator_opsets().

timeexec

Measures the time for a given expression.

timeit_repeat

Returns a series of repeat time measures for number executions of code assuming fct is a function.

to_bytes

Converts an array into protobuf and then into bytes.

to_onnx

Converts a model using on sklearn-onnx.

topk_sorted_implementation

Retrieves the top-k elements.

topk_sorted_implementation_cpp

Retrieves the top-k elements using a C++ implementation when the axis is the last dimension, otherwise, it falls …

translate_fct2onnx

Translates a function into ONNX. The code it produces is using classes OnnxAbs, OnnxAdd, …

type_mapping

Mapping between types name and type integer value.

validate_python_inference

Validates the code produced by method to_python. …

validate_runtime

Walks through most of scikit-learn operators or model or predictor or transformer, tries to convert them …

verify_code

Verifies python code.

verify_script

Checks that models fitted in an example from scikit-learn documentation can be converted into ONNX.

version2number

Converts a version number into a real number.

visual_rst_template

Returns a jinja2 template to display DOT graph for each converter from sklearn-onnx.