Blog of Sara Jakša

Visualizing Network with Python and Networkx

Graph of Heroes characters interacting in the first episode

I have borrowed an O'Reilly's book Data Science from Scratch by Joel Grus from the library. The examples in the first chapter weren't interesting in their problem content, as I am not that interested in the social networks. But there was a nice visualization of the network and I got interested in learning first how to visualize networks.

I read the whole first chapter, and there is nothing. I read a chapter on visualization, and there are examples for scatter plots and histograms, but no networks. I ended up going to he chapter on analyzing networks, but there was nothing there either.

Now interested in the problem, I decided to hit the Google and try learn by myself how to visualize it. I took an episode of a series that I recently watched and decided to get the data by rewatching the first episode. I ended up using Networkx and matplotlib, simply because that was one of the hits on Google.

The picture above is the visualization that I ended up creating with the code that is written down below.

    import networkx as nx
    import matplotlib.pyplot as pyplt
    from collections import defaultdict

    # Data used to create a graph. Users is a list of dictionaries of all the named people that appear on Heroes season 1 episode 1. Meetings is the list of tuples that indicate which people had interaction with one another
    users = [{"id": 0, "name": "Charles Deveaux"},
    {"id": 1, "name": "Peter Petrelli"},
    {"id": 2, "name": "Nathan Petrelli"},
    {"id": 3, "name": "Simone Deveaux"},
    {"id": 4, "name": "Mohinder Suresh"},
    {"id": 5, "name": "Nirad"},
    {"id": 6, "name": "Noah Bennet"},
    {"id": 7, "name": "Niki Sanders"},
    {"id": 8, "name": "Ando Masahashi"},
    {"id": 9, "name": "Micah Sanders"},
    {"id": 10, "name": "Claire Bennet"},
    {"id": 11, "name": "Daniel Linderman"},
    {"id": 12, "name": "Angela Petrelli"},
    {"id": 13, "name": "Zach"},
    {"id": 14, "name": "Hiro Nakamura"},
    {"id": 15, "name": "Tina"},
    {"id": 16, "name": "Isaac Mendez"},
    {"id": 17, "name": "Sandra Bennet"},
    {"id": 18, "name": "Lyle Bennet"}]

    meetings = [(2,12), (1,2), (1,12), (6,10), (6,17), (10,17), (1,16), (3,16), (1,3),(1,4), (1,0), (1,0), (1,3),(0,3),(1,0),(1,3),(0,3),(6,4),(1,2),(1,3),(10,17),(8,14),(8,14),(8,14),(10,13),(1,4),(1,2),(3,16),(12,1),(7,9),(8,14),(13,10),(1,2),(13,10),(7,9),(4, 6),(10, 18),(10,17),(17,18),(15,9),(15,7),(9,7),(2,11),(4,5),]

    #Creates a new graph, puts all people there as a node.
    G=nx.Graph()
    for user in users:
        G.add_node(user["name"])

    #For each pair of people it calculates the weight of the edge based on how many interactions did they have
    weight_meetings = defaultdict(int)
    for meeting in meetings:
        if meeting[0] < meeting[1]:
            meeting = (meeting[1], meeting[0])
        weight_meetings[(meeting)] += 1

    #Puts pairs of people that had interaction in the episode in a graph as an edge.
    for meeting, weight in weight_meetings.items():
        G.add_edge(users[meeting[0]]["name"], users[meeting[1]]["name"], weight=weight)

    #Takes the edges from the graph and put the weights of each edge in a list
    edges = G.edges()
    weights = [G[u][v]['weight'] for u,v in edges]

    #Draws the graph
    pos=nx.spring_layout(G)
    nx.draw(G, pos=pos, node_size=100, node_color = "yellow", edge_color = "orange", with_labels=True, font_size=12, font_color = "blue", width=weights)

    #Shows the graph
    pyplt.show()

Breaking Up with my Toastmasters Club

I have decided that after almost 5 years, I am quitting my Toastmasters club. It was a decision that I have came to around a couple of months ago and even decided on the date, which is today.

