Saturday, December 12, 2015

New Machine Learning Algorithm, The Crowning of Charlemagne, and Jovian Distances

Today I Learned:
1) ...about a machine learning algorithm with an interesting model from a joint project out of New York's Center for Data Science, the University of Toronto, and MIT. It's designed to solve the same sort of problem that most machine learning algorithms face -- to take some examples of a thing and some examples of not-the-thing, then tell you whether other stuff is more of that same thing or something else (in this case, the authors considered the problem of recognizing written characters).

The novelty of this algorithm is that it breaks the thing it's looking at (in this case, a character) into sub-parts, figures out how those parts are put together, and produces a *generative* model of the thing. In the case of characters, it breaks the character into things like lines and circles (things you can easily make with the stroke of a pen), figures out where those things start and end with respect to one another, and produces a sub-algorithm that describes how to produce a random example of that character (with some imperfections in the strokes and their positions). The algorithm can then look at a new character and figure out how likely it is that generative model would produce that.

For example, you might show the algorithm a few examples of handwritten lower-case 'i'. It might break its conception of 'i' into 'a longish vertical line' and 'a very short line' with the relationship 'the very short line goes <some amount> above the longish vertical line'. It makes a generative model out of this information -- call it makeI -- such that calling makeI returns a bitmap of a possible handwritten instance of a lower-case 'i'. If you show it a handwritten 'w', it essentially tries to make a bunch of 'i's using makeI, sees that none of them look like the 'w' you showed it, and declares with very high probability that it's not an 'i'. If you show it a handwritten 'j', it might see that some of the 'i's made by makeI look kind of like it, but not completely, so it might declare with only moderately high probability that the 'j' is not an 'i'.

(For the curious, this is a hierarchical Bayesian model over a nastily-high dimensional model. The algorithm does a quick, dirty estimate of the posterior to find likely maximum a posteriori peaks, then optimizes using numeric methods around that range to find maximum-likelihood generative models for a new piece of data. If the maximum a posteriori peak corresponds to a generative model close enough to the model the algorithm has for a known thing, it delares the new example to be of that type. There's another nifty thing it does that I don't understand as well where it can tune what "close enough" is using past examples.)

One startling thing about this algorithm is that it performs quite well given only one training example -- on some random real-world characters, after seeing exactly one example of a new character, it had a misclassification rate around 3%, which is slightly better than humans given the same task (and waaaay better than hierarchical deep learning (and about twice as good as the best modern machine learning network the authors applied)). Another cool thing -- the algorithm's generative models produced "written characters" that were, statistically speaking, indistinguishable from human-written characters, according to human judges.

Sadly, the article describing this algorithm is behind a paywall unless you have a Science subscription, but here it is anyway: http://tinyurl.com/pt9nked

2) It turns out the story of the birth of the Western Roman Empire is pretty interesting and pretty controversial. It happened right around 800 AD, in the court of Charlemagne, the King of the Franks at the time. For some time, the Roman empire had been ruled for some time from Constantinople, far in the east. It was a Christian empire that nomially ruled most of Europe, though in practice this it collected taxes and kept lots of bureaucratic notes and didn't do much else.

This changed on Christmas of 800, when then-pope Leo III crowned Charlemagne Emperor of Rome, pretty much declaring the Western Roman Empire overnight.

Leo III wasn't very popular, when elected. Shortly after his... ascension?... Leo was almost assassinated (technically, almost had his eyes and tongue ripped out -- this was a popular way of stripping public officials of power without damning ones-self to eternal damnation for murder), and he fled west and sought refuge with Charlemagne. He ingratiated himself with the King, and together the two decided that for Charlemagne to have the authority of Emperor of Rome would further Charlemagne's interests and help legitimize and protect Leo III. A bunch of administrative stuff happened more or less behind the scenes, of which we have some documentation today, but the big moment happened on Christmas, when, as part of a regular ritual ceremony, Charlemagne knelt before Leo III. To everyone's surprise (possibly even Charlemagne's!), Leo put a crown on Charlemagne's head and declared him Emperor. The written histories from the period are very dramatic on this point.

