A Model for Programmer Apprenticeships, Starting in High School with Mathematica

Eric Nelson
Founder & CEO, Augment LLC

Isaac Gelman
Apprentice, Augment LLC | Student, University of Southern California

Join the Conversation #WolframTechConf

Eric Nelson

3x WTC

BS Electrical Engineering, University of Minnesota

PAST: Thin films engineer
Epitaxial crystal growth process at LED substrate startup (MN)

PAST: Classroom teacher: Technology & Entrepreneurship

Founded Augment LLC (2015)
Train programmers and build cloud-based software applications

PRESENT: Sr Software Engineer at MS3, Inc. 
Building enterprise IoT and other enterprise cloud and edge.

Isaac Gelman

1x WTC

Studying Applied Math at University of Southern California

Programmer apprentice with Augment LLC since 2017

Member of CAIS at USC
(Center for AI in Society)

The cognitive meal being served

Fragrance: The problem to solve
Will be fast... 3 min / ~12 slides = 15sec/slide

Appetizer: Long-term objectives, quick-history, training overview

Entree: Isaac’s experience & Apprenticeship Model detail

Dessert/Pudding: Q&A

Software is finally actually eating the enterprise world

Enterprise “Digital Transformation” is reaching critical mass
ERP <> IoT <> Internal SaaS <> Customer-facing apps <> Custom Apps...

Big Data is common
Volume, Velocity, Variety, Value, and Veracity
In 2017, Amazon’s Prime Day handled 12.9M events.  Per second.
100MM+ catalog items

Business managers need “handlebars” for it.

The “handlebars” for data is computational thinking.

We actually need WAY more and better data.

Continuous software development
customizing SaaS, building integrations & data pipelines, mobile, etc.

We’re mistreating “Computer Science” education

Crash courses are not a real strategy.

Harvard’s CS50 course (10 weeks) covers:
Binary, ASCII, Logic & Processors, Memory, Algorithms, Pseudocode, Syntax, Variables, Data Types, Operators, Boolean Expressions, Conditionals, Loops, Compiling, Functions, Arrays & Strings, CLI, Libraries, Types, Casting, Debugging, Search & Sort Algorithms, Complexity, Unsolvable Problems, Models & Simulations, Software Design Principles, Encapsulation, Recursion, Numerical bases, File IO, Images, Version Control & Git, Internet, IP, DNS & DHCP, Routing, TCP/IP, HTTP, Trust Models, Security, HTML & CSS, Python, SQL, Model-View-Controller, JavaScript, AJAX, AI & ML, VR & AR, IDE... and more.

Also a CS50 for MBAs...

It’s not about “coding”

22,249,173,963 lines of code written by 31 million students!

Yes, big numbers... BUT

LOCs is not a metric of success. For anyone. Doing anything.

Q: What have they understood?

Code is a tool.  What matters is what you do with it.

A breeze of change?  (stats from August 2018)

Highlights

2017 -> 2018 In-Person vs Online Growth

Dynamic@bcFTGrowthChart

Online is typically longer and less $$$

Training periods in general are trending longer

Highlights

2017 -> 2018 New Job-Seekers vs Corporate Training

Dynamic@bcTypeGrowthChart

Job-Seekers trained in generalized “Junior Dev” template

Corporate Training is more likely to be specialized to a role.

Highlights

2013 -> 2018 New Job Seeker student growth rates

Dynamic@bcFTJSYoYGrowthChart

Still growing but much slower.

Assertions...

Companies want Sr Devs (corp), not Jr Devs (job-seeking)

Scalable training -> Online

For-profit companies focused on post-schooling.(catch-up)

“Do-good” initiatives generally missing the mark.

US Public Education is... behind.  
Problem: Salary. If you can teach computational thinking, you probably won’t work in elementary education.  With salary-differential, such schools can be thought of almost as computational thinking deserts.

Computer-Based ________ courses may be best for school.
SME professionals + cooperating teachers.  “co-teaching”
Start in primary school.
Computational thinking must be 1st-class subject.  Needs a better name.
Wolfram is the best language to do it.  No question.

Production languages aren’t best for learning.
The bias toward Java or C++ may be a primary reason computational thinking hasn’t penetrated K12.
Learners aren’t optimizing for performance.

Computational thinking not just for pro software engineers

Our big objective: Automated on-ramps to SWE expertise

Many branches off CT... SWE is just one.

Long-term swe apprenticeships in parallel with schooling.
(Notable so it will be recognizable to colleges and prospective employers.)

Networked skills interact algorithmically -> optimize for growth.

Automated assessment of capability feeds interaction algorithm.
(“listens in” on operations and infers demonstrated capability from behavioral anchors)

Blockchain tracking of growth/mentoring/tutoring operations.  
All growth is “badgeable” -- badge points to operational transcript.  UX is critical.

Ever-expanding hooks into real-world, useful projects.
Crowd-sourced competitions with prizes, e.g. Kaggle (Google), DevPost, ...
Contracted projects (MBA programs do this) -- suitable for a subset of apprentices.

Even if superintelligence, humans will still need expertise.

Maybe superintelligent AIs will train humans for entertainment

Hopefully like this...

Not this...

Augment’s Quick-(pre)History

2013: Eric’s 1st programmer training pilot
Ruby on Rails -- using online training courseware (Treehouse)

2013-2015: Eric teaches programming classes at a charter school
Scratch & Python -- using text-based courseware (Learn Python the Hard Way)

2015: Officially founded Augment LLC
Mathematica -- using Wolfram training materials

2016

Fall 2015: Cold-called Abby Brown about teaching Mathematica

Spring 2016: Began training first cohort of TPHS seniors
5 students -- Single team building a Puzzle Game

Summer 2016: First cohort of juniors
20+ students -- Multiple teams doing scientific modeling, data analysis, etc.

Presented at WTC16

Training Principles Overview

Projects target real accomplishment: Useful products.

Insightful conceptual understanding -> procedural competence

Focus first on expression of intent -> then translation into code

Foster collaboration by creating “thin interfaces” between people -- i.e. Reduce the cost of interaction

Everyone builds their own learning algorithm

My experience training with Augment

In my own words ...

Augment model

Fundamental engineering principles

A path to expertise

Intro and comfort with Wolfram Language
	 
Abby Brown' s high school math and programming classes

More than Mathematica

Framework for pursing a learning project

Group work -> team lead

Small tasks -> projects

Projects

1. Algorithmic trading

2. Background subtraction

3. Machine generated artwork: ARTificial Intelligence

Project 1: Algorithmic Trading

Algorithmic trading concept map

WikipediaData’s links and back links.

Use a threshold variable to remove concepts that don’t appear often enough.

Visualize the concept map several ways using Graph[]

Graph[algoTradingLinks,VertexLabels->Placed["Name",Tooltip],VertexStyle->{"Algorithmic trading"->Red},GraphLayout->"BalloonEmbedding",VertexSize->1]
CommunityGraphPlot[algoTradingLinks,VertexLabels->Placed["Name",Tooltip],CommunityBoundaryStyle->{Red},VertexStyle->{"Algorithmic trading"->Red}]
Graph3D[algoTradingLinks,VertexLabels->Placed["Name",Tooltip],VertexStyle->{"Algorithmic trading"->Red},GraphLayout->"RadialEmbedding",DirectedEdges->False,PerformanceGoal->"Speed",VertexSize->.4];

Project 2: Background Subtraction

Lesson for CT@TP

ListAnimate[videoImagesBW,7]

Convert these images to grayscale

