<jupyter_start><jupyter_text>Dziban MKIII<jupyter_code>from dziban.mkiii import Chart
from vega_datasets import data
base = Chart(data.cars())<jupyter_output><empty_output><jupyter_text>Example 1 A user is analyzing the cars dataset. They begin by asking the question, 'How does horsepower relate to MPG?' They can formulate such a query as such.<jupyter_code>scatter = base.field('Horsepower', 'Miles_per_Gallon')
scatter<jupyter_output><empty_output><jupyter_text>A simple scatterplot is recommended. This is the basis of recommendation with __Dziban__, but we can also build upon this result.  Example 2 Now, taking a look at `scatter`, a trend is visible: increasing __horsepower__ is correlated with decreasing __MPG__. To confirm this, they may which to view an aggregate metric: the mean of the horsepower in relation to MPG.A __cold__ recommendation would yield the following.<jupyter_code>bad_binned = base.field('Miles_per_Gallon').field('Horsepower', aggregate='mean')
bad_binned<jupyter_output><empty_output><jupyter_text>Note that a few things have changed that may be confusing. First, the x and y axes were swapped. The pattern seen in the previous visualization has been flipped. Second, the `zero` baseline for MPG has been removed, which again makes comparison difficult. A better visualization would be one that has been __anchored__, and thus changes the least number of items whilst optimizing effectiveness.<jupyter_code>good_binned = bad_binned.anchor(scatter)
good_binned<jupyter_output><empty_output><jupyter_text>Example 2 Suppose now the user has begun with the bar chart we left off on in __example 1__, `good_binned`. They wish to see this relationship, but additionally as pertains to the country of __origin__. That is, they wish to see the relationship between mean horsepower, miles per gallon, and origin. A recommendation from scratch would be as such.<jupyter_code>origin_bad = base.field('Miles_per_Gallon', 'Origin').field('Horsepower', aggregate='mean')
origin_bad<jupyter_output><empty_output><jupyter_text>Again, however, reading this chart will require additional time, as many encodings have been moved around (MPG from y to x, horsepower from x to size, bar mark to point mark). To minimize the cognitive load made on users, we should preserve the encodings present in `good_binned` above (the user's reference point).<jupyter_code>origin_good = good_binned.field('Origin').anchor(good_binned)
origin_good<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06776926179911255, 'fraction_numerical': 0.0016135538523598225, 'mean_word_length': 6.630769230769231, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '197796', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 715, 'n_tokens_neox': 687, 'n_words': 290, 'path': 'examples/old/MKIII.ipynb', 'repo_name': 'haldenl/dziban', 'size': '2479'}