Skip to content

Injecting External Charts Using the SDK

This topic shows you how to inject a custom chart into a given experiment using MissingLink's send_chart SDK function on your CallbackObject.


  • Ensure you have performed basic integration with MissingLink's SDK.
  • Get the experiment identifier. The identifier can be either Experiment Id or Model weights hash:
    • Experiment Id - You can find the id of the currently running experiment by calling callback.experiment_id while the experiment runs. An attempt to retrieve the id before the experiment starts will return None.
    • Model weights hash - You can find the weights_hash of the model by calling model_weights_hash= callback.calculate_weights_hash(model) during the model training phase. If the same model_weights_hash is present in more than one experiment when sending the chart, the chart will be added to all of those experiments.
  • Create the array of X axis and array of Y axis values:
    • X axis points - Array of m data points. Elements can be Strings, Ints, and Floats. For example [0,1,2], [0.1,0.2,0.3] or ["One","2","3.0"]. The type must be consistent between the elements of the array.
    • Y axis points - Array/Matrix of m data values. Can be either an array m of Integers/Floats or a matrix (having n Ints/Floats each), or a full matrix describing the values of every y chart in every data point, for example [0.0,0.1,0.2] or [[11,22],[44,55],[77,88]].

Write code

The syntax of the send_chart SDK function is as follows:

def send_chart(self, name, x_values, y_values,
                x_legend=None, y_legends=None,
                scope='test', type='line',
                experiment_id=None, model_weights_hash=None):


The method injects an experiment external chart into an experiment. The experiment can be identified by its experiment_id or by model_weights_hash in the experiment (see examples, below). Exactly one of experiment_id or model_weights_hash must be provided.


  • name: Chart name. The name is used to identify the chart against different experiments and through the same experiment.
  • x_values: Array of m Strings / Ints / Floats - X axis points.
  • y_values: Array/Matrix of m Y axis points. Can be either an array m of Integers/Floats or a matrix (having n Ints/Floats each), or a full matrix describing the values of every y chart for every data point.
  • x_legend: String, Legend for the X axis.
  • y_legends: String/Array of n Strings legend of the Y axis chart(s)
  • scope: Scope type. Can be test, validation or train. Defaults to test.
  • type: Chart type. Currently, only line is supported.
  • experiment_id: The id of the target experiment.
  • model_weights_hash: Hexadecimal sha1 hash of the model's weights.


The following are examples of usage:

  • With weights hash:

    model_weights_hash= callback.calculate_weights_hash(model)
    callback.send_chart(name='Custom Chart 1',x_values=[0.1,0.2,0.3],  
                        model_weights_hash=model_weights_hash, y_legends=['y 1','y 2','y 3','y 4'])


    If there is more than one experiment with the same weights hash, the external chart will be added to all the experiments.

  • With experiment id:

    experiment_id= callback.experiment_id
    callback.send_chart(name='Custom Chart 1',x_values=[0.1,0.2,0.3],  
                        experiment_id=experiment_id, y_legends=['y 1','y 2','y 3','y 4'])


    You can see the full working code example with the support of different scopes here.