Belle II Software light-2406-ragdoll
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 1184 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 1189 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 1235 of file plotting.py.

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

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