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 1187 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 1192 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 1238 of file plotting.py.

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

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