Plot the distribution of a real-valued feature conditioned by the target.

    Examples:
        `plot_real_feature(X, 'emb_mean_euclidean')`

    Args:
        df: Pandas dataframe containing the target column (named 'target').
        feature_name: The name of the feature to plot.
        bins: The number of histogram bins for the distribution plot.
        figsize: The size of the plotted figure.

def plot_real_feature(df, feature_name, bins=50, figsize=(15, 15)):
    """
    Plot the distribution of a real-valued feature conditioned by the target.

    Examples:
        `plot_real_feature(X, 'emb_mean_euclidean')`

    Args:
        df: Pandas dataframe containing the target column (named 'target').
        feature_name: The name of the feature to plot.
        bins: The number of histogram bins for the distribution plot.
        figsize: The size of the plotted figure.
    """

    ix_negative_target = df[df.target == 0].index
    ix_positive_target = df[df.target == 1].index

    plt.figure(figsize=figsize)

    ax_overall_dist = plt.subplot2grid((3, 2), (0, 0), colspan=2)
    ax_target_conditional_dist = plt.subplot2grid((3, 2), (1, 0), colspan=2)

    ax_botplot = plt.subplot2grid((3, 2), (2, 0))
    ax_violin_plot = plt.subplot2grid((3, 2), (2, 1))

    ax_overall_dist.set_title('Distribution of {}'.format(feature_name), fontsize=16)
    sns.distplot(
        df[feature_name],
        bins=50,
        ax=ax_overall_dist
    )

    sns.distplot(
        df.loc[ix_positive_target][feature_name],
        bins=bins,
        ax=ax_target_conditional_dist,
        label='Positive Target'
    )
    sns.distplot(
        df.loc[ix_negative_target][feature_name],
        bins=bins,
        ax=ax_target_conditional_dist,
        label='Negative Target'
    )
    ax_target_conditional_dist.legend(loc='upper right', prop={'size': 14})

    sns.boxplot(
        y=feature_name,
        x='target',
        data=df,
        ax=ax_botplot
    )
    sns.violinplot(
        y=feature_name,
        x='target',
        data=df,
        ax=ax_violin_plot
    )

    plt.show()