This was obviously incredibly important because it marked the beginning of the Western Roman Empire. It was also critically important as a symbol, because it implied that the authority of the Emperor came from God, and thus was granted by the papacy. This crowning moment more or less defined the relationship between the religious and secular leadership of the Western Roman Empire. There's some speculation that Leo did this more or less behind Charlemagne's back. If so, it may be the most important PR stunt in European history, all thanks to one man.

3) Jupiter is about as far from Saturn as it is from Earth (at the closest approaches of each, respectively).

Trial by Combat, Tempering and Annealing, and the Ice Line

Today I Learned:
1) Trial by combat was a real thing. In many of the Christian germanic tribes of the dark ages, when disputes couldn't be settled in other ways, the disputing parties would fight to the death, and it was expected that God would let the innocent party survive. This probably worked really well as long as everyone believed that it worked, because most guilty parties would rather confess their guilt than enter a trial by combat and, presumably, die.

2) Tempering a metal (when you heat a metal pretty hot and cool it quickly) works by disrupting the crystal structure of the metal. This makes it harder for cracks to propagate through the metal -- if a spreading crack encounters a defect in the crystal structure, the defect can often just absorb the crack without propagating it.

Annealing, on the other hand (when you heat a metal pretty hot and cool it *slowly*) reforms the crystal structure, giving the metal greater strength at the cost of some brittleness.

3) Astronomy seems to be full of critical lines and points and distances. Today I learned that one of these is the ice line, which is an orbital radius (in our solar system, between Mars and Jupiter). The ice line is the minimum distance at which icy bodies can form without being vaporized over geologic timescales by the parent star. This is imporant because a lot of material in early solar systems is ice, so bodies forming outside the ice line can generally collect many more large objects. That's why all of the planets outside the ice line are so much bigger than the ones outside it -- all the juicy ice mass in the inner solar system was melted away before it could form any really big chunks.

Friday, December 11, 2015

Wage Controls, Frosting Glass, and Abstract Algebra Terminology

Today I Learned:
1) During World War II, one of the effects of the wartime emergency plans in the US was wage controls, meaning that US companies were not allowed to pay more than a certain amount to their employees. This was part of a larger set of price controls to reign in inflation. This was a bit problematic for companies because it meant they couldn't compete for better workers by raising prices. What they *could* do was offer other benefits that weren't restricted by law, which is how employer-paid healthcare became standard.

After the war, Harry Truman proposed a national universal healthcare system, which was quite popular but opposed by doctors and hospitals, who had a lot of money in the private health insurance business, and labor unions, for whom employer-paid healthcare was a big trophy and bargaining chip. Truman lost.

2) ...how to frost glass! There are many ways to add a frosty finish to glass, but most of them are just variations on acid treatment (mostly using nasty fluoride-based acids of one form or another). You can also sand-blast glass, which is probably not as precise or nice as acid etching for, say, chemical glassware, but perhaps that's fine. If you're making many identical frosted glass pieces, you can also just etch the frosting into a glass mold.

3) A few abstract algebra terms:

Field: A field is a set of things on which "addition" and "multiplication" are defined (and their inverses, subtraction and division), such that the field is closed under both multiplcation and addition, and with some common sense properties satisfied for both operations (i.e., there is an addative and multiplicative identity, there are inverses for both operations for all elements of the field, both addition and subtraction are commutative and associative, and the distributive property holds). Some standard fields include the rational numbers, the real numbers, and the complex numbers. I tried really hard to come up with a good, instructive, non-numeric field, but I couldn't (the closest I could come up with was the set of lists of logical propositions, with addition being the set union of two lists of statements and multiplication being the list of all statements you could prove using two lists of statements, but it didn't really work out... for one thing, I'm not sure whether division is actually defined on such a "field"; for another, I couldn't come up with good addative and multiplicative identities that satisfied all of the properties of identities).

This is one of these terms that I keep learning and forgetting over and over again. Clearly I'm not using fields enough in my life.

Extension of a field: An extension of a field is basically a field that's a superset of another field. The most common example is the complex numbers, which are an extension of the real numbers -- it's the real numbers, "extended" with an extra element i and all the things you can get by adding and multiplying real numbers and i together. Another example would be the field consisting of all numbers of the form a + b*sqrt(2), where a and b are rational numbers -- this is the rational numbers extended with sqrt(2).

