24-Hour Hacks w/ The Wolfram Language

Aaron Brzowski, Western Kentucky University

Join the Conversation #WolframTechConf

What is a hack?

A hack when relating to software is a solution to a problem that may not necessarily be the best solution, but it functions. It may not be the prettiest, most elegant solution, but put simply, it works.

Hacks using the Wolfram Language can be far more powerful than hacks using other languages due to the vast depth of built-in algorithms and knowledge all accessible symbolically. Wolfram Language helps you build what you want to build in 24 hours without having to reinvent the wheel along the way.

Places to Start

A hack using the Wolfram Language can start with a simple idea and grow into something truly powerful. All you need is a problem you want to address, and the Wolfram Documentation center can help you find functions and libraries to build your hack around.

Follow these steps when attempting a 24 hour hack with the Wolfram Language!

Determine a problem you wish to solve

It can be anything within the realm of imagination

Search the Wolfram Documentation for sections relating to your problem

Find useful helper functions within the Wolfram Language to do key calulations and data management

Examples of this are the Wolfram Cloud Platform and Wolfram DataDrop

Leverage the scalability of the language, your hack easily can grow to support a large user base, or data set

Examples of 24-Hour Hacks

Leap Motion Integration w/ Mathematica

Planning

Determined the Problem - No Easy Way to Hand Draw 3D Parametric Plots within Mathematica

Searched the Wolfram Documentation Center - Found JLink libraries to connect Mathematica to Java API Endpoints

Utilized helper functions - Storing large amounts of data points collected was tedious without loops to PrependTo a list of points

Displayed points collected from Leap Motion in a dynamically updating 3D graphic to visually plot a parametric curve

Extended upon by fitting a parametric curve to a requested degree to the points gathered from the Leap Motion device

Code

Needs["JLink`"]; 
ReinstallJava[CommandLine->"java",JVMArguments->"-Djava.library.path=[/Users/aaronbrzowski/Documents/LeapSDK/]"];
AddToClassPath["/Users/aaronbrzowski/Documents/LeapSDK/lib/"];
InstallJava[];
controller=JavaNew["com.leapmotion.leap.Controller"];

This above variable called “controller” allowed us to then access the Leap Motion API through their SDK as any other languge would allow.

It allowed us to define the tool we used above the controller, which we selected to be a single point device (a chopstick) for precision.

Then once we could instruct the controller to detect a single point, we simply ran the detections over a specified period of time and saved points to a list and dynamically updated the graphic.

Expansion

The best part of creating a hack in the Wolfram Language is when you’ve set out to achieve what you’d like to accomplish, and then can expand in your remaining time, and expand we did.

We utilized custom normalizing functions to transpose a signature written in the air to a 2-Dimensional curve, and then developed training sets using classifier functions within the Wolfram Language. 

This allowed our hack to successfully determine with 99.999% confidence a given signature between my signature, and my partner’s signature using machine learning.

Custom Data Curation w/ Wolfram Language Through Twilio

I built a service to accept information about what you want to know in a WebApp, and then curates custom text messages to be sent to your mobile phone through Twilio with that data you’d requested. It currently will return the latest tweet from someone you specify, the latest image and caption from your favorite subreddit, your current portfolio value given the ticker of the stock you own along with number of shares, and also the weather forecast for the day (of course).

I built this service entirely using Wolfram Language within Mathematica. The WakeyWakey service runs on a server I hosted that executes a function to send SMS messages with a user’s curated data at set times throughout the day. It currently runs once per day in the morning at 8am to alert users of what’s going on in their personal worlds that day.

The steps I followed to create this project are as follows:

Created a Databin on Wolfram DataDrop to store user input from cloud deployed webform

Connected external APIs such as Twitter, Reddit, and Twilio to handle the SMS data processing

Created and formatted cloud deployed webform to input data user requests to have curated

Formatted data from each source (Twitter, Reddit, Weather, etc.) based on a Do loop which accessed the Databin and passed in parameters for each person to curate data on an individual basis

Once data was curated, I then formatted each data set into a message easily sendable with Twilio, and then sent batch messages to a current user

Can be scaled to any number of users, only limit is runtime and storage on Wolfram Datadrop

GM DrivePrint

Utilizing data gathered from GM vehicle sensors we created a platform to analyze driving data sent to an offboard server running on Wolfram Cloud. This driving data is analyzed using machine learning algorithms we developed to accurately determine who is driving the vehicle based on their driving patterns. The driver is then shown a driving score at the end of their drive based on their acceleration, braking, and quick turns during the drive.

Backend

The backend was written using WolfLang and a Wolfram Datadrop to host all data outputted from the vehicle itself. I simply wrote a custom APIFunction that I cloud deployed which allowed the car’s onboard computers to send the collected data (using Javascript) to the API endpoint I’d written through the vehicle’s LTE connection. 

This API function then posted the data the databin within Datadrop to be available for processing. 

Once the data had been posted to the databin, another custom API endpoint that I had written was hit, essentially accessing the data posted to the databin, running it through a custom machine learning classifier (linear regression), and then outputting a “score” value we used to determine the driver’s driving personality which we could then compare against future drivers for classification.

Using these “score” values, we were then able to successfully determine the driver of the vehicle between drivers in a previous training set with up to 99.9999% accuracy, dependent on the length of the drive.

result =  identifier->
2*accelTemp +
1.5*Mean[normalizeList[brake,-0.2]]+
1.0*Mean[Differences[normalizeWheelList[wheel]]]+
0.75*accelTemp*wheelTemp (*allowed us to gather G force data on the car*)
;
DatabinAdd[Databin["gj2nUQ7X"],result];

Conclusion

It doesn’t matter what you create. Just create.

Spend 24 hours and build something.

It won’t be pretty. It won’t be clean. But it can be functional.

Uniqueness is key in 24-Hour hacks. Build something different.

Build something you’re proud of.