About Kai Staats

This author has not yet filled in any details.
So far Kai Staats has created 551 blog entries.

Learning recursion

Yesterday presented a real mental struggle.

I entered my office at AIMS with good friend Adriaan who had spent the night at my flat. I walked him through my work in Genetic Programming, sharing the challenges and success to date. The next step was to flatten the GP tree into a live polynomial in order to push real-world data through and learn how each tree performs.

I had devised a bottom-up approach, analysing the GP tree structure using the 2D array which holds each node and all of its associated values. A series of nested for-next loops would build the formula, starting at the bottom and working to the top. A bit mechanical, but something I knew how to do.

Adriaan suggested a top-down recursive method. I understood the concept of recursion, but had never programmed one properly. He drew an example on the black board and I was lost. He drew another, and I remained lost. I need physical examples for my brain to grasp a concept, and recursion is fairly ambiguous by nature. I grew frustrated. And Adriaan had to leave for Town.

I worked on two other updates to my code. Now my operands and coefficients reside in external .csv files which are imported at run-time.

Arun arrived an hour later and suggested I write a basic recursion script to calculate factorials. Of course. That made sense. And it worked!

I then returned to my script and in about two hours more had it working. The challenge was fine-tuning the code to present 3 different levels of recursion depending on the ‘arity’ (number of child nodes) for each parent node. In the end, the number of lines of code was similar to my original approach, but recursion is more elegant … and I learned something new.

Thank you Adriaan and Arun!

Now, my GP code generates randomly generated mathematical polynomials which will soon be tested in a tournament to determine which ones will move into four types of mutation and reproduction to build the subsequent generation.

Progress!

By |2017-11-25T00:03:13-04:00April 7th, 2015|Ramblings of a Researcher|Comments Off on Learning recursion

When Nature Calls

Adriaan, Holy and I went to Natures Valley with the intent to camp for three nights, kayak, hike, and relax. The kayaking was wonderful, as we engaged in a guided tour of the shallow estuary, its tributaries, and hatcheries. We enjoyd a mid afternoon nap on the first day there followed by a fabulous dinner cooked over two camp stoves and an open fire.

But on the second evening, it began to rain.

That night, I woke to the realisation that the floor of my tent was holding back a substantial amount of water. I looked outside the door to find my shoes floating. By the time I sat up, put on my shorts, and threw the few loose items into my backpack, the water had risen over the waterproof portion of the tent and soaked my sleeping bag.

I yelled, “Adriaan! I think it is time to go!” He yelled back, “Yeah, I agree. Already packing!”

I raced from my tent to the back of his bukkie (truck). Holy was already in the camper shell, having escaped the drips on her face in their large, shared tent two hours prior. The water was up to the wheel wells but the started the engine. Adriaan drove off to make certain he could get the vehicle out.

The entire camp ground came to life. Car engines sputtered and choked. Horns and sirens sounded as electrical systems shorted. People drove and walked to the higher ground just outside the entrance. We were lucky, as our campsite was but 50 meters from the gate. I can’t imagine the effort those further into the camping ground and further downhill must have mustered to escape.

I pulled each corner of my tent from the ground, throwing it over my shoulder. I walked, barefoot, to the top of the road and found Adriaan, Holy, and the bukkie. We went back to get more of our things from their tent and the picnic table. By this time, we waded through water nearly to our waist.

We helped the neighbours escape as they had three children, the youngest of which could not have been a year old. Their car was on higher ground, the water to the undercarriage. They did not seem to recognize what they had to drive through to get out. We walked with their car to make certain they made it, their tent and some belongings left behind.

The water went down nearly as quickly as it had risen. We removed Adriaan’s tent and by 2 am were on the road again, soaked, chilled, and overwhelmed by all that had happened.

Adriaan drove all night. I slept in back, wrapped in a damp sleeping bag, Holy in front with the heater on high. The day went well, with a visit to the southern tip of Africa and then a national park just outside of Hermanus. There we dried our gear and enjoyed a four hours hike.

The next week, I was discussing the adventure with one of the astronomers at SAAO. He was there also, but arrived the next morning. When he and his family arrived, it appeared to be a war zone, downed trees piled across the bridge and riddled across the campground. Gear, tables, chairs, and toys scattered everywhere, soaked, snapped, or destroyed.

The sad truth, Petri explained, is that this happens every couple of years, yet there is not a single sign warning patrons of the possibility of flash flood.

By |2017-04-10T11:17:34-04:00April 7th, 2015|2015, Out of Africa|Comments Off on When Nature Calls

My first GP polynomials!

First GP Tree by Kai Staats Having wanted to replace the grey matter in my head with something more valuable, eg: whipped cream, the recursive loop now generates polynomial strings!

