Data Science: What is K means?

If we have a dataset that we suspect can be divided into specific clusters, for example, customers who we think might fall into different types, we can use an iterative algorithm called ‘K means’ to find and refine these subgroups.

What’s the algorithm?

Choose K, the number of groups that you think you’re data is split into

Randomly assign each data point to one of these K clusters

Repeat the following two steps until centeroid assignment doesn’t change for each data point:

1. Assignment step: Calculate the Euclidean distance between each datapoint and each K centeroid. Pick the centeroid that is closest to said datapoint.

2. Update step: Recalculate centeroids, take all the data points’ coordinates in each cluster and calculate the mean coordinate. These are the new K centeroids.

How do you measure “closeness”?

There are several ways of doing this, but the most common is the Euclidean-based distance

as a measure of “closeness.”

How do you choose your intial K?

In the Udemy course, so far, we have not yet had to choose K, as the test data came already grouped into clusters. One way is to use the elbow method where you add more and more clusters to see where the percentage of variance explained as a function of the number of clusters dimishes, and choose the number that does that as your K. I don’t really know what that means yet, will report back when I get to it.

Useful links:

Towards Data Science

Wikipedia

Moving house silver lining

Never move when seven months pregnant, unless you absolutely have to! We recently moved from one neighborhood to the next out of necessity, and it was intense. No big dramas or difficulties but tiring for all involved. I think there is always more that you forget you have to do or pack and as always, things take longer than you expect.

Here is what I’ve learned from the experience and would do differently:

Eight weeks before:

Contact friends for packing boxes and supplies in case they already have them

Gather all the materials you’ll need like Sharpies, tape and knives and stash a these in each room so that these items are handy.

Go through all the rooms and grab all you can for goodwill/ebay etc.

Start packing the non-essentials, labelling clearly that they are low priority items.

One month before:

Try and book cleaners if you can for the move-out clean when all the boxes are gone, you will thank yourself!

Two weeks before:

Freeze meals for the lead-up to the move, you’ll have enough to worry about, so doing this means you will have a few meals you can just defrost and eat when you’ve had enough of takeout.

A week before:

When people offer to take your infant or toddler while you pack, take them up on it! An hour of peaceful packing is like three hours with a child “helping” you.

I cannot emphasize enough: label your boxes with immediate/soon/eventually as well as a detailed description of what’s in there as well as what floor and/or room you want it to go to at the new place.

If you can, book a massage for yourself and any family members involved in the move a few days afterwards, they’ll thank you for it!

Start packing your suitcases with all the last-minute things that you’ll need immediately, plus things like passports and important documents.

Just accept that you’ll have to have take-out the day of the move itself and probably the day after.

After it’s all done:

As long as the bedroom and the kitchen are mostly done, you can do the other rooms eventually, a little at a time.

Celebrate your hard work!

My silver lining despite getting so tired was that we got rid of so many accumulated “necessities” and also purchased one or two beautiful longed-for items that we feel good about having. Here’s to a new start and knowing your own tastes and preferences better in your thirties.

Parenthood: Dysgeusia

This is one of the weirdest symptoms of pregnancy so far, the constant taste of what I can only describe as metallic vomit in my mouth at all times. It never abates, the only thing that makes my tastes buds feel normal is extremely acidic things like orange juice and grapefruit juice. Weird. Wikipedia describes it as “distortion of the taste senses.” Damn right, I feel distorted, I feel grumpy. The solution I have found has been minty chewing gum.

Interestingly, it’s not just pregnant woman who can get this condition but those on chemotherapy, having asthma treatment and also those with a zinc deficiency.

Of course lots of women get a change in their tastebuds during pregnancy, but it seems like for some it continues on until the bitter (!) end. In fact, both my ob/gyn and general doctor told me not to expect it to go away until after delivery, wonderful.

What can you do?

The What to Expect When You’re Expecting website has a few suggestions:

Sour foods

Try changing your prenatal vitamin

Brush your teeth and tongue

Health: Sarcopenia. Basically, will you be able to get up off the toilet?

Sarcopenia, the gradual atrophy of muscles as one gets older scares me. Because we are all living longer and in general, are more sedentary, it is becoming a more common problem. I’m approaching 40 soon-ish and getting terrified of this already: so how do I make sure this happens as slowly as possible?

The good news is that it is gradual, 0.5–1% loss per year after the age of 50, and there seems to be evidence that we can help it slow down. How do you know if it’s happening? It’s not always only visible, “Simple muscle circumference measurement does not provide enough data to determine whether or not an individual is suffering from severe sarcopenia.” so there are other things going on that aren’t necessarily observable.

So what can we do?

1 Exercise?

Even athletes experience this phenomena after reaching roughly 40, with “peak levels of performance decreased by approximately 50% by 80 years of age.” According to Harvard Health Publishing, progressive resistance training is the key. “In fact, a recent meta-analysis published in Medicine & Science in Sports & Exercise reviewed 49 studies of men ages 50 to 83 who did PRT and found that subjects averaged a 2.4-pound increase in lean body mass.”

2 Nutrition?

There is no current clear research on this, with some advice saying to supplement with Vitamin D when one is deficient but that’s about it. (Sayer, A. A. (2010). “Sarcopenia”. BMJ341 (aug10 2))

What about protein I hear you ask? According to this Harvard Health Publishing article “Older men can suffer from anabolic resistance, which hinders our ability to break down and synthesize protein, so we need to eat more.” Hmm, so no harm in upping your protein intake I guess.

3 Medications?

No approved medications so far for halting or reversing this process.

Hormones such as testosterone might have some positive effects but they also currently have negative side effects. ( Kunihiro, Sakuma; Akihiko Yamaguchi (28 May 2012). “Sarcopenia and Age-Related Endocrine Function”International Journal of Endocrinology. 2012). Hormone Replacement Therapy can ” increase lean body mass, reduce abdominal fat in the short-term, and prevent bone loss. According to WebMD However, there has been controversy around the use of HRT due to increased risk of certain cancers and other serious health problems.”

So it seems the safest action is lots of resistance training alongside your regular cardio as well as making sure you are taking the correct supplements for your age and possibly increasing protein intake. With regards to exercise, it is hard to mix it up, I find myself doing the same old exercises when left to my own devices (my favorites, which i’m sure coincide with what’s easiest!) for legs: reverse lunges with weights, sumo squats (a bit tricky with baby bump right now but adapting it) and step-ups onto boxes with weights. For arms: bench press, tricep dips and pulls are my go-tos. To mix it up, the Nike app (https://www.nike.com/us/en_us/c/nike-plus/training-app) is really good at forcing you to do new exercises, as are Instagram accounts like Alexia Clark’s.If it’s feasible then I guess doing regular muscle mass assessments, such as the InBody one would be a great idea to monitor how your muscle mass is growing over time.

Data Science: Blogs and sites

From lists on these Medium, Udacity and KDNuggets, here are some of the pages I read most often:

  • The Mode one is ok, not sure it’s super useful for me right now, a fun article though are from Medium on getting free lunches using Python
  • O’Reilly , this article on the difference between data engineers and data scientists