Sunday, August 23, 2015

Iowa rides, neural nets

I've been taking a lot of rides since I got back from my trip. I think I've been cranking out 5 or 6 rides a week, which is more than I anticipated. I figured that after riding across the country, I'd want to be done riding for a while. Not true! I've been loving riding in the Iowa City area. The countryside is beautiful. Unlike riding in the twin cities, I can be out on some rural road in less than 15 minutes from my house. Contrary to popular belief, Iowa is not entirely flat. I ride a lot of rollers around here. Nothing crazy, but at least the terrain is varied. Nothing like west-central Kansas, which is flatter than a damn pancake. Today Tom and I went out to a little town called Oxford, about 20 miles north and west of where we live. Coming back, we had a monster tail wind, some nice rollers, and a beautiful tarmac road. We passed the occasional farm house, but corn and soybeans were our constant companion. In the wind, the soybean fields ripple, as if a wave is passing through them. It makes me feel like I'm riding on some causeway through a large body of water.

Friday, August 7, 2015

On the road to haikus

For the last few months I've been working on a little project in which I try to generate haikus. At first, the goal was simply to construct a series of words that had the correct haiku structure, 5 syllables in the first line, 7 in the 2nd, and 5 in the last. Not content with word salad haikus, I decided to try to make poems that made a little bit of sense. As a result, I scraped article titles from CNN (using a cool little module called newspaper) and selected chunks of texts that had the correct structure. This resulted in some interesting haikus. Due to the fact that my code made text selections at random, most of the poems were impossible to read. At this point I decided that I needed to model how sentences are constructed using real texts (from books, or the article titles I mentioned above) as my data.

After looking through some text, I realized that the way words appear in a sentence depending on two main factors: the preceding word, and the location in the sentence. 'The' is more likely to appear at the start of a sentence than say, 'him', and 'flows' is more likely to come after 'water' as compared to 'burns'. Instead of looking at individual words however, I thought that it would be best to look at categories of words. Parts of speech is a good way of categorizing words, as it allows me to build sort of a sentence template. If I can create a list consisting of a series of parts of speech, creating a sentence is relatively easy -- you just plug in words that correspond to the part of speech at each location, and a sentence is formed. Analyzing the factors I identified above comes down to answering the following question: "What's the chance of observing part of speech A in position x+1 given that part of speech B is in position x?" The trick is to do it for all combinations of part of speech at every location up to some predetermined location in a sentence (say 7 spots). In the end, you get a three dimensional matrix whose slices represent the probabilities of finding each part of speech given all the other parts of speech in the preceding location. This seems all well and good, but it doesn't work. If you try to construct a 'most probable' sentence using this method, by looking at the most probable combination in the first slice, and then using the result of this as the starting point in the next slice, you get a bunch of nonsense. I remember getting a list of 5 nouns with a verb or two thrown in there. The reason why is simple. This method doesn't take into account how having part of speech 'A' in position one effects the probability of part of speech 'B' at some downstream position in the sentence; it only takes into account the adjacent position. For awhile I thought I would try to construct a cumulative probability tree, where you look at the frequency of every possible combination of parts of speech up to some predetermined location, but this ended up being, as you can imagine, computationally expensive. I resolved to try a different method.

Instead of looking at words as the base unit of a sentence, I thought it would be simpler and easier to look at common sequences of words as the base unit for my sentence. I wrote a little piece of code that grabs a sequence of parts of speech from a random sentence in a text and sees if it occurs at any other point in the text. It's possible to do this for every sequence in the text. The result of this code is a structure that contains highly frequent sequences of POS (parts of speech). Below are a few examples of chunks that I've 'filled in' with words from the text:

the miserable possession brought the stream
the chief god of an age
the dark country Over a wall
you wanted a beating for justice
they saw a mighty jerk of a distant spot
you drew the good fairy of the young man

Notice that these sequences don't really make any sense, but they're not word salad. Notice too that most of these chunks are just that; chunks, not actual sentences. Right now I'm working on a way of knitting together sentences to create something a little more coherent. I'm also trying to devise a way of creating associations between individual words. Some words just don't work together, while others fit together nicely. As I'm working only with POS, my code is blind to these possible word associations. I'm thinking of applying a 3-gram approach, where I look at the frequency of 3 word segments in a text. My project is on github, but it's kind of a mess. 






Tuesday, August 4, 2015

Final Thoughts

I've been having a hard time writing anything about the last few days of my bike trip. The last few days of biking were hard, long days, each more than 80 miles. Less than 24 hours after arriving in Yorktown, my dad came to pick me up and we proceeded to drive some 7 hours up to New York. We spent the next two days after that driving back to Iowa City. It was awesome to see everyone in New York, even if it was only for an evening. Brandon, Jack and Ornella were there, as well as the Mistry gang. I hadn't realized how much I missed my friends until I saw them. After getting back to Iowa, I resolved to take two days completely off. I rode my bike, but only casually. I didn't start in on any of the tasks that I've been meaning to get done while here this month. I just watched TV and hung out with my parents. I tried to write about the last few days of the trip, but I just sat at my keyboard with nothing to say.