In these years, I have noticed that a lot of people don't pull that much deliberation to thinking in which hobbies or organizations they are investing their time and in which they don't. A lot of people stopped coming, but when asked, they always replied that they will come back eventually. Most never did. And some live in the illusion for more than a year.

Some people do come back once or twice, realize that people changed, and then most of these ones don't come back either. But they have just wasted all these months thinking about coming back.

One analogy that I like to think about is to compare the relationships with people with the relationships with organization. Just like sometimes it is better to change the social environment, it is also better to sometimes rethink what kind of relationships do you have with organizations in your life.

For me, the reason why I started to attend Toastmasters was because I wanted to improve my social skills. I was still naive back there and I believed the books. I wanted to be an entrepreneur and all the books on the entrepreneurship said that social skills are important for it.

Let be honest, when there are two people which are identical, but one have a better social skills and the other doesn't, most people will always choose the one with the better social skills. Even if social skills are unimportant in that specific situation. And that does not hold true only in entrepreneurship, but almost everywhere.

So I came there, got a panic attack and loved it. I stayed, but over the years it went from something that I needed to calm down afterwards and sleep longer the next day to routine. It does no longer challenge my skills in this department.

I could be saying that I am going to be listening to my co-members and I am going to stay for the sake of the club. But that is never a good idea. The resentment would build eventually and on the end they would be forced to stop me by kicking me out. There is no need for that.

And I am not really a type of person to quietly sit by when I don't like something. I try to change it, even if it might be better to stay as it is.

Just like people break up, get a divorce or in some cases kill their partner, I decided to to the same with the club. And just like the clean break is the best possible way to do it, I plan to no go even close to anything Toastmasters like for at least a couple of months. I don't like to be reminded of the things that have passed, just like I imagine that immediately after the break up, partners don't really want to hear about one another.

That way, I am going to get a mental space that I could devote to the different pursuit. Attention residue was not really used for long term commitments, but tasks, I think it still explain what is going on in our head. As long as the task is not complete mentally and in reality, we have thoughts distracting us.

It is only by deciding to quit something that we can recover that mental space and use it for something else. What I am planing to use it for? I have no idea yet. But I am sure, that if I really needed an idea, I can always just ask my Ti to step aside and let the Ne have its fun.

Cottage Cheese Cake Recipe

Cottage Cheese cake

My mother is currently on some sort of low carbs diet. I guess each person has to try different things in their life. Anyway, that was a great excuse to try and make a new snack that was in accordance to her diet. Which made it harder that not only were 'usual' carbohydrates, like flour and sugar were clearly out of the picture, she is not even allowed to eat most types of fruit.

I ended up making a cottage cheese cake with the dough made of nuts. It also allowed me to use the grated hazelnuts, which I was eyeing in the drawer for quite a while.

Ingredients:

  • hazelnuts
  • butter
  • lemon
  • cottage cheese

Recipe:

  • Mix hazelnuts and melted butter to create a dough
  • Put dough in the refrigerator for an hour
  • Mix cottage cheese and lemon
  • Put first the dough, then the cottage cheese mixture in the pan
  • Bake for 45 minutes at 185°C

Suggestions:

  • For me, the dough ended up being brittle. I can only speculate, but I think I used too much butter
  • The taste was way too cottage cheese-like for my taste, so when I ate it, I mixed it with either chocolate ice-cream or whipped cream with raspberries

Why People are Taking Pictures

Japanese Display made out of Chocolate

Unlike most people that I know, I don't have a lot of pictures on my computer or my phone. I recently listened to a person that was clamming that 1GB of space was getting filled with pictures in a matter of days. Another one has more pictures that can reasonably look over in a year. Unless, only I get bored at looking at the different pictures.

I do have a couple of pictures from the chocolate museum in Eger, a small but quite nice place in Hungary. I still remember how I actually took them. I let a local woman there show me around and she took me to the chocolate museum. Everything there, including everything on these pictures is made of chocolate.

