Accessing and plotting t-SNE data

If you use the Ouptut to file option to save t-SNE output to files, you can then create plots using other fields for comparison purposes – or use the output as predictors in classification or regression models. The t-SNE model creates a result file of x, y (and z) coordinate fields that is most easily accessed using a Fixed File source node. This section provides example information.

  1. In the t-SNE node dialog, open the Output tab.
  2. Select Output to file and type a file name. Use the default HTML file type. When you run the model, this will generate three output files in your output location:
    • A text file (result_xxxxxx.txt)
    • An HTML file (the file name you specified)
    • A PNG file (tsne_chart_yyyyyy.png)

    The text file will contain the data you need, but for technical reasons it may be in standard or scientific format. If it's in scientific format (1.11111111e+01), then you need to create a new stream that recognizes the format:

Accessing t-SNE plot data when the text file is in scientific numeric format

  1. Create a new stream (File > New Stream).
  2. Go to Tools > Stream Properties > Options, select Number formats, and select Scientific (#.###E+##) for the number display format.
  3. Add a Fixed File source node to your canvas, and use the following settings on the File tab:
    • Skip header lines: 1
    • Record length: 54
    • tSNE_x Start: 3, Length: 16
    • tSNE_y Start: 20, Length: 16
    • tSNE_z Start: 36, Length: 16
  4. On the Type tab, the numbers should be recognized as Real. Click Read Values and you should see field values similar to:
    Table 1. Example field values
    Field Measurement Values
    tSNE_x Continuous [-7.07176703,7.14338837]
    tSNE_y Continuous [-9.2188112,8.89647667]
    tSNE_x Continuous [-9.95892882,9.95742482]
  5. Add a Select node to the stream so you can delete the following bottom two rows of text in the file which are read as nulls:
    *****************
    Perform t-SNE (total time 9.5s)
    On the Settings tab of the Select node, select Discard for the mode and use the condition @NULL(tSNE_x) to delete the rows.
  6. Add a Type node and a Flat File export node to the stream to create a Var. File source node that will copy and paste back into your original stream.

Accessing t-SNE plot data when the text file is in standard numeric format

  1. Create a new stream (File > New Stream).
  2. Add a Fixed File source node to your canvas. The following three nodes are all that's required to access the t-SNE data.
    Figure 1. Stream for accessing t-SNE plot data in standard numeric format
    Stream for accessing t-SNE plot data in standard numeric format
  3. Use the following settings on the File tab of the Fixed File source node:
    • Skip header lines: 1
    • Record length: 29
    • tSNE_x Start: 3, Length: 12
    • tSNE_y Start: 16, Length: 12
  4. On the Filter tab, you can rename field1 and field2 to tsneX and tsneY.
  5. Add a Merge node to connect it to your stream by using the Order merge method.
  6. You can now use a Plot node to plot tsneX versus tsneY and color it with your field under investigation.