Tuesday, August 19, 2014

Clojure Data Analysis Cookbook by Eric Rochester

Clojure Data Analysis CookbookClojure Data Analysis Cookbook by Eric Rochester
My rating: 5 of 5 stars

This book is a good tutorial on data science using Clojure. It starts with working with data (access and cleaning up), then the various chapters cover a range of tasks from focusing on numeric computing (performance, parallel processing), statistics (Incanter and other numerical libraries), working with other numerical software (Mathematica and R), graphics, and the web. The topics are actually a fairly complete look at data science, so it feels more like a tutorial than a cookbook.

I found this to be a great text on working with data in Clojure. My background is in technical computing, mostly R and Python although I also use C, Java, and Fortran as needed. I've been dabbling in Clojure, but I had not made the jump from doing tutorials and exercises in Clojure to doing something for real. Working through this book has improved my skills in setting Clojure up and using it for real tasks. The book code also provides a nice example of good programming style (I think) that I can see myself trying to emulate.

A book on data science is necessarily about the practical details of implementation, not about mathematical and statistical methods. Presumably, the reader has another source about the details of various statistical and machine learning methods that they can use to figure out what to do, then the Clojure and Incanter API documents tell you how to do it, and this book is about how to do the 80% of data science that is not about implementing the algorithm, but about how to manage the data, then work to communicate the results of the algorithm in understandable ways. This book is probably what brings me from dabbling in Clojure to being able to use Clojure for real tasks. Well done.

View all my reviews

Saturday, August 09, 2014

Functional Thinking by Neal Ford: Book review

Functional ThinkingFunctional Thinking by Neal Ford
My rating: 4 of 5 stars

Functional programming can often sound like magic, in its promises of greatly improved productivity and near guarantees of accuracy and expressiveness. But one problem is that the examples usually given are those in an unfamiliar form, using languages very different than the procedural and object oriented languages most of us are used to. And the advantages are not apparent when presented. What Ford does in Functional thinking is to present the advantages of functional programming within the context of an object oriented language that can support this, then move to more appropriate languages to show how the advantages can be more clear when the language supports it more directly. It does not stand alone, you will not learn functional programming from this book, but it does offer a more clear argument for why functional programming can useful and better in some circumstances.

The setting that I have seen functional programming explained and taught has always been in the context of demonstrating a functional programming language, such as a Lisp (Lisp, Scheme, Clojure). Or sometimes, a language that has some functional features (R, Python). But I always had to take the commentators word at why this was good. Ford using Java 8 (as it adds some functional features), Groovy, Scala, and Clojure provides a progression from functional features in an object-oriented language (Java), to functional features in multi-paradigm language (Groovy and Scala), to it look in a language that is clearly functional (Clojure). This provides a good look at its qualities by showing how these features improves upon an object-oriented solution, then how it is more expressive and closer to the problem when presented in the cleaner form (i.e. in Groovy, then Clojure). I probably would not have caught the lessons of this if this was my first exposure, and I stopped after the first chapter to watch one of Ford's talks on YouTube so I could get an overview of the book before I finished. But the reward is that it gives context for my learning of Clojure (and functional programming in general).

Not for learning a programming language, but for learning how to think about problems in new ways, enabled by functional programming.

Note: I received a free electronic copy of this for review as part of the O'Reilly Press Blogger program.

View all my reviews I review for the O'Reilly Reader Review Program

Sunday, July 27, 2014

Parenting Month 45: Visitors and limits

Cousins working together on a Blue construct
Cousins playing at the Carnegie Science Center Blue exhibit

This month was marked by my family visiting.  My parents came for a month, and my sisters and nephew came for a week.

The highlight, of course, was grandparents spending time with a new grandchild.  The other highlight was the cousins recurring time with each other. As T and J get older, their interaction becomes richer as both grow in their abilities to deal with other people.

Grandma and grandson at the Carnegie Museum of Natural History

AY has been notable in her responsiveness. As she is the second, we cannot help making comparisons to the only baseline we know. At this time, T was in the midst of colic. In comparison, AY is very responsive, trying out a range of facial expressions when we are talking to her, and vocalizing in call and response fashion. We are also entertained by her kicking and reaching out to things.

Baby looking out from lamb blanket
T is still the very good big brother. He likes to tell everyone that AY talks, sleeps, poops, and cries. He also still read and talk to his little sister, and helps with bath and diaper changing time.  However, the novelty is wearing off, and he is not always as excited to help out as he was.