Automorphism: This is a mapping/function/rule that maps from a set onto itself and preserves some important property. Exactly what property is maintained depends on the kind of automorphism, but I think a good rule of thumb is that with an automorphism, if you add/multipy two elements together and apply the automorphism, it doesn't matter which one you do first (so for an automorphism A, you have A(x + y) = A(x) + A(y)).

Transcendental: This is a term I've heard all the time, but I never actually knew what it meant until today. A transcendental number (or element of a group) is one which cannot be defined as a root of an expression (usually a polynomial of some sort).

Also kind of learned about Galois groups, but at that point my comprehension dropped pretty precipitously. They may show up in a later TIL.

Wednesday, December 9, 2015

Repressing Plasmids, Honebee Song, and Facts About Transcriptases

Tody I Learned:
1) An important cloning consideration -- if you have a gene on a plasmid under repressor control, it's almost always a good idea to grow up the plasmid in a strain that expresses the repressor (or to co-express the repressor on the same or another plasmid). You don't want the gene to express because a) most genes are toxic when highly expressed, which lowers your plasmid yield and puts selection pressure on the bacteria to spit out or disable your plasmid, and b) expressed genes tend to mutate more, which can be a real pain downstream.

2) Honeybees are fairly vocal communicators. Or perhaps musical. They use sound to communicate, in any case, mostly but not entirely by buzzing their wings. Depending on the frequency and context, their sounds can mean a number of things, most of which amount to requesting more bees to do some task.

3) There are reverse transcriptases* that will copy both RNA and DNA templates. I didn't know that -- I thought there were only reverse transcriptases that only work on RNA and transcriptases that only work on DNA. Anyway, this is handy if you want to make lots of copies of cDNA**

Along these lines, I also learned today that, according to NEB (New England Biolabs, for the uninitiated -- a really awesome biotech company specializing in enzyme engineering with good prices and a fiercely independent mentality), transcription reactions should be run longer on short templates than on long templates. That's surprising. In almost every other context I've heard of, long templates require more time to process, which makes sense. I suspect there's some kind of piling up of enzymes that happens with short templates.

Also also, while I'm talking about transcriptases, today I learned that transcription works much better on linear DNA than on plasmids (circular DNA), because on a circular template the transcriptase will just run around and around and around, making very long transcripts of multiple copies of the plasmid. I'm pretty sure I should have known this (and may have learned it) in my last lab -- can anyone confirm or deny this?

*A transcriptase is an enzyme that "transcribes", which means it copies sequences of DNA into equivalent (reverse complementary) RNA. A *reverse* transcriptase is an enzyme that converts RNA into the equivalent (reverse complement) DNA. Reverse transcriptases are useful for turning RNAs from a sample into DNA, which is easier to work with and analyze.

**cDNA = complementary DNA, which means that it was produced from an RNA template. I think cDNA used to also stand for "cloned DNA", which didn't really mean much... can anyone else confirm this?

Tuesday, December 8, 2015

Signals vs Cues, Electric Cars, and Fire... In Spaaaaace!

Today I Learned:
1) In sociobiology (in particular the study of social insects) the term "signal" means something an organism does, and is evolutionarily selected to do, in order to intentionally tell others about some condition; the term "cue", in contrast, denotes something that an organism can use to infer some condition, but isn't selected for to act as communication. For example, a wounded person screaming for help is a signal, which another person can pick up on to know that somebody's in trouble; a person bleeding all over everything is a cue, which another person can pick up on to know that somebody's in trouble. Both are effective communication, but the signal is selected for on the basis of its information-bearing nature and the cue isn't. (Another example, an ant changing its behavior in response to a pheromone indicating the presence of food is picking up on a signal, while an ant changing its behavior in response to lower food availability in the colony is picking up on a cue).

2) Chevrolet sells a fully-electric small car (the Chevrolet Spark) for around $25,500 -- which becomes a net $17,000 after a US tax credit, at least as long as total Spark sales remain below 200,000 cars. That's more than *I* can afford right now, but I'm surprised how cheap it is. The Spark has an 80-mile/charge range, and takes between 7 and 20 hours to charge depending on what voltage you use to charge it. It has decent overall ratings, coming in at the #10 Affordable Subcompact Car in US News & World Report rankings.

