Belle II Software development
Importance Class Reference
Inheritance diagram for Importance:
Plotter

Public Member Functions

def add (self, data, columns, variables)
 
def finish (self)
 

Detailed Description

Plots importance matrix

Definition at line 1185 of file plotting.py.

Member Function Documentation

◆ add()

def add (   self,
  data,
  columns,
  variables 
)
Add a new correlation plot.
@param data pandas.DataFrame containing all data
@param columns which are used to calculate the correlations

Reimplemented from Plotter.

Definition at line 1190 of file plotting.py.

1190 def add(self, data, columns, variables):
1191 """
1192 Add a new correlation plot.
1193 @param data pandas.DataFrame containing all data
1194 @param columns which are used to calculate the correlations
1195 """
1196 self.figure.set_tight_layout(True)
1197
1198 def norm(x):
1199 width = (numpy.max(x) - numpy.min(x))
1200 if width <= 0:
1201 return numpy.zeros(x.shape)
1202 return (x - numpy.min(x)) / width * 100
1203
1204 importance_matrix = numpy.vstack([norm(data[column]) for column in columns]).T
1205 importance_heatmap = self.axis.pcolor(importance_matrix, cmap=plt.cm.RdBu, vmin=0.0, vmax=100,
1206 rasterized=True)
1207
1208 # put the major ticks at the middle of each cell
1209 self.axis.set_yticks(numpy.arange(importance_matrix.shape[0]) + 0.5, minor=False)
1210 self.axis.set_xticks(numpy.arange(importance_matrix.shape[1]) + 0.5, minor=False)
1211
1212 self.axis.set_xticklabels(columns, minor=False, rotation=90)
1213 self.axis.set_yticklabels(variables, minor=False)
1214
1215 self.axis.xaxis.tick_top()
1216
1217 for y in range(importance_matrix.shape[0]):
1218 for x in range(importance_matrix.shape[1]):
1219 txt = self.axis.text(x + 0.5, y + 0.5, f'{importance_matrix[y, x]:.0f}',
1220 size=14,
1221 horizontalalignment='center',
1222 verticalalignment='center',
1223 color='w')
1224 txt.set_path_effects([PathEffects.withStroke(linewidth=3, foreground='k')])
1225
1226 cb = self.figure.colorbar(importance_heatmap, ticks=[0.0, 100], orientation='vertical')
1227 cb.ax.set_yticklabels(['low', 'high'])
1228
1229 # remove whitespace
1230 self.axis.set_ylim(0, importance_matrix.shape[0])
1231
1232 self.axis.set_aspect('equal')
1233
1234 return self
1235

◆ finish()

def finish (   self)
Sets limits, title, axis-labels and legend of the plot

Reimplemented from Plotter.

Definition at line 1236 of file plotting.py.

1236 def finish(self):
1237 """
1238 Sets limits, title, axis-labels and legend of the plot
1239 """
1240 return self
1241
1242

The documentation for this class was generated from the following file: