Twizzlers Julia Ewan | The Washington Post | Getty Images

The licorice-makers at Hershey's factory in Lancaster, Pennsylvania, have been trying for years to perfect the art of the Twizzler. The weight of each chewy, Helix-like licorice stick varies just a little bit because of slight variations in temperature, said George Lenhart, a senior manager at Hershey's who oversees disruptive technology. If the licorice gets even slightly too cold as it goes through the machines, it will be too light. A tiny bit too much heat makes the licorice heavy, Lenhart said. But when consumers buy a package, it promises them a specified net weight (such as 1 pound) or number of pieces of the fruit flavored candy. Hershey must consistently follow through, offering a pound or more per package. This has created a big, expensive mass production problem for the Twizzler assembly line. Yet now, a partnership with Microsoft has leveraged machine learning to teach robots the art of Twizzling.

The challenge of the perfect Twizzler

Each 900-gallon batch of licorice must cook for 4 hours before traveling through holding tanks and pipes to a pressurized machine called an extruder, which pushes the licorice through like Play-Doh. If the licorice came out of the extruder too light, it either had to be re-extruded or more licorice needed to be added to the batch, a time-consuming process, Lenhart said. "We had to go a little heavy all the time," Lenhart said.

Source: Hershey's

On the other hand, if it came out too heavy, the machine produced an extra 100 grams of candy per minute, wasting precious ingredients. To minimize waste, Hershey's operators manually weighed the licorice every 15 minutes, adjusting the machine 12 times a day to try and standardize the Twizzlers. "Variability is something that we are always are trying to minimize," Lenhart said. "They have spent years perfecting it, but if I could predict the weight of the licorice, would I be able to adjust the machine automatically." He added: "If the highs are not as high, lows are not as low, you are getting closer and closer to the net weight number is without going below. The less waste, the more profitable." Lenhart has been obsessed with this since he joined Hershey's in 2010. He started by doing business intelligence and data-mining, and gained an intimate knowledge of each plant. Then, he attended a Microsoft tech conference, and it clicked.

60 million data points