She really wanted me to take a couple pictures and I did not understand why. On the end it came to two basic reasons: either to show other people or to remember it.

I usually prefer to make a point from my experiences to other people and not just say it for its own sake. I can make this points just as well in speaking and writing and don't need pictures for that. Plus, for me the medium of words came a lot easier than the medium of pictures and video. I will let the people that are actually proficient in these media create them, as it will bring a lot more value in the world.

I also seems to have more of a trouble remembering than forgetting. At least for now. I can still remember how the city looked like in Leipzig or Eger, where I lived for a couple of months. I can ever remember places from Munich, Vienna, Prague and London, even though I have only been there for day at the time and in some cases more than a decade ago. I have more of a problem that certain pieces of my history push to my formind all the time. I don't need additional remembering.

Also, I don't want to be like my grandmother, who thinks that in some ways I am still the same than I was when I was 3 years old. I hope that this is not true.

Also, taking photos comes with the drawback, as not actually being in the moment when experiencing it. I had an impulse to just write something down or that that subject could become a good article or scene in a story. Other people just seem to have these impulses turned toward taking photos or sharing on social media.

I don't say that it is wrong to accept that consciously. I just don't like that people ignore it when they try to convince you why something is worth doing. At most I get the complain about the storage size. Nobody mentions the focus lost, the time spend first selecting them, then organizing them and then reviewing them. Because, the last point is not done, then why take pictures at all?

Well, now you can also enjoy the great creations made out of chocolate. It is no substitute to going in person, but why not.

On the end, I just wanted an excuse to put all these pictures on my blog.

Chess set made out of chocolate

Japanese display made out of chocolate

Dog made out of chocolate

Decorated eggs made out of chocolate

Fairytale scene made out of chocolate

Head of a goddess made out of chocolate

Head of a goddess made out of chocolate

Russian dolls made out of chocolate

Shoes made out of chocolate

School supplies made out of chocolate

Cheeseless Pizza Recipe

Cheeseless Pizza

I still had some pizza dough, but I did not have any cheese at home. This below is my attempt at cheeseless pizza.

I think it would actually test good, if the tomato would not overpower everything. Maybe next time I should stick with the canned ones, instead of using the fresh ones.

Ingredients:

  • flour
  • water
  • olive oil
  • yeast
  • sugar
  • tomatoes
  • eggs
  • mushrooms
  • garlic
  • herbs (basil, oregano, parsley, cayenne pepper, salt)

Recipe:

  • Mix yeast, sugar and some water
  • Mix water and olive oil and some flour, add yeast mix
  • Add flour until the dough is not sticky
  • Squash tomatoes, and oregano, basil and cayenne pepper and shimmer for 10 minutes
  • Mix olive oil with garlic and parsley to make a sauce
  • Whip eggs
  • Roll the dough until it is thin
  • Stab through the dough with a fork and put an olive oil on it
  • Put tomato mixture, then eggs
  • Cut the mushrooms
  • Put sauce and mushrooms on the pizza
  • Bake for 15 minutes on 180°C

The Desire of Each Function

We all have and use 8 different personality functions, sensing, intuiting, feeling and thinking, each in the introverted and the extraverted directions. But each of the function brings with it a backpack, which a lot of different stuff packed in it. One of them is their ultimate desire.

The more we use a specific function, the more important is their goal to ourselves. It is in a way like a Maslow's pyramid, where the lower levels have to be met to the satisfactory level, to be able to care about the levels about it.

The same way is with these function. For example, for an ESFJ, they will first care about the Fe goal. When the Fe goal is going to be met, then they will turn to the Si goal and tried to met it as well.

I sometimes wonder if there is a way to meet all eight of them, but some of them seems to be fundamentally opposed. For example, the goal of Ne is the exact opposite of the goal of Ni.

So what are these desires?

Extraverted thinking desires order. They want things to be done in a efficient way and the best way to do it is to find the way that is the most efficient and then repeat it until something more efficient comes this way.

