Belle II Software light-2405-quaxo
Importance Class Reference
Inheritance diagram for Importance:
Collaboration diagram for Importance:

Public Member Functions

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

Detailed Description

Plots importance matrix

Definition at line 1177 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 1182 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 1228 of file plotting.py.

1228 def finish(self):
1229 """
1230 Sets limits, title, axis-labels and legend of the plot
1231 """
1232 return self
1233
1234

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