Я использую displot
для построения графиков распределения между 2
наборами данных. Я использую следующий код:
def plot_distributions(y, Z, filename=None):
graph, axes = plt.subplots(1, 2, figsize=(10, 4), sharey=False)
legend={'race': ['black','white'],
'sex': ['female','male']}
for idx, attr in enumerate(Z.columns):
for attr_val in [0, 1]:
ax = sns.distplot(y[Z[attr] == attr_val], hist=False,
kde_kws={'shade': False,},
label='{}'.format(legend[attr][attr_val]),
ax=axes[idx])
if idx == 0 or idx==1:
ax.set_xlim(0,1)
ax.set_yticks([])
ax.set_title("{}".format(attr))
ax.set_ylabel('Prediction Distribution')
ax.set_xlabel(r'$P({{income>50K}}|z_{{{}}})$'.format(attr))
if filename is not None:
plt.savefig(filename, bbox_inches='tight')
return graph
graph = plot_distributions(y_pred, Z_test, filename='img.png')
Это дает мне следующий результат: ![enter image description here](https://i.stack.imgur.com/APbGk.png)
Обычно, 2 графика должны быть ближе друг к другу.
Как лучше всего рассчитать расстояние между этими 2 участками?