Extraverted thinking desires the truth. They want to question every imaginable assumptions, just to make sure that the final conclusion is true. They will also remember all of the steps that were taken to reach the conclusion.

Extraverted intuition desires possibilities. It lives in the world, where everything can be connected to anything else. They are the explorers, or like the child in the candy shop. Both of them see the world as full of wonder.

Introverted intuition desires direction. It explores the world of future, imagining what the future is going to bring and what to do, so we can actually reach it. They are the great planers.

Extraverted sensing desires experience. It lives in the world where it seeks new experience, let that be sensory, cognitive, physical or something else. They are the great adventurists.

Introverted sensing desire memories. It creates, stores and reviews the vast library of information for the later access. It is like a librarian that knows their way around the newer books, as well as the old manuscripts stored there.

Extraverted feeling desires harmony. It makes sure that the relationships between people, or even between people and other beings and things are in as good shape as possible. They want to make sure there is no rough edges.

Introverted feeling desires self-expression. It wants to show the world their personality, their self. The canvas of life is to be filled with personality of the artist in the best way then know how.

So if we return to the previous example of an ESFJ. These people will first try to make sure that there is harmony in the group. When they managed to achieve that, then they will try and make as many memories as possible. That is why they sometimes stereotype them as a good hosts.

Each type can be analyzed like that. I am an INTP, and I first try to find the truth, which I am sure some people are already sick of my questions. Then I use the mental image of the system that I created this way to try something new, and for most people unexpected.

I know an ENFP, who has the desires of possibilities and self-expression. That person mostly project is in the other people. When met with a new person, they will quickly discover that apparently they have a lot of skills and good ideas. Then she will go and encourage them to be who they really are.

I also know the INTJ, who has the desires of direction and order. I have never seen a person that would calmly talk about their whole industry going under (direction), but at the same time no complain about their job. It seems that he is quite content doing what he does (direction + order). It is eerie for me. Also he is the one that always points us the flaws with my ideas, mostly based on the assumptions of what the end goal is, but mostly connected to inefficient use of time to achieve it (order).

I could pull another examples for my mind, but I do believe that I made my point clear enough. It is the desires of out function that also have an affect on out life. It is better to be aware of them, as we can only control what we are aware of.

Which Function to Improve in Order to Grow?

I believe that no matter which personality function a person is trying to improve, they are going to be growing. But these are some functions where they are already good enough, so there is a diminishing return to improving them, like the dominant function. Some of them might be harder to even start on. At least for me, the trickster function is like that.

I don't know for other people, but from my experience, the best way to improve is to let the second function out to play.

I notice the difference, because I remember when I started to relay more on my Ne, than on my Ti. And that was when I had my study exchange in Germany.

The reason was that before that I did not really needed to use it. Living in my home town, being part of the regular communities, living my life, it all just made sense. I had, through my life, observed and created a mental model of what was needed for a normal life.

Then I come to Germany. I got lost. Then I had trouble using an ATM, because the card has to be turned in a different way. I was not the only person having problems with it, as I later encountered two Greek students that had the same problem. I had no preexisting social life. I had no idea how the faculty that I was attending worked. Hell, I lived with two other women and when I came there I had no idea what the rules of living together were. Not to mention, the pamphlet with the process of how to connect to the internet could just say to use ssh, instead of a complicated process, that only worked on Windows.

Ti can be a pretty good analyzer, but it needs data. In order to get data, an extraverted function has to collect it. So what my Ne did was to start looking for a different possibilities of what is possible around me. Then it pushed me to try it.

Then the results were analyzed by Ti, and in about two to three weeks I was already so confident in my surroundings, that I could live there for the rest of my life.

But after these couple of weeks, I did not really get back to the old path. At least no entirely. I liked the experience so much, that I have tried to incorporate it into my life in a more active way.

It is that experience that allowed my to start a lot of projects in my Toastmasters club. It was that experience that pushed me to go to a summer school with students from Faculty of Computer Science, even though I at the time studied at the Faculty o Economics and was only doing little programming for fun. It was that experience that allowed me to make my time studying a lot more flexible. If not for that experience, I most likely would not be writing this blog either.