I also learned today that electric vehicles don't, in general, need oil changes... because they don't need oil... because they have shockingly simple engines.

For a fun little anecdotal review of electric car ownership, see: http://ift.tt/1FRYwJf

Thanks to Chigozie Nri for pointing me down a rabbit hold of fascinating internet posts on electric cars.

3) Flammability works differently in space. NASA recently sent a burn-box to the ISS, in which they tried burning a bunch of common spacecraft materials. It turns out that the burning properties of some materials are radically different in low-G. For instance, a flame-retardant cotton-fiberglass blend similar to the stuff used in a lot of astronaut's cloths burns quite well in space. Also, the usual methods of putting out fires don't necessarily work -- spraying on flame-retardant foam, for example, can end up just spewing fire everywhere and making the situation worse.

Monday, December 7, 2015

Who Built The Moon, Live Streaming, and Induction Sensors

Today I Learned:
1) Sometime in the not-too-distant future, humanity will go back in time and construct the moon. No, seriously, a guy on the internet told me: http://ift.tt/1okOaNY

2) People will live stream almost anything, given an audience. In addition to the usual Russian dash cams, there are live streams of people eating, walking to work, and coding. The last one particularly interests me -- this is third-hand, but apparently some programmer decided to program on live stream once, and he decided it was the best thing ever because it's basically like pair-programming with 10 helpers over your shoulder. Except the ten guys don't have to be paid. I feel like there's a lot of potential value to be had in this area.

3) An induction sensor is a sensor that detects nearby metal by watching for inductive effects. Basically, it has a little bit of running current, which generates a magentic field, which in turn affects the current. When a metal object is brought nearby, it changes the shape of the magnetic field and in turn changes the current. Induction sensors are used on some 3D printers to detect the print bed.

Sunday, December 6, 2015

Solidworks, Aspect Oriented Programming, and Cake Pops

Today I Learned:
1) How to design a cuvette holder in Solidworks! Thanks to Erik Jue on this one!

2) Aspect Oriented Programming is a style of programming designed to address a thing called "cross-cutting concerns", which is anything that shows up in a bunch of places in code but is hard to actually make modular for some reason. For instance, lots of times you want to log a bunch of different events whenever they happen. Say, for instance, that whenever you make a call to any of an object's "set..." functions (say, setX, setY, setColor, or setVisible for some kind of shape Object), you want to print all the member variables of that object to a debug file.

You could manually wrap each call to the set function with some logging code, a la

outfile.write("Logging for setX: " + str(myObj.properties))
myObj.setX(5)
outfile.write("Logging for SetVisible: " + str(myObj.properties))
myObj.setVisible(True)

but this isn't maintainable in the least and involves a ton of redundant code

A slightly better thing to do would be to put the logging code inside the set functions for the class, a la

class ExampleShape:
   ...
   def setX(self, x):
       outfile.write("Logging for setX: " + str(myObj.properties))
       self.x = x
...
myObj.setX(5)

which is better but still a pain if you have many set functions in many different kinds of objects, and if you ever decide to log in a different way (say, by using some third-party logging package), then you have to go back and potentially rework a ton of code.

The Aspect Oriented (TM)* solution is to define an aspect with advice and cutpoints that define where to apply the... oh to heck with the official language -- basically you can write a rule that adds some wrapper code around STUFF, and a second rule that defines what STUFF is, and the compiler (assuming you're working in a language with AOP support) will find STUFF with the second rule and add whatever you need to STUFF using the first rule.

Using the logging example, the first rule would say "add a logging statement with the name of the function and all of the object's information", and the second rule would say "any method of the ExampleShape class starting with 'set'".

All this is kind of nifty, but potentially adds a lot of non-locality to code, and frankly I'm not convinced you can't do all of this with some carefully thoguht-out object-oriented programming.

*That's a joke, aspect oriented programming is not, in fact, trademarked.

3) There's a thing called a cake pop, which is a cake, crumbled into little bits, mixed with icing to form a pasty substance, and reformed into a delicious, starchy lolipop. Why didn't anybody tell me about this *before* I was vegan?