My data starts with the famous “iris” data dataset. The first four columns are floats describing attributes about the column with labels, “Species”.
X is a DataFrame of the first 4 columns.
Y is a Series of the last column “Species”.
I have a loop which feeds each row of X (ie. the four attributes) into an algorithm. In each iteration, the algorithm takes such a row of X and spits out a floats “prediction” for each of the 3 possibles values in species.
Observe above (1) model.predict() takes a row of X and returns one of the 3 labels in “Species” column, which is the prediction, and (2) the prediction also returns probabilities for each of the 3 possible Species, whose total adds up to 1.0, but in practice 1 species has a probability of something like 0.97 and the other two are virtually zero. I thought perhaps such low values might be an issue.
I construct a mesh grid for the heatmap using numpy. The -1 and +1 to define X_min/max are not essential for the heatmap. I only use them because when I combine this heatmap with a second trace of a scatterplot, then their width/height don’t seem to align well. But I can remove the -1 and +1 and nothing changes in this issue.
When I construct the mesh grid, I select two attributes from the above DataFrame, for example, SepalLengthCm and SepalWidthCm. The range of these two attributes forms the range of the X_min/X_max and Y_max/Y_min of the heatmap, respectively. The +1 and -1 (as described above) merely expand the their lengths. Each “coordinate” in the mesh grid represents an X (dataframe) value which is plugged into the above model which then spits out a probability prediction. The coordinates are then the x/y values in the heatmap, and the probability values (between 0 and 1.0) are the Z values in the heatmap.
The “h” value is used to calculate X_range and Y_range. A higher h value means more granular coordinates to be calculated in model.predictions (ie. 0.01, 0.02, 0.03, … versus 0.1, 0.2, 0.3, …), so a higher h value means a much more “dense” heatmap with a much large number of x/y/z coordinate values for plotly to plot.
When I use an h of .05 I get maybe 4000 coordinates to calculate for the heatmap, and plotly successfully generates a nice plot. But if I lower .05 to 0.02 I get maybe 5000 coordinates, and plotly does not generate an error but fails to display any plotly in Google Colab.
All I can think is maybe its about memory?