df df['key1'] = (4, 4, 4, 6, 6, 6, 8, 8, 8, 8) sns.pairplot(x_vars=["one"], y_vars=["two"], data=df, hue="key1", size=5) sns.pairplot(vars=["one", "two", "three"], data=df, hue="key1", size=5) #%%% # Generate Data num = 20 x, y = np.random.random((2, num)) labels = np.random.choice(['a', 'b', 'c'], num) df = pd.DataFrame(dict(x=x, y=y, label=labels)) #Altair code from altair import Chart c = Chart(df) c.mark_circle().encode(x='x', y='y', color='label') #%% import matplotlib.pyplot as plt from mlxtend.plotting import category_scatter df.columns df.head() fig = category_scatter(x='x', y='y', label_col='label', data=df, legend_loc='upper left') df8b.columns fig = category_scatter(x='marks1', y='marks2',
def accuracy_vs_horizon_chart( base: alt.Chart, horizon_selection_brush: alt.Selection, belief_horizon_unit: str, intuitive_forecast_horizon: bool, unique_belief_horizons, ) -> alt.LayerChart: ha_chart = ( base.mark_circle() .transform_joinaggregate( on_the_fly_mae="mean(mae)", on_the_fly_reference="mean(reference_value)", groupby=["belief_horizon", "source"], ) .transform_calculate( on_the_fly_wape=alt.datum.on_the_fly_mae / alt.datum.on_the_fly_reference, accuracy=1 - alt.datum.on_the_fly_wape, ) .encode( opacity=alt.condition( selectors.time_selection_brush, alt.Opacity( "event_start:T", scale=alt.Scale(domain=(0.9999, 1)), legend=None ), alt.value(0), ), # Trick to be able to apply the selection filter for event_start (event_start must be a field in one of the encoding channels) x=alt.X( "belief_horizon:Q", axis=alt.Axis(labelFlush=False), scale=alt.Scale( zero=False, domain=(unique_belief_horizons[0], unique_belief_horizons[-1]), ), title="%s (%s)" % ( "Forecast horizon" if intuitive_forecast_horizon else "Belief horizon", belief_horizon_unit, ), ), y=alt.Y( "accuracy:Q", title="Accuracy (1-WAPE)", axis=alt.Axis(format="%", minExtent=30), scale={"domain": (0, 1)}, ), color=selectors.source_color_or( selectors.idle_color, selectors.horizon_hover_brush | horizon_selection_brush, ), size=alt.value(100), tooltip=[ alt.Tooltip("accuracy:Q", title="Accuracy (1-WAPE)", format=".1%"), alt.Tooltip( "belief_horizon:Q", title="%s (%s)" % ( "Forecast horizon" if intuitive_forecast_horizon else "Belief horizon", belief_horizon_unit, ), ), alt.Tooltip("source:O", title="Source"), ], ) .properties(title="Model accuracy in the %s before" % belief_horizon_unit) # .configure_title(offset=-270, orient="bottom") ) ha_interpolation_chart = ha_chart.mark_line(interpolate="monotone").encode( size=alt.value(1), color=alt.Color("source:N", legend=None) ) return ha_interpolation_chart + ha_chart