For me, allowing the auxiliary function out to play was the most growth like experience that I have discovered so far. It does not compare with my experience trying to improve Fe (my anima), which, while it was helpful, it was the most stressful thing. Or my Si (my eternal child), which is sometimes kind of boring and sometimes fun. Or Te (opposite personality) which was just frustrating with no payback. Or Se, which just did not help so far.

It was Ne (auxiliary) that was not only fun and exciting, but also the one that made me a different person that I was before.

Social Media is Making us One-sided

In the last fifteen years social media went to practically nonexistent, to being ubiquitous. It is really anybody that does not use them. I know that in the student generation, it is assumed that people have Facebook, and if a person does not have it, it does not exist. Really, I once told another student, that I met in the Japanese culture festival that I don't have a Facebook. She told me that she does not remember to contact anybody that she does not have on Facebook as friends.

There seems to be quite a lot of negative effects of social media. Frequent uses of social media are more lonely. They have a lower attention span. Their skills of ignoring irrelevant data is atrophying.

But today I am going to ignore what the different studies have already found. Instead, I am going to think about what effect does a social media have on the personality type.

A couple of years ago it was still believe that social media attracts mostly introverts. This particular piece of information is no true. Just look around at who is using the social media. They are both introverts and extraverts. I read one study that found our that extraverts use social media more frequently than introverts.

I actually believe that social media in fundamentally an extraverted activity. It is a flux of activity, with constant new information coming in, with no end in sight.

There is a cortical difference between the introverts and extraverts. Introverts are a lot more sensitive to any kind of input and they reach a threshold a lot quicker. That makes them a lot less likely to seek any kind of new experience.

Extraverts are different. They are less sensitive to the input, and they need a lot more of it to reach a threshold. Which is why they seek the new experiences all the time. They are just not simulated enough.

These differences makes the social media much more suited for the extraverts than introverts.

But each of us have both extraverted and introverted functions. We each use all the functions, some more than others. The two most used ones are of both types, one is extraverted and one is introverted.

Being constantly plugged in to the social media constant stream is overusing the extraverted functions in us, and it underuses the introverted functions in us. Before anybody wants to complain that they are not constantly on the social media: There was a study that showed that younger generation spends on average 5 hours per day on the phone. With 24 hours per day, and assuming 8 hours of sleep, that is almost a third of the waking hours.

The effect on the introverts is probably going to be seen first. By being plugged in the current matrix, excuse me, social media, they are no practicing their dominant function. Using dominant function is like a staple food. Sure you can survive without it, but it is not going to be healthy.

I wonder if it can eventually lead to the atrophy of the dominant function. If it can, it would be like destroying the best tool in the personal arsenal. Or maybe it is such a fundamental part of us, that it simply become dormant.

The extraverts can use their own dominant function to access social media. I imagine that in the sort term, there are not as many drawbacks for using it than for introverts.

But by using only the dominant function these people could be walking into a trap. Having only dominant function differentiated leads, at least according to Jung, to the collectivism. You know, that pesky concept that is behind things like mass consumerism or communism.

By using the social media extraverts are giving up a real opportunity for growth.

On the end, social media is such a one dimensional experience, that there is no way that I can perceive that being constantly connected to it can in any way help us toward being a better human being.

Recipe

Apple Strudel

So, what does a person do, when they figure out that in the back of the freezer, there is some sort of the strudel dough? At least I assume it was, because frankly, there was no label or words or anything written on it.

Then, we also have apple tree at home, and now it is the time for apples. But some of the ones that fall on the ground are either too sour or they had already started to rot. It does not feel nice eating an apple, and at the same time seeing the rotten parts of it. On the other hand, the healthy parts are still tasty.

And I was in luck that my mother had requested sour cream and cream for whipping, so I had a lot of margin of error. Dessert have to be really go for the whipping cream to not improve it, and here I was more afraid that it is going to be special in a different direction - like completely uneatable.