The video as a matrix (idea from fast.ai Computational Linear Algebra course)

MatrixPlot[M, ColorFunction->GrayLevel]

Get the background

background=imageRestore[Median/@M]

Magnify@Manipulate[
origImg=ImageResize[videoImages[[fnum]],320];

Row[{Column[{origImg,
background-frame[fnum],
Binarize[background-frame[fnum]]
}],
HighlightImage[ImageAdd[origImg,ColorReplace[ImageAdd[origImg,ColorNegate@Binarize[background-frame[fnum]]],White->Black]],Binarize[background-frame[fnum]]]
}," "],

{fnum,1,Length@videoImages,1}
]

Projects

1. Algorithmic trading

Sample of the entry point into large project
Access to computable data

2. Background subtraction

Visualizing data & matrices

3. Machine generated artwork: ARTificial Intelligence

Project 3:
ARTificial Intelligence:
Modeling an Image as a Function (Wolfram’s What’s New 11.3)

TPHS Advanced Topics ‘17-‘18
Math Open House Final Project 
By Isaac Gelman

Design Intent

Build artificial intelligence that can effectively predict RGB values at a specifically indexed location. The neural network itself is trained on one image. The image is pre-processed: each pixel location in the image is labeled with its respective R, G, and B values.

Initialization and Code

A rescaling function, newIndex, takes a pixel location and rescales it to fall onto the continuum: {-1,-1} to {1,1}. {-1,-1} is the top-left corner; {1,1} is the bottom right corner.

newIndex[x_,y_,dim_]:={(((x-1))/(dim[[2]]-1))*2-1,((y-1)/(dim[[1]]-1))*2-1};

For example:

newIndex[1,1,{75,50}]
newIndex[50,75,{75,50}]

The indexedPixels function takes an image as an input, and labels each location index value (rescaled to {-1,-1} to {1,1}, see above) with the appropriate vector of RGB values. Note that this function makes several global variable directions, namely width, height, and dim.

indexedPixels[img_]:=Module[{values,indexes,dim,width,height},
{width, height} =dim= ImageDimensions[img];
indexes=Catenate@Table[newIndex[row,col,dim],{row,1.,height},{col,1.,width}];(*indexes*)
values=ImageData[img]//Catenate;(*pull RGB values*)
Table[indexes[[i]]->values[[i]],{i,1,Length[values]}](*label index with RGB*)
];

The solution function uses a neural net that outputs the A.I.’s guess at recreating the picture. Note: some global variables are used in the function for ease of readability when using solution.

solution[net_,dim_]:=Magnify@Image[Table[net[newIndex[row,col,dim]],{row,1,dim[[2]]},{col,1,dim[[1]]}]];(*reconstruct image by asking the neural net its prediction for each index*)

The net function trains the neural network with inputs of: a set of training data, the layer design, and the maximum number of rounds to train. The TrainingProgressReporting option outputs an intermediate version of the solution over some interval.

