# 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.

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.

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

# 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

# Food: food prep!

I have taken a long hard look at how much I spend and waste on poor planning for grocery shopping. After reading these entries on The Penny Hoarder, Every Dollar, Cooksmarts and Cupcakes and Cashmere I have a list for myself:

Limit shopping to two days a week, if I don’t have it, I’ll have to make something from the pantry or freezer

Double any recipes such as chilli, soups, dals, stews etc. to freeze for another dinner

Wash and pack away all fruits and veggies as soon as I get home from the store e.g. carrot sticks, broccoli florets…

If I have a spare ten minutes the night before or in the morning, do some dinner prep like roasting veggies, making a sauce/dressing or boiling something.

Purchase attractive storage items and lunch boxes so that I feel like eating out of them

Purchase water bottles and fill them up the night before when making lunch

Once a week sit down with a drink and some music and using pantry ingredients find one or two new recipes for the week. e.g. I have so much quinoa that hasn’t been used, I decided on quinoa burgers

Go out once a week for lunch, dinner and breakfast and that’s it!

Instead of going for regular brunches, have a yummy imitation brunch at home with friends and then go out for a coffee afterwards. Some of the most tasty ideas are an avocado toast bar that people can customize (radishes, kimchi, chopped pistachios and eggs), brioche French toast with seasonal fruit or Indian spiced eggs with goat’s cheese and fried potatoes.

I have been following these steps for the last few months and still have a way to go, but have already saved about one third in food costs and definitely been eating better. Lunches are still hard, it’s so tempting to buy a sandwich or something convenient, but having a tasty and varied lunch packed already makes it much easier to resist.

As far as dinner goes it’s still half organized declicious-ness and half haphazard thrown-together stuff.

Breakfast:

Monday: Egg white scramble, swiss chard and turkey bacon

Tuesday: Tofu scramble with fried egg on top, mushrooms and spinach

Wednesday: Protein pancakes, fruit and maple syrup

Thursday: Fried egg and cheese tortilla, avocado

Friday: Egg white scramble, kale and turkey bacon

Saturday: Croissants, jam and eggs at cafe

Sunday: Shakshuka with chickpeas and asparagus

Lunch:

Monday: Arugula, romaine, yellow bell pepper, chickpeas, mozerella, walnuts and flaxseeds

Tuesday: Chopped cabbage, red bell pepper, veggie burger, feta, sunflower seeds

Wednesday: Lunch out: BLT sandwich with fries hurrah

Thursday: Arugla, romaine, tuna salad, cucumber, olives

Friday: Chopped cabbage, black beans, sweet potato, brocolli

Sunday: Dal and rice with some kind of veggie

Dinner:

Monday: Pan-fried salmon with teriyaki sauce, soba noodles and asparagus

Tuesday: Indian cauliflower and potatoes, ladyfingers, rice and dal

Wednesday: Thai beef salad from this Bon Appetit recipe was just mind-blowing: fresh, crunchy, sweet and salty

Thursday: Pan-fried tilapia, lentils and tomato and onion salad

Friday: Out for pizza!

Saturday: Kimchi jigae and frozen homemade pork dumplings, broccoli

Sunday: Late lunch, so just had oatmeal with pears