Ingredients:

  • strudel dough
  • apple
  • sour cream
  • cinnamon
  • sugar
  • cream for whipping

Recipe:

  • Put the strudel dough outside to thaw
  • Grate apples
  • Mix apples with sour cream, sugar and cinnamon
  • Put the mixture on one part of the strudel dough and roll
  • Wipe the cream for whipping (I needed around 5 minutes)
  • Bake for 20 minutes at 180°C
  • Serve peace of it topped with whipped cream

Suggestions:

  • Some recipes recommend the lemon. I did not put it in, because I like my my sweets to be actually sweet. But if you want to add less sugar, and for it to still be tasty, then I think that lemon can help, as it makes the taste of the whole dish more spring-like
  • When I put the strudel dough outside, I immediately tried to pry the sheets apart, but they broke. It was a lot easier and more successful, when I tried it after it completely thawed

The Difference in Knowledge Acquisition for Introverted and Extroverted Thinkers

Even though INTP and ISTP both have a Ti as their dominant function, there is quite a bit difference in their representation. INTP are known as people that have breath of the knowledge, while ISTP are known as specialist in one specific knowledge.

I don’t agree with that notion on any level but very superficial. I think that just like ISTP, INTP go deep into the subject matter. It is just that their auxiliary Ne sometimes makes them check more than one speciality.

This contrasts with that little subset of Te dominant or Te auxiliary that I have met so far. They are much more likely to have opinion on basically any subject that a person can bring up.

These difference come from the fundamental differences in how Ti and Te relate to the world.

Extraverted thinking is an extraverted judging function. What does this imply is that extraverted thinking is much more interested in what is going on in the outside world than the inside one. The introverted thinking is the reverse: much more interested in the inner world than the outside.

Other functions have this as well. Let us take sensing. Extraverted sensing is interesting in what is going in the inside world. The introverted sensing is much more interesting in the current feeling of the body and sense of self.

That leads us to the first difference, and that is how both of them are perceiving the subjective data, like personal impressions, experience and their own learning.

Extraverted thinking finds the subjective data to be there only to obscuring the real truth. On the other side, introverted thinking accepts subjective data as completely valid facts.

Which also brings us to the second difference, how they come to the acceptance of a fact.

Extraverted thinkers are much more likely to simply accept an assumption, assuming that they can be certain that it came from the credible source. So a pupil in primary school with the extraverted thinking is much more likely to simply accept that the Earth is round, because it says so in the textbook. They assume the facts are true, because they want to reach a conclusion as quickly and as efficiently as possible.

No that they will believe anything they hear.

Introverted thinkers are much more likely to question the facts. In the true perceiving fashion they are much slower to reach a conclusion. They painstaking make sure the data and facts are corrects beforehand. The good example of this is my diet. You can tell me that some diet, like eating only organic fruit and vegetables is good for me. But I tried it and I did not notice any difference. So for me this fact is not right. But I could only said that after I tested it for myself. And sometimes these tests can only be done in head, which is probably how the mental exercises, like the Schrodinger cat come in existence.

Also, knowing why something is true can be a valid shortcut for reaching the acceptance of the validity of the fact.

This upper fact does point to another difference. Introverted thinkers are people that are enjoying the journey and the journey itself is much more important than the end. They are the one that are more likely to take action.

The extroverted tinkers are different, as they want to reach the results, so called end, as soon as possible. The enjoyment of the journey is not as important to them. They are more likely to reach a results.

Which clearly shows, when you ask a person a question that is from from the area in which they are competent in. Introverted thinkers are going to start pondering and questioning the subject at hand. Extraverted thinkers are going to find some facts and reach a conclusion as soon as possible.

Let me return the the upper point, that I don’t think that INTPs are the breath types of thinkers. From the upper data, we can say that extraverted thinkers are more of the breath types of thinkers, while the introverted thinkers are more of a depth type of thinkers. So from this analogy, INTPs would be, like ISTPs, more of a specialists.