In order to convert the resulting string to an executable polynomials, Arun suggested the library Sympy. Sympy even evaluates the algo, producing a simplified version and/or returning ‘0’ if it is not functional. If this works, I will not need to write an evaluator.

New to this version, the code now calls external .csv files for available functions and terminals. At the very bottom of the run, it auto-generates the polynomial.

Fun!

By |2017-11-25T00:03:03-04:00April 6th, 2015|Ramblings of a Researcher|Comments Off on My first GP polynomials!

My first GP trees!

First GP Tree by Kai Staats After 10 days coding, I have completed a GP tree generator!

Tested are Full and Grow trees through depth 5. Both parents and children are properly recorded. I can run ‘trees’ from the command line to view the Numpy array which holds the tree.

The Python code is coming along nicely. Clean, commented, and modular such that I will be able to extract all internal functions as external methods. A few more changes, such as making the section that builds the root a function, but it’s getting there.

It will be relatively simple to draw upon external data sets for the FUNCTIONS (operands) and TERMINALS (features) as the entire code base is designed to scale.

Yeah!

By |2017-11-25T00:02:54-04:00March 30th, 2015|Ramblings of a Researcher|Comments Off on My first GP trees!

Homeless in Cape Town, part VI

My friend Eurica, the car-park lady whom attended our Christmas dinner last year has had a very difficult few months. More accurately, a difficult decade.

Both her brothers are now dead due to gang shootings (the youngest killed two months ago). The Muizenberg Law Enforcement repeatedly take all the belongings of the homeless population, a weekly punishment rather than proactive law enforcement. (Last year I confronted a managing officer and he openly admitted to their thieving.)

What little money she earns, what clothing she has is frequently stolen while sleeping in upper Muizenberg park.

Her husband was killed twelve years ago, leaving her a single mother to a now 12 year old girl and 16 year old boy. They live a few hours from here by bus, with Eurica’s mother-in-law.

Today, I was walking back from the train station and saw Eurica sitting by the beach, clearly shaken. She said two police officers and her mother-in-law showed up today, unannounced. She had burst into tears, fearing that one of her children was now dead too. But they came to force her to make child support payments. Now, she fears she will be thrown into jail for inability to pay.

I went up to my AIMS office at 9:30 pm and spent an hour doing research. I printed three websites about child support law in South Africa, and hi-lighted the sections that pertained to her. In particular, the formula they use to calculate the payment amount, as there is no fixed amount.

I found a SA government subsidy program for single mothers which pays 350R per month per child, or $32 USD. Incredible that anyone can live on that. I have heard that families in the Townships, just down the street, live on $50 a month. Rice and water.

I then wrote a letter addressed to the magistrate which provided a positive disposition, stating that Eurica loved her children, wanted the best for them, and appreciate the past twelve years of care her mother-in-law has given. I detailed the challenges of her life and closed with an offer of 150R per month (at Eurica’s suggestion) and then gave her 300R as pre-payment for the months of October and November.

I gave her a strict set of rules for how to manage the meeting, making certain to bring all legal documents back for my review before signing. I want to make certain she does not sign away her kids nor commit to some amount she cannot afford.

She is suppose to have a government social worker, but none has been provided. I will fill that role until we can figure out what is going on. Plenty of experience in these matters between my parents’ life work and my time playing attorney for Terra Soft.

The hardest part of the evening was when she broke down and sobbed, saying, “This is not the life I imagined. I don’t understand why this is me. I stopped prostitution. I stopped taking drugs. I don’t drink. I pray to God but he never answers. My brothers are both dead. My mother has gone crazy. And I barely live day to day. I don’t believe there is a God any more … or he has abandoned me.”

Earlier today she took a handful of tablets in an attempted suicide. A friend rushed to the store and made her drink 2 litres of milk, which caused her to vomit, and she survived.

When we were talking, the stress in her body was so evident one of her eyes vibrated while the other was shut; her hands opened and closed uncontrollably, her face listless and speech slurred. She can’t take any more stress. She is on the edge.

Last year I had promised to help her with a proper CV and training to get a job. I have not done this, despite the fact I see her a few times a week. I know I have failed her in that respect. I don’t believe she will stop fighting and making bad decisions, therefore I don’t believe the CV will make a difference. But I know I should try. I need to follow-through, as I did tonight.

Two of the car park attendants are walking her to the next town where she has a place to stay until the meeting at the court, in the morning.

I gave her a clipboard, pen, the cash, and my card if she needs help during the meeting. I hope they don’t coerce her into something illegal. The legal system is bad enough in the States, I can only imagine what is attempted in South Africa.

This entire experience is a bold reminder of all the years my father worked as a social worker, the stories of the challenges of life brought home to the dinner table each night.