Biking across the country, I fell into a routine of intensity that absorbed much of my attention and effort. I feel like I didn't make time in my head to miss people. While biking, I didn't think about much. I never spent time contemplating GR or poetry or programming. Mostly I thought about how many miles I'd ridden that day, if I should stop soon to put on sun screen, or holy shit I'm super hungry let me nom down on a bagel with peanut butter. Off the bike, I thought about eating, and where I was going to stay. The evenings were oftentimes the best for me. While I definitely enjoyed getting up everyday to ride my bike, it was also nice to hang out at a campsite or church in the evening, lounging in the (sometimes) cool air, eating, and reading books. As the trip progressed, I found that I wasn't as lonely as at the beginning. I think that I started to revel in the solitude of the experience. At the same time, I also found myself interacting with strangers on more occasions, and more confidently. I slowly accepted the fact that 99% of conversations I would have with strangers were going to be superficial, but that doesn't mean that I couldn't get a brief glimpse into their lives.

I think that my objectives for my trip shifted as I made my way East. Originally, I imagined that the trip would be about testing myself, day after day, to see if I could make it across the US. Somewhere in Eastern Colorado, I realized that I was physically capable of biking across the country. I slowly arrived at the idea that the only impediment to my progress was my idea of what a bike tour should be like. If I didn't feel like knocking on strangers' doors to ask if I could stay with them, I didn't have to. If I woke up one day thinking that I was going to bike 120 miles, then I could. If I woke up and felt the need to ride 30 miles, then I could. I was free to ride it however the hell I wanted to. For once, the only expectations that governed my behavior were my own. I didn't have to stop and gawk at historical sites. I didn't have to stop at state and national parks if I didn't want to. Ultimately, however, I knew that I wanted to ride. Looking back, I think that one of my favorite parts of the trip was seeing the way the landscape changed as I rode. A bicycle is fast enough to make it across the country in a summer, but slow enough to enjoy the vastness and diversity of the American landscape.









Saturday, August 1, 2015

Diamondback Haanjo comp long term review

I wrote this review about a week after I replaced my bike in Kansas. I'm working on a post about the last few days of my trip. Here's a brief update. After arriving in Yorktown, Tom came to pick me up (after driving 1100 miles) and we drove to New York, where we spent the night at the Mistry house. We had a good time catching up with everyone. I didn't realize how much I missed everyone until I got there and saw them. It was wonderful to be able to spend even a little time at the Mistry house. After another two days of driving, we got back to Iowa City yesterday afternoon. It's good to be home.

Back in St Paul, I had a gigantic Schwinn world sport frame lying around. I resolved to build it up with some parts that I had, including a double FSA gossamer crankset and an eight speed rear setup from my first road bike. This bike played host to a number of firsts for me. Friction shifters was one, and gobs of tire clearance was the other. I think I could jam a 35c tire in there. For the first time in my biking life, I could go off pavement. No single track (as there is little single track in the vicinity of a kid without a car) but definitely off road. Some unpaved bike trails, some dirt by the river. I got muddy for the first time. I broke a wheel for the first time. It was awesome. The bike wasn't ideal though. I knocked my nuts on that top tube so many times that I wondered if I'd ever be able to reproduce. I could never get the fit right because of the size of the frame. Also, it was heavy as hell, and the gearing was less than ideal. But it made me lust for getting dirty.

When I was planning my bike trip across America, I wanted a bike that I would be able to tour with, but also something that I would be able to take off road. After some research I decided that the haanjo comp was going to be my beast. I rode the shit out of the bike in new York. I rode gravel, a little single track, and a lot of roads. It was my adventure bike. If I saw a road or trail that looked interesting, I pointed the bike and went. I didn't worry about breaking things or not having enough traction-- the 42c stock tires tore it up. If I ever needed more grip, I just took a little air out of the tires, and I gripped. This bike wrecked gravel trails. It was light enough to fly up descents, and stout enough to handle the beating that dirt trails can dish out. I could ride with roadies and do okay-- occasionally I'd fall behind, but only with crazy fit people. I remember one ride I took with a woman and her friend where we averaged something like 22 mph for a few hours. The diamondback haanjo comp is a do everything pretty well type of bike. Not a mountain bike, and not a true road bike, but some sweet sweet spot right in between.

I do have a few niggles with the bike. Diamondback never explicitly states that the bike is not designed for racks, so they felt they weren't responsible when the braze-ons ripped off the bike. This is not a touring bike, but I thought I could get away with touring on it. It held up for 1800 miles. It performed well for 1800 miles, in fact, after I changed the gearing. Two other things irk me about the bike. The shift cable routing is under the down tube. What the shit. This is a bike designed to get super dirty, and mud ends up right where those cables get routed. This means that shifting inevitably sucks after about 100 miles off road. The front derailleur is a clamp on type, which by itself is not an issue. However, the position of the second bottle cage mounts are such that the front derailleur cannot be put low enough to accommodate the 46 tooth chainring in the front. This means front shifting is always a bit lackluster.

In general, this bike was awesome for me. I've ever had as much fun on a bike as with the diamondback haanjo comp. It's a bike where you point and go, and you get there fast, and comfortably. What more could you want?