We have noticed that while T is more outgoing and social (talks and plays at pre-school, tells short stories at home), he is regressing in other areas. We have noted that he used to have a relatively long attention span, focusing on one activity longer than others his age before switching. But it has gotten shorter. This is observable when reading books or when making things (Lego or woodworking).  Another not so good trend is that he is becoming more self-conscious of his limitations. Things that he used to try (and do fairly well) are now approached with a statement of "I can't do it".  While he is still a very well behaved and happy child, we do see some of the not so welcome traits that are probably quite prevalent in preschoolers, some that we are hoping that he skips the worst of. Part of this may come with paying attention more to others his age, and taking on their habits, playing, and capabilities. Some of these are fairly innocuous, like growing a liking for superheroes (and yes, there is one kid in his class that bears most of the responsibility for teaching everyone about superheroes) and the fact that he picks up pop culture (everyone knows Frozen, but Star Wars, TMNT, and others are common. I consider it part of my duty to try to get a step ahead of what he learns from his classmates :-) )  But he has also picked up increased instances of the use of the word 'no' and occasionally trying out tantrums to try to get his way. At this point, we are still pretty successful at working our way around 'no' through humor, and we're trying to teach him that tantrums don't work nearly as well as other things (like reminding him of some of the things we can do with him because we are not worried about tantrums at all)

Hi, I love mei-mei

One more month of summer, then both academic parents go back into a full work schedule, but for now, we are thankful that a relatively relaxed summer lets us have this level of interaction with our kids.

Monday, July 21, 2014

Java Cookbook by Ian Darwin: Book review

Java CookbookJava Cookbook by Ian F. Darwin
My rating: 4 of 5 stars

What you want from a programming language cookbook is instruction on the basic tasks that are needed to form the scaffolding that you build around your application. Language teaching and references can teach you syntax and good practices. Topical books can demonstrate how to tasks in the large. But the cookbook is for the small but necessary tasks. And for me, who does not spend much time in the JavaVM ecosystem, the Java Cookbook is a very welcome addition to my bookshelf.

I spend most of my time doing scientific programming in Python and R, but I am starting to return to the JVM because of the need to deploy what I develop. But while other languages like Jython, Groovy, Scala, and Clojure exist on the JVM, to use them well means you need grounding in Java, certainly most of the instructional material assumes more than passing understanding of the JVM and the Java standard library.

I've been building a prototype application using Java as my means of re-learning Java. Where this cookbook has helped me already is in understanding better how to configure projects, more effective use of the Java data structures and I/O, and some utilities. While I know what I need to do through my experiences in other languages, and Java tutorials and references can identify the libraries and functions that I need, the Java Cookbook provides well written examples that I can use to guide me through the JVM.

There are some warts. This book (like most JVM books) seems to be written with the understanding that the readers are web programmers and I think that the discussion of the options available are filtered with that in mind. But this is a very good reference for those times when you know what you need to do, and it is not the type of thing that gets put into a tutorial.

Disclaimer: I received a free electronic copy of this book through the OReilly Blogger program

View all my Goodreads reviews

I review for the O'Reilly Reader Review Program

Thursday, July 10, 2014

Me and My Big Mouse by Ethan Long: Book Review

Me and My Big MouseMe and My Big Mouse by Ethan Long
My rating: 3 of 5 stars

This is a fun book about a boy who has a pet mouse who he has to take everywhere, but the pet mouse is often very annoying. It is notable in that it has a message, that even something we find endearing can be very annoying. My three-year old son has caught onto the idea that something you like can also do something bad (make messes, break things) and be annoying. He does not quite catch on to the idea that this can be an analogy to a younger sibling (has a newborn sister), so he may be a bit young for this.

The discrepancy between word and picture may be hard to understand at this point, as irony is not yet part of his mental makeup. The pictures are cute, and get the point across of so this book is one that he occasionally asks for. And maybe as he gets older, we can reference it when he does reach the point he regards his little sister as annoying. :-)

View all my reviews

High Performance Python By Micha Gorelick, Ian Ozsvald: Book review

For someone like me who is a technical programmer but did not study CS, I've seen hints on how to speed up Python numerical code, but I only had a vague understanding of the principles and application.  This Early Release version of High Performance Python has examples that demonstrate why certain data structures are faster than others in particular situations, and how to use the various data structures provided.

But what may be unique is the chapter on the ways of speeding up Python through compiled code. There are many ways of using compiled code through Python, C and FORTRAN extensions, Cython and PyPy, and more recently Numba. But this book explains the strengths and limitations for each, along with a number of other ways of using compiled code along with Python that I had not heard of before. There are many references for each of these, but no general overview of this group of resources.

This is still an Early Release stage, so there are some warts. Many of the code examples are raw, and you have to know what you are doing to fill them in and get them to work. A website or Git repository with the source code examples would be very helpful.