I find myself scared, sometimes not wanting to be around Eurica for long periods for more than a quick chat. Her stories are dismal and the look of her weathered, worn face, ten years my junior, a reminder of what living without shelter means. Her hands are those of an elderly woman as her body is fighting HIV.

Sometimes I just want to walk away and not look back because it is so fucking hard to realise how much people suffer. I know I could not survive a day without hope, the way she has for more than a decade.

By |2018-11-24T01:48:41-04:00March 24th, 2015|2015, Out of Africa|Comments Off on Homeless in Cape Town, part VI

Loggerhead Saved!

Kai Staats: turtle rescue This past Friday I walked to the beach for a short run and yoga session when a surfer walked up and handed me a Loggerhead hatchling, an incredibly small turtle.

I took him back to my apartment complex and knocked on my neighbour Hannah’s door. The look on her face was priceless when she said good morning, but then saw the turtle cupped in my hands.

It was 7:30 am. Hannah called the Two Oceans Aquarium which instructed us how to care for him (her?) until we could make it to town. We placed her on a dry towel inside a small tupperware container and drove to Town. The turtle become more and more listless, eventually not moving unless I touched his shell or front flippers. Even then, almost no reaction. I was afraid she was not going to make it.

Kevin, a marine biologist greeted me at the front counter. I was given a behind-the-scenes tour as we worked our way up a few flights of stairs to a room full of noisy compressors, filtration systems, and glass aquariums which contained a variety of rescued sea animals. One was a very large turtle which was blind in both eyes, but is apparently recovering.

Kai Staats: turtle rescue

Kevin washed the hatchling in fresh water, removed a barnacle, and then placed her in a deep plastic tray at the bottom of what will be his new home for the coming year. He filled up the tank with room temperature water which in turn heated his container.

Kevin explained that Loggerheads do not nest on this side of the continent, so far south for the water is far too cold. He was likely caught in the Indian ocean current that periodically warms False Bay (and Muizenberg beach). He was adrift for no less than two weeks. Only one in a thousand reach sexual maturity (17-33 years), and even then, they have very low reproductive rates.

Within just a few minutes, the turtle came back to life. I had forgotten how much reptiles are affected by the temperature of their surroundings. The cold Atlantic water and then dry, cool air in the car had slowed her down considerably.

By |2017-04-10T11:17:34-04:00March 22nd, 2015|2015, Out of Africa|Comments Off on Loggerhead Saved!

Silhouette

I know you only by your silhouette.
Walking, running, dancing in the sea’s foam.

I know you only by your outline,
glowing against the rising sun.

I know you only by the shape
of what I hoped we’d become.

By |2015-07-10T06:16:14-04:00March 9th, 2015|The Written|Comments Off on Silhouette

Zen & the Art of Research

Our professor Bruce took us on a 5 days, zen meditation retreat. Yes, a meditation research retreat. How cool / weird / awesome is that?!

We spent 8 hours each day not talking, and then talked about not talking over dinner. Wasn’t all that different from normal research, in my experience. The venue was stunning. A gorgeous, isolated guest farm about two hours South and East of Cape Town.

Thank you Nadeem, Arun, Gilad, Eli, and Martin for a great week … of not talking.

On departure we learned the next group to come through the guest farm is an orgasm retreat. I think I signed up for the wrong week.

By |2017-11-25T00:02:47-04:00March 6th, 2015|Ramblings of a Researcher|Comments Off on Zen & the Art of Research

Concretely Andrew Ng

Today I completed the Andrew Ng open course on Machine Learning

Every morning for the past two months I have awaken (woke? waked? woke up?) at 6 am, on the beach by 6:30, then run, surfed, practised yoga or a combination for an hour. Back to my flat for breakfast and 1-2 Andrew Ng videos until 10 am. Down to AIMS for tea and into the office (where I am distracted by the view of the waves and beach).

Had to watch some of the lectures more than once, to absorb all that was presented. I paused at every formula in order to copy it into my small, spiral notebook. Over 50 pages in all. The first two chapters were hard to get through, but then I gained a kind of momentum–I even looked forward to the videos.

If you desire a crash course to Machine Learning, this is the way to go.

However, I hope to never hear the word “concretely” again.

By |2017-11-25T00:02:40-04:00March 1st, 2015|Ramblings of a Researcher|Comments Off on Concretely Andrew Ng

From Java to Python

Today I engaged Emmanuel in a Skype call to review my first Python translation of his Java code. I then sketched a workflow diagram (in gedit), which I delivered to Emmanuel for his review. Feels good to have made progress, even if just a few lines of code.

Given that I don’t know Java, this is going to be an arduous process.

By |2017-11-25T00:02:33-04:00February 28th, 2015|Ramblings of a Researcher|Comments Off on From Java to Python
Go to Top