instagram

Students learn how to compose Transformers, which act as functions operating on tables.

Lesson Goals

Students will be able to…​

  • Compose Transformers to create more sophisticated analyses

  • Diagram their composition to make sense of the order of operations

  • Find bugs when Transformers are not composed in the correct order

Student-facing Lesson Goals

  • Let’s practice combining Transformers

Materials

Preparation

  • This lesson requires each pair of students to create a cut-out set of "Transformer Cards". Have scissors available.

🔗Creating Transformers (Review) 25 minutes

Overview

Students practice creating, naming, and saving all of the Transformer types that they have discovered: Filter, Build Attribute, and Transform Attribute.

Launch

It’s fun to play around in CODAP! In fact, one of CODAP’s strengths is that it invites user experimentation.

Sometimes, however, relying on experimentation can limit our ability to plan data transformations. Familiarizing ourselves with exactly which inputs each Transformer requires can help us to efficiently transform data, without relying on guessing and checking every time.

Each Transformer we’ve worked with consumes a different amount of arguments, represented in the table below.

Filter Build Attribute Transform Attribute

Transformer Type
Dataset
Expression

Transformer Type
Dataset
Name of New Attribute
Expression

Transformer Type
Dataset
Attribute to Transform
New Name for Transformed Attribute
Expression

  • How many arguments does Filter require? How about Build Attribute? Transform Attribute?

    • Filter requires 2 arguments. Build Attribute requires 3 arguments. Transform Attribute requires 4 arguments.

  • Why does each Transformer require a different number of arguments?

    • All Transformers require a Transformer type and a dataset. Beyond that, Filter only needs a Boolean to know which rows to include and exclude from the new dataset. Build and Transform both require a new attribute name. Transform also needs to know which attribute is being transformed.

Investigate

In the subsequent activities, "Transformer Cards" are a tool for thinking about what specific arguments each Transformer requires. These cards will later support students in composing Transformers.

Let’s practice creating Transformer Cards to represent various Transformers.

Confirm that students have correct responses on their Transformer Cards, as these cards are central to the subsequent segment of the lesson.

Synthesize

  • Did you get more comfortable creating Transformer cards as you completed these two pages?

  • What obstacles did you encounter?

    • Responses will vary, but it is likely that students will have the most difficulty determining the expression.

  • What is the value of naming Transformers?

    • We name Transformers so that we can recognize what they do easily and even apply them to different datasets.

🔗Composing Transformers 25 minutes

Overview

Students learn to diagram composed Transformers using the Circles of Evaluation. This tool has deep roots in both Order of Operations and Function Composition, and math teachers may want to take a detour through one or both of these lessons to support those learning goals.

Launch

We already know how to filter, transform, and build columns - but what if we want to do multiple things, all at once? Filtering, transforming and building are powerful transformations, but when they are combined they become even more powerful!

Let’s play a game to explore what happens when we combine Transformers.

Get Ready:

  • Each pair of students needs one set of cut-out cards from Transformer Cards to Cut Out.

  • Each pair of students will need to refer to the three-row table of animals on the top of the page.

Gameplay:

  • Student 1: Randomly choose two cards and lay them down face up in front of your partner in the order that you chose them.

  • Student 2: Determine the output of "playing" those two cards in that order by referring to the three-row table of animals.

  • Return the cards to the deck, shuffle, and play another round.

Challenges:

  • Look at the cards in the deck. See if you can deal your partner two cards that…​

    • produce an error

    • produce the same dataset, regardless of the order in which they are dealt

    • produce a dataset with just one animal

    • produce an empty dataset (not an error!)

  • What did you discover about composing Transformers?

If we use our Transformers in the wrong order (trying to filter by a column that doesn’t exist yet, for example), we might wind up crashing the program. Order matters: Build / Transform, then Filter.

Investigate

One way to organize our thoughts is to diagram what we want to do, using the Circles of Evaluation. The rules are simple:

1) Every Circle must have one - and only one! - saved Transformer written at the top.

Each Transformer card that you created required different information, including the Transformer Type, the dataset, the expression, etc.

Once a Transformer is named and saved, however, it needs just one piece of information from you: the dataset that you want to transform! This leads us to the second rule of Circles of Evaluation…​

2) The dataset that the Transformer consumes is written in the the middle of the Circle.

Let’s think about our Transformer cards again. The Circle of Evaluation for filter-if-fixed looks like this:

(filter-if-fixed t)

But what if we want to play another Transformer card? The Circle of Evaluation above produces a table …​ which brings us to the third rule of Circles of Evaluation…​

3) Circles can contain other Circles!

Let’s say that after drawing filter-if-fixed, your partner draws filter-if-young. You could represent this sequence of cards like this.

(filter-if-young (filter-if-fixed t))

Changes can cause tables to go out of sync, resulting in hard-to-find bugs and invalid results.

But composing saved Transformers makes everything a "live view" of the original - unchanged -data! Any updates made to the original dataset will flow through the composition, keeping everything in sync. Transformers can also be reused, eliminating duplicate work.

Tip: Renaming Tables

Encourage students to rename tables descriptively.

As students compose Transformers, they may note that table names start to become quite lengthy, i.e. (weight-in-kg(filter-if-light(Animals-Dataset))). That’s a lot of parentheses! As an alternative, students might consider renaming the table something simpler. For instance, light-animals-in-kg would be a more easily interpreted table name.

Sometimes, the hardest part of solving a problem is knowing what you want to do, rather than worrying about how to do it. For example, sometimes solving an equation is a lot easier than setting it up in the first place.

Circles of Evaluation give us an opportunity to think through what we want to do, before getting in front of the computer and worrying about how to do it. Circles of Evaluation let us think and plan, without getting bogged down by small details.

Synthesize

Was it helpful to think about the Circles, without worrying about CODAP? Why or why not?

These materials were developed partly through support of the National Science Foundation, (awards 1042210, 1535276, 1648684, 1738598, 2031479, and 1501927). CCbadge Bootstrap by the Bootstrap Community is licensed under a Creative Commons 4.0 Unported License. This license does not grant permission to run training or professional development. Offering training or professional development with materials substantially derived from Bootstrap must be approved in writing by a Bootstrap Director. Permissions beyond the scope of this license, such as to run training, may be available by contacting contact@BootstrapWorld.org.