Disclaimer: I received a free electronic copy of the Early Release edition of this book as part of the O'Reilly Press Blogger Program.

I review for the O'Reilly Reader Review Program

Sunday, June 29, 2014

Parenting month 44: 2 adults and 2 kids

Two parents and two carriers
There are four of us

This month was notable for a slightly uncoordinated grandparent shift change, so there was a two week period where no grandparents were around, and we became the classic two parents, two kids nuclear family.  And we were in the midst of a traditional one-month confinement, so we had to figure out how to do things and keep the three year old from tearing up the house (as active three year olds who stay indoors will do naturally).  One week of full time day care helped, and T joined daddy on a few father-son outings.  One of those outings was participating in a Red Cross shelter operations training exercise, where he got lots of praise for being a very well behaved three year old; including following daddy from station to station, listening to instructions, role playing a three year old shelter resident, generally entertaining himself during most of the practicums, and taking an active role in the shelter setup station.

T is generally a well behaved three year old. Preschool reports he follows instructions, and now he plays and talks with the other kids and the staff.  His name also is showing up as part of the estimation game (the teachers show the kids in the jar, and some of the kids call out their guesses as to how many things there are which the teachers record, I think between 1/3~1/2 of the kids make guesses).  And of course, he likes going on outings with parents, but he tends to freeze when interacting with others in public. We think that it is a feeling of security issue, if he is secure with us, he will interact, but in different or more exposed environments he gets scared and closes up/freezes.

AY is in her second month. Given that we only have one other child to compare her to, we think that she is quite active.  Her eyes seem to track, arms and legs are being experimented with, and arms seem to go in the same general direction as the eyes. And she has a range of facial expressions. T likes to announce when AY smiles at him.  She has also figured out that when she is in a rocker/bounce seat, kicking makes the whole thing rock. She has the same expression on her face when taking a bath, if she kicks hard enough, the water splashes out of the tub (and usually onto whoever is giving her the bath). Her first experiences of being able to manipulate her environment :-)

Recent research says you should read to newborns.
Recently published research says we should read to newborns.
The other thing with reaching a second month is that there is now a difference between the normal discomfort of being out in the world and specific discomfort.  So AY now has a proper infant cry when she is hungry (which is different than a dirty diaper or sleepy), and she has a very good pair of lungs, just like her brother (proper as a progeny of parents who have run marathons).  And like her older brother, we have noticed the coming of rashes. But this time we know it is diet so the next phase is to see if we can do better than the first one in limiting the suffering (all around).

Next months big thing, the whole family is here!

Saturday, June 21, 2014

First try at gardening: seedlings

Planting parsley and oregano
Adding soil for seeds

This was my first time trying to garden.  The real motivation for doing this was to give my son something to watch grow over the summer. Which means we start in winter/spring. Since I did not care too much about how successful this was, we started from seeds.

First sprout of a marigold
First seedlings
Lesson 1: Using egg shells really does not gives seeds much room to start.

I started seeds in egg shells.  First mistake was not filling them to the top with soil.  In hindsight, the soil in the egg shells gives the seeds room for roots and also protects the seeds from shock.  About 2-3 weeks into it, just as the first seeds started germinating, they got moved outside to be shocked in preparation for transplant, which pretty much killed my entire first batch of seeds :-(

When I finally got some ready for transplant, the problem was that the roots did not have much room to grow in the shell, so I was essentially transplanting a bare plant and roots.  So I probably lost a pretty large portion of these.  One thing that worked better was transplant into a small container that had a few inches of depth, then plant them.  One other thing I would do next time is to put 2-3 seeds per shell, under the understanding that 1 will survive the transplant process.  More than that gets crowded.

Lesson 2: if using egg cartons (or anything else that gets transplanted into the new container, punch holes in the bottom and sides to give water and roots room to a way to get out of the container.

When things got transplanted to small containers (mason jars or something else) they started to grow fast. In particular, the mason jars that I transplanted into (usually 3 egg shells each) quickly got overcrowded, and I ended up pulling out about half of them to transplant outside.

The main destination for these various herbs (basil, parsley, oregano, rosemary and marigolds for variety) was to go in a container garden in the backyard. My containers were built around a tomato, some pepper, and a strawberry plant. Each got an assortment of seedlings that were grown from eggshells.  So at this point, they are all established.  The ones with the tomato are suffering because the tomato is growing very well (and sucking up water and light).  I probably have the pepper container a little crowded (I've been pulling oregano out to make more room.)  And there are a few things that I've been planting in our unused front, just to see how they survive.  And there are a few herbs that we are growing inside, just so they are easier to look at (and we are starting to harvest from these)

Tomato and peppers in containers.  Peppers are newly staked using bamboo.
Tomato and pepper containers