net[trainD_,layers_,maxRounds_,reportDim_]:=Module[{network},
network=NetChain[layers,"Input"->2];
NetTrain[network,trainD,MaxTrainingRounds->maxRounds,
TrainingProgressReporting->{
Column[{
solution[#Net,reportDim],
solution3DRed[img,#Net,reportDim]}
]&,
"Interval"->Quantity[2,"Rounds"]}]
]

3D visualization function, red channel only. Overlay the discrete training points (“ground truth”) with the surface representing the net’s prediction.

solution3DRed[img_,net_,dim_]:=Show@{ListPointPlot3D[{#[[1,1]],#[[1,2]],#[[2,1]]}&/@indexedPixels[img],ColorFunction->Function[{x,y,z},Darker[Red,1-z]],PlotRange->All],
Plot3D[net[{row,col}][[1]],{row,-1,1},{col,-1,1},PlotRange->All,ColorFunction->Function[{x,y,z},Darker[White,1-z]]]};

Function to resize an image automatically. The maximum dimensions (either or height or width) will have a value no higher than the the maxDim parameter.

heightRatio[img_]:=ImageDimensions[img][[2]]/ImageDimensions[img][[1]]
resizeMax[img_,maxDim_]:=If[heightRatio[img]≥1,
ImageResize[img,{Round[maxDim/heightRatio[img]],maxDim}],(*if the img is tall, divide the width by the height ratio*)
ImageResize[img,{maxDim,Round[maxDim*heightRatio[img]]}]](*if the img is wide, multiply the height by the ratio*)

newNet[trainD_,layers_,maxRounds_,reportDim_,img_]:=Module[{network,graphicsCache},
graphicsCache={};
network=NetChain[layers,"Input"->2];
{NetTrain[network,trainD,MaxTrainingRounds->maxRounds,
TrainingProgressReporting->{
Module[{solution1,solution2},Column[
solution1=solution[#Net,reportDim];
solution2=solution3DRed[img,#Net,reportDim];
AppendTo[graphicsCache,{solution1,Rasterize@solution2}];
{solution1,solution2}
]]&,
"Interval"->Quantity[2,"Rounds"]}],
graphicsCache}
]

Look only at the red values, and plot them in 3D.

The red points and a surface

pointsPlot
pointsSurface

usaDim={width,height}=ImageDimensions[usaImg];

{usaNet,usaCache}=newNet[
indexedPixels[usaImg],(*training data*)
{100,Ramp,100,Ramp,100,Ramp,Tanh,100,Ramp,50,Tanh,3},(*layer design*)
500,(*max Rounds*)
Round[1.2*ImageDimensions[usaImg]](*reporting dimensions*),
usaImg
]; 

solution[usaNet,usaDim]
solution3DRed[usaImg,usaNet,usaDim]

Other personal projects are to answer questions I have

Can weights be used to create a new input that will return a one-hundred percent match in an MNIST neural network?

Can a convolution with a hard-coded kernel accurately identify edges? (For example, only diagonal edges)

Can a Mathematica classifier effectively identify how many fingers I hold up in front of my webcam?

Is deep learning == curve fitting?

Moving forward

Center for Artificial Intelligence in Society
(University of Southern California)

AI for social good
	Curriculum stage : Keras in Python
	Preserving endangered language with phoneme recognition: Ladin
	Forecasting rainfall in drought areas
	Pneumonia diagnosis
	Multi-modal data auto encoder comprehension

Computational intelligence orgs at USC

TAMID Group

Continuing projects

Image to LATEX code: Alex Li
Combine knowledge from all of CAIS, fast.ai, Wolfram NNs, Deep Learning

Increasing capability

Training Principles Detail

Projects target real accomplishment: Useful products.
Creates both a moving stimulus stream & guard rails on thinking.
Stimulus Stream: Problem evolving in real time, Start my life’s work today -- right now, This is important to me
Guard rails: Can’t go alone, People will see & care about the results, Real problems demand real creativity

Insightful conceptual understanding -> procedural competence
Primary reason to start while still in school -- procedural competence is how you get a job and it’s what you get paid for, so that becomes the focus after school.

Focus first on expression of intent -> then translation into code
New learners don’t know the Wolfram notation, syntax, functions, or functional programming best practices.  First learn to externalize models with natural language.

Foster collaboration by creating “thin interfaces” between people -- i.e. Reduce the cost of interaction
Clear, unmistakable communication protocols: Air-traffic control tower.
Shared understanding of essential domain language shorthand: Everybody knows what I mean when I say “Air-traffic control tower”
Standardized, transmissible documentation templates: Every code stub contains Context, Designer’s Intention, etc.
Conflict is a pathway for improving mental models.
Document meeting essentials and store for future use in searchable database.
Mentors exemplify communication patterns for tutors and learners.

Everyone builds their own learning algorithm
Clear expression of the accomplishment / objective.
Deconstruction of the accomplishment into components.
Sequencing components along a critical path -- most important / challenging first: the “heart” of the problem.
Searching for Prior Art, assessing its utility, and synthesizing understanding.
Test understanding via Transfer to simple, low cog-load context.
Assemble solution structure from prior-proven conceptual primitives.

Progression of a “training season”

1: Profile the team to define the “big picture” constraints & aims:
Starting capabilities, Prior accomplishments, Personal aspirations, Strengths & Weaknesses...  Projects are always dependent on the people within the team.

2: Immediately begin individual operations -> big picture aims:
Individual entry to technical and subject matter competencies based on assessed ZPD
Immediately begin “reeling in” and cataloging the prior art for the domain.
Learning efforts produce artifacts (e.g. progressive examples).
Use simple, easy-to-use tools for tracking early project operations. (low barrier to entry)

3: Gradual orchestration & Early specialization
Conductor / Team Leader monitors and “assists” interactions (assisted via a “dashboard” of team member behavioral data)

4: Initiate DevOps tooling
Begin to adopt better tools for project management, version control, & CICD.

5: Jigsawed Team of Specializations
Ongoing, continuous build-out of training artifacts

6: Present working prototype(s)
This is a “guard rail” on thinking and action.
This should happen as early as possible.

7: Systematic improvement

8: Final Presentation

9: Wrap-up & Hand-off

Why Mathematica as training language?

Because Mathematica is not about coding -- It’s about manipulating expressions.

Minimizes the distance between intention and computation.
New programmers should not be concerned about OOP design patterns

If all else fails, they can at least use Mathematica for their homework...

A fine distinction between Mentors & Tutors

Mentor-interaction makes the learner “wise”
Deeply insightful examples, analogies, illustrations, and demos tuned to learner’s background and mentor’s experience.
Concerned with the “bigger picture” view of personal development.
Substantively change learner’s cognitive structure with each interaction

Tutor-interaction makes the learner “technically competent”
Propagate best practices for a particular language, tool, subject matter, etc.  (High SNR knowledge distillation)
Concerned with success of specific project & operations.

Example Training Context

Bird Brain Game

File Header

Version: 0.5.10.3
Filename: BBGame_Stubs_v0.5.10.3.nb
Last Author: Alex Krotz
Date: 5/3/2016

Designer’s Intent

Summary
The Bird Brain Game is a simple puzzle game designed to assess the intelligence of birds --or in our adaptation here-- humans.
First a set of n colored squares is created where each square from left to right is given an arbitrary and ascending integer value. 
The Bird is trained to recognize, from memory, whether 2 colors, presented as colored squares as in the original set, chosen randomly, are in canonical order from another larger set n where each color had been arbitrarily given a set of ascending values. The presented pair may or may not be in ascending order but one will be greater than the other.

How it works
Colors are randomly assigned ordinal values within a set of n, 1 to n. (e.g. 1 is Red, 2 is Green, 3 is Yellow)
	For this session, this random assignment becomes the canonical sequence of the set.
The bird is trained to recognize the canonical color order via one-at-a-time display of “in order” color pairs {lesser, greater}, called “Training Pairs”
	e.g. {{Green, Yellow}, {Red, Yellow}, {Red, Green}}
When the bird has studied the training pairs for a time period, the bird is then tested.
The test consists of a random color pair, called “Testing Pair”, may or may not be in order within the original set.  
The bird recalls canonical color order from memory of the canonical set.
The bird indicates whether the Testing Pair is true to canonical order
	e.g. Bird indicates {Green, Red} is NOT “in order”
The game then records and displays the number of times the bird is correct vs. incorrect.
	(In the future, we will analyze this data across various users)

COMPLETED STUBS:
Color Rules: Randomly associate numbers to colors, up to n colors
Training Pair Generator: randomized table of all training pairs for n colors
Display Training Pairs: slider bar to scroll through training pairs, displayed as colored squares. 

REMAINING STUBS:
Record Training Time: measure time used to study Training Pairs
Display Testing Pair: a randomized combination of 2 numbers, 1 to n
User Respond to Testing Pair: Toggle True or False, if Testing Pair is accurate to canonical order or not
Record Testing Time: Measure how much time user takes to respond to Testing Pair
Results Display: number of correct vs. incorrect responses

Instructions to evaluate notebook

Navigation Bar -> Evaluation -> Evaluate Notebook

Op List

Repairing Psuedocode/Designer’s Intent

- Record Training Time: Pseudocode
- Display Testing Pair: In line comments
- User Response to Testing Pair: In line comments
- Testing User Interface: Pseudocode, in line comments, designer’s intent
- Results Display: Pseudocode
- Data Exports: Pseudocode, in line comments, designer’s intent

Improving User Interface

- Hide data until “finish testing” is clicked, then show all the data at once
- After the user finishes testing, show them their results (number the questions and tell the user if they were correct or incorrect)
- Include a “New Game” button so that the user could play a new game after finishing
- “New Game” button could alos export the data, so that the lists are cleared for the new game
- The UI could be made intuitive by presenting a set of instructions, then transitioning to training then testing smoothly rather than in a column where the buttons are displayed simultaneously.

Data Visualization

- Data lists needed: time spent on each testing pair, results of the testing pair (correct v incorrect)
- Each session needs a unique name and total time for the session
- The cannonical order of the colors and each testing pair must be recorded
- joseph is working on GRAPHING the data; would be interesting to see data added to the graph as people play it throughout the math open house night
-Graph a specific user’s accuracy relative to time spent testing
-Visualization of old programs should be through a separate program. This way we can skip user to user without having too much code in the original program. This could be incorporated into a single program, however i dont know if it would be as efficient. The data that has to be recorded is the user ID, canonical order key, testing pairs presented, and the “distance” of the testing pairs.

Data Export

- Data archive needs structure to allow for multi user/version 
- Data needs to be stored in a single file that can be consistently accessed for import/export
- It would be cool if the data could be exported as a csv file, just raw numbers can be used when exporting data

Code Stubs

Color Rules, v1

Designer’s Intent

Bird Brain Game Big Picture
Colors are randomly assigned ordinal values, 1 to n.
A bird is then trained to be able to recognize whether 2 colors, chosen randomly, are “in order” or not.
This stub generates that color order.

Stub Design:
Generate a table of rules converting numbers 1 through n to random, high-contrast colors.

SuperFunction Design

Final output is a random set of color rules.
Input is the number of colors.

Pseudocode

Initialize list of high-contrast colors. (for now, 12 colors in list)
Initialize number of colors used in gameplay, gameNumColors. (default is 6)

Randomize the color list.
Create function to generate rules, converting numbers to colors, based on gameNumColors.
Generate a set of color rules for the given game.

SuperFunction Pseudocode

Create set-delayed function colorRules with input gameNumColors.
Initialize color list.
Create a random sublist of colors of size gameNumColors.
Output the rules generated by colorRulesGenerator.

Code v1 [Deprecated]

(* Deprecated,
(* Initialize masterlist of colors *)
colorList = {Red,Yellow, Green, Blue, Black, Orange, Cyan, Magenta, Brown, White, Purple, Pink};
(* Initialize number of colors to play game with *)
gameNumColors = 6 ;
*)

(*
(* Randomize a sublist of n colors from colorList, n = gameNumColors *)
colorListRandom = RandomSample[colorList[[1;;gameNumColors]]];
(* Function to generate a list of rules based on randomized color list *)
colorRulesGenerator[numColors_]:=Table[i-> colorListRandom[[i]], {i,numColors}]
(* Instrumentation, Generate color rules for a game with 6 colors*)
 colorRulesGenerator[gameNumColors]
*)

Code v2

(* Function to generate a list of rules based on randomized color list *)
colorRulesGenerator[numColors_]:=(
colorList = {Red,Yellow, Green, Blue, Black, Orange, Cyan, Magenta, Brown, White, Purple, Pink};
(* Initialize number of colors to play game with *)
gameNumColors = numColors;
(* Randomize a sublist of n colors from colorList, n = gameNumColors *)
colorListRandom = RandomSample[colorList[[1;;numColors]]];
Table[i-> colorListRandom[[i]], {i,numColors}]
)

colorRules

Training Pair Generator, v2

Designer’s Intent

Bird Brain Game Big Picture
The bird learns the correct color order via a random sequence of color pairs, which are “in order”, {Lesser, Greater}.
This stub generates a randomized table of those color pairs, called Training Pairs.

Stub Design:
Generate a randomized table of all Training Pairs for any number of colors (via gameNumColors), converted to colors (via colorRules).

SuperFunction Design

Input is gameNumColors.
Output trainingPairs.

Pseudocode

Generate Table of all combinations of Training Pairs, e.g. {1,2}, {1,3}...{3,5},{3,6}...{n-1,n}
Randomize Table of Training Pairs
Convert Training Pair numbers to colors via colorRules

SuperFunction Pseudocode

Create a SuperFunction trainingPairsColors with input gameNumColors.
Create training pairs from the numbers that were assigned to colors by colorRulesGenerator.
Convert training pairs from sets of numbers back to sets of colors.
Output pairs of colors in canonical color order.

Code v1 [Deprecated]

(*Deprecated,
(* Function to generate Table of Training Pairs, based on gameNumColors *)
trainingPairs= Partition[Flatten[ (* formats output as a list of pairs *)
Table[ (* Scrolls through i, from 1 to gameNumColors-1 *)
Table[{i,j},{j,i+1,gameNumColors}] (* Generates Training Pair {i, j}, where j goes from i+1 to n *)
,{i,gameNumColors-1}]
],2]
*)

(* Randomize the Table of Training Pairs *)
trainingPairsRandom=RandomSample[trainingPairs]

(* Convert trainingPairs from numbers to colors *)
trainingPairsColors=trainingPairsRandom /.colorRulesGenerator[12]

Code v2

trainingPairsColorsGen[gameNumColors_]:=RandomSample@(* Randomize the Table of Training Pairs *)
Partition[
Flatten[ (* formats output as a list of pairs *)
Table[ (* Scrolls through i, from 1 to gameNumColors-1 *)
Table[{i,j},{j,i+1,gameNumColors}] (* Generates Training Pair {i, j}, where j goes from i+1 to n *)
,{i,gameNumColors-1}]
],2]/.colorRules

trainingPairsColorsGen[5]

Display Training Pairs, v1

Designer’s Intent

Bird Brain Game Big Picture
The bird learns the correct color order via a random sequence of color pairs, which are “in order”, {Lesser, Greater}.
This stub scrolls through the randomized table of training pairs.

Stub Design:
Show Training Pairs 1-at-a-time, using a SlideView, as 2 side-by-side colored squares, with color sequence determined by Training Pair Generator.

SuperFunction Design

Input gameNumColors.
Output trainingPairs in a SlideView.

Pseudocode

SlideView display of all Training Pairs:
	Show 2 same-size squares, side-by-side, colors defined by Training Pair, selected through SlideView

SuperFunction Pseudocode

Create a SuperFunction trainingPairsDisplay with input gameNumColors
Create training color pairs with trainingPairsColorsGen
Display training color pairs in a SlideView

Code v1 [Deprecated]

(*Deprecated,
trainingPairsColors=trainingPairsColorsGen[4]*)

(*Deprecated,SlideView[Map[Graphics[{
trainingPairsColors[[#,1]],Rectangle[{0,0},{1,1}],
trainingPairsColors[[#,2]],Rectangle[{1,0},{2,1}]}]&,Range[Length[trainingPairsColors]]],AppearanceElements->{"PreviousSlide","NextSlide","SlideTotal"}]*)

Code v2

trainingPairsDisplay[gameNumColors_]:=(
trainingPairsColors=trainingPairsColorsGen[gameNumColors];
(*sets list of color pairs with a specific number of colors*)
SlideView[Map[Graphics[{
trainingPairsColors[[#,1]],Rectangle[{0,0},{1,1}],
trainingPairsColors[[#,2]],Rectangle[{1,0},{2,1}]},ImageSize->400]&,Range[Length[trainingPairsColors]]],AppearanceElements->{"PreviousSlide","NextSlide","SlideTotal"}]
)

trainingPairsDisplay[5];

Toggling a Manipulate: A button that starts a manipulate [Deprecated]

Designer’s Intent

Bird Brain Game Big Picture
By using a button to start the manipulate, it is easier to define when the game starts and purpose of a button is to define events such as start of game and when the user is ready.

Stub Design:
Creates a button which starts a chain reaction. In the manipulate another button,testPairStart, is created which creates another button that indicates that training is done. The button testPairStart, should create another manipulate for the testing environment.

Superfunction Design

No input
Function creates “Start Training” Button, which then creates “Start Testing Button

Pseudocode

Initalized boolean values, trainingPairStart and testPairStart to False. 
Create a Button called start which sets trainingPairStart to be True and starts the training session.
Once the Start Training button is clicked, it toggles the manipulate and creates another button called Start Testing.
When Start Testing is clicked it clears the training pairs and prints out “Training Complete”

Code v1 Deprecated

(*
trainingPairStart=False;
testPairStart=False;
Dynamic[If[testPairStart,"Training Complete",Button["Start Training",trainingPairStart=True]]]

Dynamic[trainingPairStart]
Dynamic[testPairStart]

Manipulate[If[trainingPairStart,Button["Start Testing",{trainingPairStart=False,testPairStart=True}]],{x,0,10}]
*)

Code v2 Deprecated

changes in v2: 
	-deleted dynamic showing of traningPairStart and testPairStart
	-deleted manipulate, and made the Start Testing Button dynamic

(*
startTrainingButton:=(trainingPairStart=False;
testPairStart=False;
Column[{
Dynamic[
If[testPairStart,"Training Complete",Button["Start Training",trainingPairStart=True]]],

Dynamic[If[trainingPairStart,Button["Start Testing",{trainingPairStart=False,testPairStart=True}]],{x,0,10}]
}]
)
*)

(* startTrainingButton *)

Record Training Time: measure time used to study Training Pairs

Designer’s Intent

Bird Brain Game Big Picture:
The game records the time taken between the beginning and the end of training in order to see how long it takes the bird to memorize the color orders. 

Stub Design:
The game using system time, outputs the difference between the start of the game and the end of the game.
Start of game is when a button trainingPairStart is clicked.
End of game is the user feels that he/she is ready and clicks on another button testPairStart.

Superfunction Design

“Start Training” Button produces starting time
Starting time data is input into superfunction

Pseudocode -- ??? Improve Pseudocode

Once the Training button is toggled, it records the starting time and once Testing button is toggled it records the ending time and returns the difference in values.

Code v1 [Deprecated]

(*
(*Initalization*)
trainingStart=False;
testingStart=False;
trainingStartTime;
trainingEndTime;

(*Instrumentation*)
Dynamic[trainingStartTime]
Dynamic[trainingEndTime]
Dynamic[timeSpentTraining]

(*Creates the Start Training button*)
Dynamic[If[testingStart,"Training Complete",Button["Start Training",{trainingStart=True,trainingStartTime=Now}]]]

Manipulate[
If[trainingStart,
Button["Start Testing",
(*Used to record time*)
{trainingEndTime=Now,timeSpentTraining=trainingEndTime-trainingStartTime ,trainingStart=False,testingStart=True}
]],
(*Just a dummy control to complete manipulate*)
{x,0,10}]
*)

Code v2

changes in v2:
	-deleted dynamic showing of trainingStartTime, trainingEndTime, and timeSpentTraining
	-deleted manipulate, and made the Start Testing Button dynamic instead
	-made timeSpentTraining only show after Start Testing Button is clicked

timeTraining:=(
(*Initalization*)
Clear[trainingStartTime,trainingEndTime, testingStartTime,testingEndTime];
trainingStart=False;
trainingEnd = False;
testingStart=False;
testingEnd = False;
showTrainingPairs=False;

Column[{
Dynamic[(*Start Training button -> On-click becomes "Training In-Progress" -> When Start Testing clicked becomes "Training Complete" *)
If[trainingStart ===True ,
If[testingStart===False,
"Training In-Progress",
"Training Complete"
],
If[trainingEnd === False,
Button["Start Training",{
trainingStart=True,
trainingStartTime=Now, (* Records Training Start Time *)
showTrainingPairs=True}(* Turns TrainingPair SlideView on *)
],
"Training Complete"
]
]],
Dynamic[(*Start Testing button -> On-click becomes "Testing In-Progress", Sets "Training In-Progress" to "Training Complete" *)
If[trainingStart ===True ,
If[testingStart===False,
Button["Start Testing",
{trainingEnd = True,
trainingEndTime=Now, (* Records Training End Time *)
testingStart=True, 
correctAnswers = {},
incorrectAnswers = {},
testingStartTime=Now,(* Records Testing Start Time *)
showTrainingPairs=False}(* Turns TrainingPair SlideView off *)
],
"Testing In-Progress"
]
]],
Dynamic[If[testingStart,timeSpentTraining]]
}]
)

timeTraining

Display Testing Pair: a randomized combination of 2 colors

Designer’s Intent

Bird Brain Game Big Picture:
The testing portion of the game begins and the bird is presented with a testing pair that may or may not be in canonical color set order.

Stub Design:
The testing pair is then displayed to assess the bird’s memory of the canonical color set order. 
The testing pair consists of two random color swatches based on two random integers less than gameNumColors using RandomInteger. 
The two random integers are displayed as color swatches using colorRules

Superfunction

Pseudocode

Within a single function, gentestPair:
Generate random integer between 1 and gameNumColors
Generate second random integer, but exclude the first random integer from the set of numbers the second random integer is chosen from
Generate testPair, the two random integers put together into a list
Substiute the integers using colorRules
Display two colors as colored rectangles in a row

Code v1 -- ???NEEDS In-line code comments

genTestPair:=(
firstRandom=RandomInteger[{1,gameNumColors}];
(*excluding firstRandom to avoid repeating colors*)
secondRandomChoices=DeleteCases[Range[gameNumColors],firstRandom];
secondRandom=RandomChoice[secondRandomChoices];
testPair={firstRandom,secondRandom};
testPairColor={firstRandom,secondRandom}/.colorRules;
Graphics[{
(* pairSelect scrolls through each Training Pair in trainingPairColors *)
testPairColor[[1]],Rectangle[{0,0},{1,1}],
testPairColor[[2]],Rectangle[{1,0},{2,1}]
},ImageSize->400])

colorRules = colorRulesGenerator[4]
genTestPair
testPairOrder

User Respond to Testing Pair: Toggle True or False, if Testing Pair is accurate to canonical order or not

Designer’s Intent

Bird Brain Game Big Picture:
The bird’s memory is tested by allowing the bird to decide whether the test pair is “True” to the color order or “False”

Stub Design:
Bird has two choices, true or false, to indicate whether the bird thinks the given testing pair is in canonical order.
A user clicks one of two buttons to indicate whether the pair is in canonical order. 
The user’s response, true or false, is compared to the actual relationship between the values of the colors of the pair.

Pseudocode

First button assigns value “True” to testResponse 
Second button assigns value “False” to testResponse
testPairOrder compares first element < second element in testPair
testResponse is compared to testPairOrder
	If true, increment numCorrect. If false, increment numIncorrect

Code v1 [Deprecated]

(* Button["True",testResponse=True] *)

(* Button["False",testResponse=False] *)

(* Dynamic@testResponse *)

(* answer = Dynamic[testPairOrder=testPair[[1]]<testPair[[2]]] *)

Code v2 -- ???NEEDS In-line code comments

(* Initialize answers lists -- ??? comment needs improvement. *)
checkAnswer := (
testPairOrder:=testPair[[1]]<testPair[[2]];
If[testResponse===testPairOrder,
AppendTo[correctAnswers,{1,testPair,Now}],
AppendTo[incorrectAnswers,{1,testPair,Now}]
]
genTestPair 
)

Testing User Interface -- ??? NEEDS Designer’s Intent / Pseudocode

Code v1 -- ???NEEDS In-line code comments

SetDirectory[NotebookDirectory[]];

showTestPair :=Column[{genTestPair,
Button["True",{testResponse=True, checkAnswer,AppendTo[testPairList,testPair]}],
Button["False",{testResponse=False,checkAnswer,AppendTo[testPairList,testPair]}],
Button["Finished",{testingEndTime=Now,{totaldata}>>>"BirdBrainDataArray.txt",correctAnswers={},incorrectAnswers= {}}], (* Player must change file path to desired location *)
Button["Import Data", {testImport = Get["BirdBrainDataArray.txt"]}]
}]

Record Testing Time: Measure how much time user takes to respond to Testing Pair [Deprecated]

Designer’s Intent

Bird Brain Game Big Picture:
The game records the time taken between the beginning and the end of testing for each pair in order to see how quickly the bird can determine whether or not the testing pair is a true or false match to the color order. This will demonstrate how well the bird memorized the training pairs. 

Stub Design:
Records the testing time for each test pair. 
Records difference in time between when the user presses the “Start Testing” button and the user presses the “True” or “False” button.
There may be race condition between two operations assigned to the “True” and “False” buttons, the timeSpentTesting and the newly instantiated testingStartTime.

Pseudocode

“Start Testing” button, on click, assigns a time object “Now” to testingStartTime.
“True” or “False” button, on click, 
	assigns a time object “Now” to testingEndTime.
	assigns the difference between testingEndTime and testingStartTime to timeSpentTesting
	calls the genTestPair function.
	assigns a time object “Now” to testingStartTime
“End Testing” button, on click, will display results for the sequence of test pairs(see Results Display).

Code v1 Deprecated

(*
timeSpentTesting := testingEndTime-testingStartTime;
timeAssignments := (testingEndTime = Now;
testingStartTime= Now;
genTestPair)
*)

(*
(*Instrumentation*)
Dynamic[testingStartTime]
Dynamic[testingEndTime]
Dynamic[timeSpentTesting]
Dynamic[timeAssignments]
*)

(*
(*Creates the Start testing button*)
Dynamic[If[testingStart,"Start Testing",Button["Start testing",{testingStart=True,testingStartTime=Now}]]]

Manipulate[
If[testingStart,
Button["Start Testing",
(*Used to record time*)
{testingEndTime=Now,timeSpenttesting=testingEndTime-testingStartTime ,testingStart=False,testingStart=True}
]],
(*Just a dummy control to complete manipulate*)
{x,0,10}]
*)

Results Display: number of correct vs. incorrect responses -- ??? NEEDS Pseudocode / Code

Designer’s Intent

Bird Brain Game Big Picture:
The results of the testing will be displayed, showing the correct and incorrect answers as well as the time spent on each testing question.

Stub Design:
This stub stores the testing time, false answers, and true answers in order to store information

Pseudocode

Total all records of correctAnswers and incorrectAnswers and display in a column.
Use StringRiffle to combine total with a label, e.g. “1 Correct”.
???Can also show Answer Rate as an average of differences of time stamps (e.g. Average of all Timestamp[n] - Timestamp[n-1])

Code

resultsDisplay :=Column[
{
StringRiffle[{Total[correctAnswers[[All,1]]],"Correct"}], (* Outputs a string with total Correct *)
StringRiffle[{Total[incorrectAnswers[[All,1]]],"Incorrect"}](* Outputs a string with total Incorrect *)
}
]

Data Visualization -- NEW!

Designer’s Intent

Display the amount of time between each answer in a ListLinePlot

Pseudocode

Initialize testImport variable.
Extract the Time Objects for each answer from the user’s imported performance data.
Calculate the difference between each respective Time Object.
Plot the list of differences in ListLinePlot.

testImport = testImport={{ ,,,,{},{{,{,},}},{{,}}}};
answerTimesPlot:=(answerTimestamps=testImport[[1,5,All,3]];
timestampDiffs=Table[UnitConvert[answerTimestamps[[i+1]]-answerTimestamps[[i]],"Seconds"],{i,Length[answerTimestamps]-1}];
ListLinePlot[timestampDiffsTooltips,PlotMarkers->{●, 28},ImageSize->Large,PlotLabel->"Time taken for each answer (in seconds)",AxesLabel->Automatic,PlotMarkers->testPairSequence[[1,All]]])

Add color pair tooltip to list plot marker -- NEW!

Designer’s Intent

On hover over a Plot Marker, show the test pair for that question.

Pseudocode

Get the sequence of Test Pairs into a list.
Convert to color pairs.
Riffle the timestamp diffs with respective testpairs.
Apply a Tooltip to each timestamp-testpair set.
Plot Each point in ListLinePlot.

testPairSequence:=testImport[[1,7]]/.colorRules
pairsWithTooltips:=Partition[Riffle[timestampDiffs,testPairSequence],2]
timestampDiffsTooltips:=Table[Tooltip[pairsWithTooltips[[i,1]],Row[pairsWithTooltips[[i,2]]]],{i,Length[pairsWithTooltips]}]

(* ListLinePlot[timestampDiffsTooltips,PlotMarkers->{"◆", 18},ImageSize->Large]*)

Data Export Stub -- ??? NEEDS Designer’s Intent / Pseudocode

Code v1 -- ???NEEDS Inline code comments

testPairList = {};

totaldata := {trainingStartTime,trainingEndTime,testingStartTime,testingEndTime,correctAnswers,incorrectAnswers,testPairList};

Final Application [Deprecated]

(*
(* Color Rules,v1 Stub *)
colorRules = colorRulesGenerator[gameNumColors];


(* Training Pair Generator,v2 Stub *)
trainingPairs= Partition[Flatten[ 
Table[ 
Table[{i,j},{j,i+1,gameNumColors}] 
,{i,gameNumColors-1}]
],2];
trainingPairsRandom=RandomSample[trainingPairs];
trainingPairsColors=trainingPairsRandom /.colorRules;


(* Toggling a Manipulate Stub *)
trainingPairStart=False;
testPairStart=False;

(*Record Training Time Stub*)
trainingStart=False;
testingStart=False;
trainingStartTime;
trainingEndTime;

testingEndTime;

(*NEW STUB: Store results information*)
filename = "data.txt";
name = InputField[Dynamic[n]];
totaldata = {trainingStartTime,trainingEndTime,testingStartTime,testingEndTime,correctAnswers,incorrectAnswers};
exportFunction[name_]:= Export[name,totaldata]


Column[{name,
Row[


(*Record Training Time Stub*){Dynamic[If[testPairStart,"Training Complete",Button["Start Training",{trainingPairStart=True,trainingStart=True,trainingStartTime=Now}]]],
Dynamic[timeSpentTraining]}],


Dynamic@If[trainingPairStart,

(*Display Training Pairs,v1 Stub *)
SlideView[Map[Graphics[{
trainingPairsColors[[#,1]],Rectangle[{0,0},{1,1}],
trainingPairsColors[[#,2]],Rectangle[{1,0},{2,1}]}]&,Range[Length[trainingPairsColors]]],AppearanceElements->{"PreviousSlide","NextSlide","SlideTotal"}],""
]}]


(*Toggling a Manipulate Stub/Record Training Time*)
Dynamic@If[trainingPairStart,Button["Start Testing",
{trainingEndTime=Now,timeSpentTraining=trainingEndTime-trainingStartTime ,correctAnswers = {},incorrectAnswers = {},trainingStart=False,testingStart=True}
],""]

(*Display Testing Pair*)
Dynamic@If[testingStart,Dynamic@genTestPair]
(*Does the function genTestPair have to be defind at the top??*)

(*User Response Stub*)
Button["True",{testResponse=True,timeAssignments,checkAnswer}]
Button["False",{testResponse=False,timeAssignments,checkAnswer}]

(*Record Testing Time Stub*)
Button["Finished",{exportFunction[filename],testingEndTime=Now}]
(*Does timeSpentTesting need to be defined at the top??*)
*)

(*NEW STUB: Store results information*)

Name of User, or ID number
Official Date of quiz
write file program has version in correlation to datastructure

name = InputField[Dynamic[n]];

Hash@"aled"

Export["C:\\Users\\alexk\\Google Drive\\Augment\\BBdata\\data1.txt", correctAnswers]

-Some things are missing from the final code
-No results display stub
-New stub neede for Storing the results information

Full Application v2.2

Changelog

4/26 BRC, EWN -- Original authorship of v2

4/27 EWN -- v2.1 Added Designer’s Intent, Pseudocode, and Code In-line comments

4/27 EWN -- v2 .2 Added very simple Running Totals

Designer’s Intent v2.1

All functions defined in the stubs above are aggregated into a full application.
Full application is currently playable.  
It will record training activities, then store the data output in a file, which can be re-imported.  

Current functionality: 
	Early user interface for Player to study correct (canonical) color order through color pairs in {lesser, greater} format.
	User interface for Player to “test” their memory of the canonical order by asserting a “test” color pair is.. or is not... in canonical order.
	Early data export to file -- ???Export currently requires player change filepath -- Needs to be generalized.
	???Data file currently overwrites previous file in each session.  Must manually change name for file output to save additional sessions.
	Early data import.  ???Currently no visualization of data.

Pseudocode v2.1

Choose number of colors to play with.
Define colorRules... to convert numbers 1, 2, 3... to colors red, blue, green... (this becomes the “canonical” color order)
Generate list of all number pairs in correct order... i.e. {lesser, greater}.. e.g. {1,2}... NOT {2,1}... then convert this list of number pairs to color pairs using colorRules.. e.g. {1,2} -> {Red, Blue}
Show buttons to Start Training (toggle training UI to show) and Start Testing (toggle testing UI to show) and record timestamps for button clicks.
Show Training UI on click of Start Training.   Includes SlideView of all training pairs.
Show Testing UI on click of Start Testing.  Includes... 
	TestPair display
	Buttons for Player Response (i.e. True/False)
	Button to export data
	Button to import data

Code v2.2

Clear[correctAnswers];
Clear[incorrectAnswers];

Manipulate[Row[{Column[{(* Set the number of colors to be used in this BBGame session -- More colors, more difficult -- max number is 12 *)
gameNumColors =5; 

(* Define rules to convert numbers 1 through gameNumColors... defined above... to random colors..
i.e. {1 -> Red, 2 -> Blue, 3 -> Green}.. but random. *)
colorRules = colorRulesGenerator[gameNumColors];

(* Create a comprehensive list of number pairs in a {lesser, greater} format.. then uses colorRules to convert those number pairs to color pairs.
i.e. {{1,2},{1,3},{2,3}} -> {{Red, Blue},{Red, Green},{Blue, Green}} *)
trainingPairsColorsGen[gameNumColors];

(* Create toggle buttons "Start Training" and "Start Testing".
Record timestamps for when those buttons are clicked.
Toggle showTrainingPairs to initiate training and testingStart *)
(* ??? Perhaps improve name.. Stub seems to do more than name timeTraining suggests... *)
timeTraining

(* When showTrainingPairs is toggled, shows a SlideView of all training pairs. 
When training is complete, this output switches to show resultsDisplay. *)
Dynamic@If[showTrainingPairs,trainingPairsDisplay[gameNumColors]]

(* When testingStart is toggled, shows Testing UI *)
Dynamic@If[testingStart,showTestPair, ""]

}],Dynamic@BarChart[{Total@Table[correctAnswers[[n,1]],{n,1,Length[correctAnswers]}],Total@Table[incorrectAnswers[[n,1]],{n,1,Length[incorrectAnswers]}]},ChartLabels-> {"Correct","Incorrect"},ImageSize->{400,500}]}],ContentSize-> {1100,500}]

Dynamic@correctAnswers

Dynamic@incorrectAnswers

Dynamic@Table[correctAnswers[[n,3]]-testingStartTime,{n,1,Length[correctAnswers]}]

Dynamic@answerTimesPlot

Dynamic@testImport

Example Generative Learning doc

File Header

Version: 0.1.8.4
Filename: PredictFunctionTesting_v0.1.8.4KCLSRJL.nb
Version Author: Kevin Lin, Shishir Reddy, Jenny Li
Originating Author: Kevin Lin
Date: 7/11/16

Designer’s Intent

Train Predict to ascertain a function using given points
	Observe how different methods (PredictorFunctions) produce different results
	Examine how smaller steps between points improves resolution
	
Organization:
1. The Random Forest Method (Hyperlink)

1.1 Predicting a basic sine function (HL)
1.2 Improving the Predict function’s accuracy (HL)
1.3 Generate more points for the Predict Function (HL)
1.4 Compare different attributes of Predict function (HL)
	1.4.2 Manipulate step size (fix later) (HL)

2. The LinearRegression Method (Hyperlink)

2.1 Graph a linear regression using Predict (HL)
2.2 Graph a linear regression using LinearModelFit (HL)
2.3 Add more input variables (HL)
2.4 Add an unlimited number of inputs (HL)

1. The RandomForest Method

1.1 Predicting a basic sine function

Designer’s Intent

Train a Predict function to create the following sine curve using given points:

Plot[Sin[x],{x,-Pi,2Pi }] (*Objective*)

Pseudocode

Establish a set of points named “trainingSine1”
Use trainingSine1 to train Predict function
	Training set (sine plot): x-coordinate -> y-coordinate
	Use Method -> “RandomForest”
Graph the the Predicted function
	Compare with sine function

Code

trainingSine1 = {0->0,(Pi/2)->1, Pi->0, ((3*Pi)/2)->-1, 2Pi->0}; (*Start with solid # points[both output/input can be easily written] *)

p1= Predict[
trainingSine1, Method->"RandomForest"](*Predict will choose Linear regression here, so method must be used to choose RandomForest*)

Plot[p1[x], {x,0,2*Pi}]

Observation

While this graph has the general shape of a sine curve, it is quite different 
and needs to be smoothed out by providing more training points.

1.2 Improving the Predict function’s accuracy

Designer’s Intent

Use more points from the original sine function to create a more accurate Predict graph
Improve graph resolution by making the graph “smoother” and more accurate

Pseudocode

Add more points to new training set, “trainingSine2”

trainingSine2 = {0->0,(Pi/4)->(1/(Sqrt[2])),(Pi/2)->1,((3*Pi)/4)-> (1/(Sqrt[2])), Pi->0,((5*Pi)/4)->-(1/(Sqrt[2])), ((3*Pi)/2)->-1, ((7*Pi)/4)->-(1/(Sqrt[2])),2Pi->0};
(*Establishment of more points -> 
 smaller steps between points ->
attempt to create a better resolution graph*)

p2 = Predict[trainingSine2]

Plot[p2[x], {x,0,2Pi}]

Observations

The new graph has slightly better resolution, but is still quite different from the sine function.
A much larger amount of points is needed to significantly improve resolution.

Important Note:
The RandomForest Method will graph varying results due to its random nature (ambiguous; random how??). 
For example, the graph of trainingSine3 exhibits behavior different from the graph of trainingSine2, although the code is exactly the same.
This variance can be reduced by adding more points to train the Predict function.

trainingSine3= {0->0,(Pi/4)->(1/(Sqrt[2])),(Pi/2)->1,((3*Pi)/4)-> (1/(Sqrt[2])), Pi->0,((5*Pi)/4)->-(1/(Sqrt[2])), ((3*Pi)/2)->-1, ((7*Pi)/4)->-(1/(Sqrt[2])),2Pi->0};

p3 = Predict[trainingSine3]

Plot[p3[x], {x,0,2Pi}]

1.3 Generate more points for the Predict Function

Designer’s Intent

Further increase the resolution of the predicted sine graph
	by adding hundreds or thousands of points as reference for the Predict function

PseudoCode

Using Table, create a table that generates values for trainingSine4
	The points are plotted in increments of Pi/4
	Change x into a sine value using the rule: x -> Sin[x]
Create three different plots incorporating 100, 250, and 1000 points respectively
	Show all three plots on the same graph

Code

100 Points

trainingSine4 = Table[(*Creates a Table*)
x->Sin[x],(*the x value is being changed into a sine value*)
{x,
0,100,(*Predict function uses 100 points*)
Pi/4}];(*With step size being Pi/4*)

p100= Predict[trainingSine4, Method->"RandomForest"](*The predict function evaluates these data points*)

Plot[p100[x], {x,0,10Pi}]

250 Points

trainingSine5 = Table[
x->Sin[x],{x,
0,250,(*Function uses 250 points*)
Pi/4}];(*Step size of Pi/4*)

p250= Predict[trainingSine5, Method->"RandomForest"]

Plot[p250[x], {x,0,10Pi}]

1000 Points

trainingSine6 = Table[
x->Sin[x],{x,
0,1000,(*Function uses 1000 points*)
Pi/4}];(*Step size of Pi/4*)

p1000= Predict[trainingSine6, Method->"RandomForest"]

Plot[p1000[x], {x,0,10Pi}]

Combining all the graphs

Plot[{p100[x](*100 Points*)
, p250[x](*250 Points*)
, p1000[x](*1000 Points*)
, Sin[x](*Standard of Comparison*)
}, {x, 0, 10Pi}, PlotLegends->"Expressions" ]

I’ll just assume you’re adding another section to manipulate step size because I feel like that would be helpful too.

1.4 Compare different attributes of Predict function

Designer’s Intent

Discern the distinctions between different attributes of Predict:
	E.g.: Size of training set
	Model for predictor function generation
	Resolution of training set
Create a side-by-side comparison (T-Bar) between different attributes

Pseudocode

Plot {PredictFunctions 1, 2, and 3}, based on different attributes, which can be modified
Use Plot of Sine function as comparison
All Table functions are training data for Predict functions:
	Plot[{Predict[Table[x->Sin[x], 100 Training Points, Increment Pi/4]], 
	Table[x->Sin[x], 1000 Training Points, Increment Pi/4], 
	Table[x->Sin[x], 10000 Training Points, Increment Pi/4]}

	{Table[x->Sin[x], 100 Training Points, Increment Pi/8],
	Table[x->Sin[x], 1000 Training Points, Increment Pi/8],
	Table[x->Sin[x], 10000 Training Points, Increment Pi/8]}

Code

Step size: Pi/4

predictFunctionsSinPi4=Map[
Predict[Table[x->Sin[x],{x,0,#,Pi/4}],Method->"RandomForest"]&,
{10,100,1000}
]

lowResPredictPi4=Plot[Flatten[{Sin[x],
Table[predictFunctionsSinPi4[[i]][x],{i,1,3}]}],{x,0,2Pi}]

Step size: Pi/8

predictFunctionsSinPi8=Map[
Predict[Table[x->Sin[x],{x,0,#,Pi/8}],Method->"RandomForest"]&,
{10,100,1000}
]

midResPredictPi8=Plot[Flatten[{Sin[x],
Table[predictFunctionsSinPi8[[i]][x],{i,1,3}]}],{x,0,2Pi}]

Step size: Pi/16

predictFunctionsSinPi16=Map[
Predict[Table[x->Sin[x],{x,0,#,Pi/16}],Method->"RandomForest"]&,
{10,100,1000}
]

hiResPredictPi16=Plot[Flatten[{Sin[x],
Table[predictFunctionsSinPi16[[i]][x],{i,1,3}]}],{x,0,2Pi}]

All graphs together

Show[lowResPredictPi4,midResPredictPi8,hiResPredictPi16]

Much, much more... that was about half of the original document.

Other principles

Individualized everything: training path, training content, objectives and checkpoints, mentor touch points

Mentor’s primary job is to keep each student in their ZPD (Zone of Proximal Development)

Training artifacts make training next cohort easier, e.g. by illustrating a concept via progressive example

Real Accomplishment relies on Real Teamwork relies on Accurate Assessment of Capability
Everyone needs to learn quickly what everyone else can do.
Interdependence relies on confidence, which relies on capability --

Real Teamwork is a growth stimulus on all capability levels
Learners -- subject matter understanding, technical competence, etc.
Tutors -- conceptual clarification & explanation
Mentors -- growth patterns and pathways

Team as Product, i.e. The Team itself is also an output of the team’s work
I.e. Learners focus on the outputs, but tutors and mentors focus also on

End of the line

Eric@augmentsoftware.com

gelmanisaac@gmail.com

Initialization

(* Styling functions *)
labelStyler[labels_] := Style[#,FontSize-> 16, FontWeight->Bold]&/@labels;
barchartMaker[x_,y_] := BarChart[x, ChartLabels-> y, ImageSize->500, LabelStyle->16, AxesLabel->{"",Style["Growth",24]}, LabelingFunction->(Placed[Style[ToString@#<>"%",16],Above]&)];

(* Bootcamp Full-Time Growth Rates *)
bcFTLabels = labelStyler[{"In-person", "Online"}];
bcFTGrowth = {20.4, 173};

(* Bootcamp Learner Type Growth Rates *)
bcTypeLabels = labelStyler[{"Job-Seekers", "Corporate Training"}];
bcTypeGrowth = {20.4, 111};

(* Bootcamp Long-Term FT Job-Seeker Growth Rates *)
bcFTJS ={2178, 6740, 10333, 15077, 16867, 20316};
bcYoYFTJSNumChange ={4562,3593,4744,1790,3449};
bcFTJSLabels = labelStyler[{2013, 2014, 2015, 2016, 2017, 2018}];
bcFTJSYoYGrowth = Table[N[bcYoYFTJSNumChange[[i]]/bcFTJS[[i]],3]*100,{i,Length[bcYoYFTJSNumChange]}];

(* Bootcamp Growth Rate Charts *)
bcFTGrowthChart = barchartMaker[bcFTGrowth, bcFTLabels];
bcTypeGrowthChart = barchartMaker[bcTypeGrowth, bcTypeLabels];
bcFTJSYoYGrowthChart = barchartMaker[bcFTJSYoYGrowth, bcFTJSLabels];

videoImages={,,,,,,,,,,,,,,,,,,,,,,,,,,,};

videoImagesBW=ColorConvert[#,"Grayscale"]&/@videoImages; (* Map a grayscale function across the list of images *)
frame[num_]:=videoImagesBW[[num]];
imgWidth=ImageDimensions[frame[1]][[1]] ;(* part 1 of image dimensions is width *)
imgHeight=ImageDimensions[frame[1]][[2]] ;
imageCatenate[img_]:=Catenate@ImageData[img,"Byte"]; 
imageRestore[imgListVals_]:=Image[Partition[imgListVals,imgWidth],"Byte"]; (* part 2 of image dimensions is height *)

M=Transpose[
imageCatenate[frame[#]]&/@Range[Length[videoImages]] 
];

Code for Project 1

Graph[algoTradingLinksDirtyAll]

maxItems = 100; (* # of links allowed per page to download... implemented in 2 lines below *)
algoTradingFrontlinks = WikipediaData["Algorithmic trading", "LinksRules", "MaxLevelItems" -> maxItems, "MaxLevel" -> 2]; (* download frontlinks *)
algoTradingBacklinks = WikipediaData["Algorithmic trading", "BacklinksRules", "MaxLevelItems" -> maxItems, "MaxLevel" -> 2]; (* download backlinks *)
algoTradingLinksAll = Join[algoTradingFrontlinks, algoTradingBacklinks]; (* Combine frontlinks and backlinks *)
Row[{Dataset@algoTradingLinksAll, Length@algoTradingLinksAll}, " # edges = "] (* View the all algorithmic trading relationships *)

threshold=450;(* Limiter for number of appearances(defined below in If statement) *)
algoTradingLinks=
(If[ (* If either of the words show up more than threshold times *)
Count[algoTradingLinksAll,(#[[1]]->_)|(_->#[[1]])|(#[[2]]->_)|(_->#[[2]])]≥threshold,
Thread[#]]&/@algoTradingLinksAll (* then include it in the output list*)
) /.Null->Nothing ;(* remove non-matches by replacing them(Null output) with Nothing *)
Row[{Dataset@algoTradingLinks,Length@algoTradingLinks}," # edges = "]

redPts={#[[1,1]],#[[1,2]],#[[2,1]]}&/@indexedPixels[usaImg];
pointsPlot=ListPointPlot3D[
redPts,ColorFunction->Function[{x,y,z},Lighter[Red,1-z]]];
pointsSurface=ListPlot3D[
redPts,ColorFunction->Function[{x,y,z},Lighter[Red,1-z]]];

usaImg=resizeMax[,75];