Theorizing and learning by doing, whilst wrestling with Python

My editorial

And so I am experimenting with my thinking. I am writing about choices we make regarding new technologies whilst placing myself in a situation of absorbing a new technology: The Python. I am talking about that programming language, reputed for being particularly useful in studying quantitative data. I thought it would be interesting to write about people’s choices whilst making a choice about new technology. Just to be precise: the variety of Python I am enduring my pains of neophyte with is Python 3.6.2, and besides using the materials provided at the standard library of the Python I am using a book by Toby Segaran, entitled ‘Programming Collective Intelligence’, Published by O’Reilly Media, Inc. (ISBN-10: 0-596-52932-5; ISBN-13: 978-0-596-52932-1). I want to discover a few things. Firstly, I want to rediscover the process of discovering something new. It has been a long time since I really had to absorb some brand new set of skills and understandings. I recently became aware of that: I am writing about innovation and technological change, about whole communities switching to renewable energies but with all that, I am not absorbing any true novelty. Secondly, data science becomes kind of adjacent a discipline for social sciences, and I wanted to discover what can I get more out of Python that my statistical software (i.e. Wizard for MacOS) does not provide. So I want to discover new possibilities, and I want to rediscover what is it to discover new possibilities.

I really started this experiment yesterday. As I am recollecting what I have been doing, yesterday and today, a few patterns emerge. As I mentioned it, I started under a twofold impulse: an idea connected to my research and writing, for one, and sort of a vague peer pressure, for two. Being my own guinea pig, I assume I am somehow representative, and so I peg down those two motivations: curiosity awoken by current activity, and peer pressure, also connected to the present activity. As a matter of fact, I started with implementing Python in my current activity, i.e. in research. I tried to use the basic notations for expressing deterministic choice (see ‘Qu’est-ce que ça fait d’être mon propre étudiant, avec Python’). Then, I used Python to meddle with quantitative data, the one in the CSV format. I played with building strings and sets of values out of that format. I am progressively getting acquainted with the distinction between names, defined in single quotes (i.e. ‘x’), and values without quotation marks. Anyway, I took something I already do with the tools I already have, and I am trying to do it with Python. It is awkward, it is slow, it involves a lot of trial and error. I have to solve new problems. I am confronted with something apparently smart (the Python), which returns dull, preformatted answers in the case of failed attempts from my part. Tons of fun, in other words. Here, I have a second pattern, important for understanding innovation: every time we absorb a new technology, we kind of insert it into our current life and we keenly observe what changes under the impulse. That change involves an initial drop in efficiency. What I am trying to do with Python now, I do much faster and more artfully with my Excel and my Wizard combined.

The drop in efficiency I am experiencing is very much connected to the logic I have to use, or, in other words, to the structure of information. In Excel, I have tabularized structures. In Wizard, I almost don’t pay attention to the raw data, previously imported from Excel, and I focus on analysis, which involves picking up, by clicking, from pre-formatted lists. Anyway, both in Excel and in Wizard, I have a two-dimensional structure, where I move mostly graphically, with a mouse or a touchpad. In Python, I have logical structures akin to typical writing. I have to type all those structures by myself, or copy from Excel and format into the written way. I am becoming aware, I mean really aware that what I used to perceive as adjacent columns or rows of data are, in fact, separate logical structures linked by some kind of function. I encounter two types of challenges here. The most elementary one is the shift from reversible to irreversible. In Python, in order to have any logical structure usable in subsequent operations, like a string of names or a set of values, I have to validate it with an ‘Enter’. Still, after I have validated it, I cannot alter it. If I made a mistake, I have to define a new structure, almost identical to the previous one, save for those corrected mistakes, and to replace it under the same name I gave to that previous one. Defining functions that link different logical structures is much harder for me, at least for the moment.

As I am wrestling with the Python, I recall my early experience with software like DBASE or Lotus, back in the early 1990ies. Those pieces of software were something between the Python and the modern software base on graphical interfacing. I am reconstructing the path of learning I have covered and I am forming another pattern regarding innovation. From DBASE or Lotus, the path has been towards simplification and greater a comfort on the user’s side, whilst creating an increasing complexity on the programming side. What I am doing now, as I am learning Python, is to deconstruct that comfort and simplicity and see what I can get if I rethink and relearn the technology of comfort and simplicity. Just to give you an idea of what I am working with right now (the initiated to Python, I implore magnanimity from your part), I give the example of what I have written kind of on the side, whilst writing what I am writing for the blog. Here it is:

# I want to define a set of people, a set of technologies, and to illustrate the fact of preferring some technologies more than others. So I define my set of ‘people’, as a string: 

>>> people=[‘Geogre’, ‘Chris’, ‘Eleonore’, ‘Kathy’, ‘Miron’, ‘Eva’]

# S***, I made a ‘Geogre’ out of ‘George’; I have to define people again

>>> people=[‘George’, ‘Chris’, ‘Eleonore’, ‘Kathy’, ‘Miron’, ‘Eva’]

>>> technologies=[‘photovoltaic on the roof’, ‘own water turbine’, ‘connection to smart grid’, ‘cycling more driving less’]

>>> scores=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)

# Now, what I want is to connect somehow the scores to the people and to the technologies. I want to figure out some kind of function, which would put those three categories together. Here below you can see a failed attempt:

 >>> for n in people and for m in technologies return(scores [3])

SyntaxError: invalid syntax << # What did I tell you?

#Now, I am less ambitious. I am trying to create a logical structure from just two categories: people and technologies. I just want to put them in pairs, and label that matching ‘experiments with’. Here is what I did pretty intuitively:

>> for n in range(0, len(people)):

                  for m in range(0, len(technologies)):

                                   print(people [n], ‘experiments with’, technologies [n])

# It did not yield ‘SyntaxError’, which is already a plus. After an additional ‘Enter’, I had this:

George experiments with photovoltaic on the roof

George experiments with photovoltaic on the roof

George experiments with photovoltaic on the roof

George experiments with photovoltaic on the roof

Chris experiments with own water turbine

Chris experiments with own water turbine

Chris experiments with own water turbine

Chris experiments with own water turbine

Eleonore experiments with connection to smart grid

Eleonore experiments with connection to smart grid

Eleonore experiments with connection to smart grid

Eleonore experiments with connection to smart grid

Kathy experiments with cycling more driving less

Kathy experiments with cycling more driving less

Kathy experiments with cycling more driving less

Kathy experiments with cycling more driving less

# Oouff, it worked, for a change.

Simple lesson: coming up with structures that work takes experimentation. Experimentation takes time and energy, and still, in the same time, yields learning. Experimenting with new technologies is a trade-off between the time and energy devoted to experimentation, on the one hand, and the learning we have from it, on the other hand. The next step I am trying to achieve, unsuccessfully as for now, is to connect people and technologies to those numerical values from ‘scores’. Here below, you can find a short account of my failures:

>>> list(scores)

[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

>>> scores=[list(scores)]

>>> scores [3]

Traceback (most recent call last):

  File “<pyshell#12>”, line 1, in <module>

    scores [3]

IndexError: list index out of range

>>> scores[2]

Traceback (most recent call last):

  File “<pyshell#13>”, line 1, in <module>

    scores[2]

IndexError: list index out of range

What did I do wrong? Where is the loophole in my thinking? I think I know: what I have been trying to do was to kind of pick up arbitrarily a value from the set of ‘scores’ and connect it somehow to people and technologies. I have been trying to do what I commonly do with Excel: I just sort of tried to match it, as if I were making a table. I was trying to work with the new technology (i.e. the Python) just as I am used to work with the old technology, namely Excel. It does not work. New technology requires new skills and habits. There is that thing about logical structures: the numerical ones are different from the strictly spoken logical ones. Numbers are of different nature than words and letters. If I want to express the preferences of my ‘people’ for particular ‘technologies’, I have to construct a function of preference, i.e. a function which yields a numerical result through a mathematically valid process. At that point, I am becoming aware that I have two alternative logics of constructing such a function: through positioning or through inference.

The first technique consists in ascribing, to my ‘people’ and my ‘technologies’, some kind of coordinates in a virtual space. It is very similar to the Bayesian rectangle: I represent phenomena as a geometrical structure. This structure has a frontier delimiting its expanse, and, possibly, some additional secants, which serve to fine-tune the position of a given point in this space. Positioning looks like the right way to construct a function of preference when position matters. Position is distance of the given point (person, technology etc.) from (to?) some peg points fixed in the given space. In that book by Toby Segaran, I found an interesting reminder about the application of the Pythagorean theorem when it comes to distance in an imaginary space: a2 + b2 = c2. If you have two points, and you ascribe two coordinates to each (actually, this would be a plan, not a space, but who cares?), you can measure the distance between those two points on each coordinate separately, as a difference, then square up those differences, add them up, and take the square root of the so-calculated sum. Summing up, the technique of positioning allows ascribing to people preferences, which result from their relative distance from your peg points or peg axes: conservatism, openness, liberalism etc. The technique of inference assumes that if I have some characteristics X, Y, Z, my preferences are the most likely to be A, B, C and usually those As, Bs, and Cs are the expected values in a statistical distribution. If I am Polish and my friend is French, and France has greater a share of renewable energies in their final consumption of energy than Poland, my Friend is supposed to have stronger a preference for putting photovoltaic panels on his roof, or something in those lines.

I am wrapping up this account of my personal experience with innovation. I use the new technology, in the first place, to reach the same outcomes I commonly achieve with the old technology. I basically squeeze that new technology into the social role I have now. When a lot of people do the same, it means that the new technology, in a first step of collective learning, adapts to the existing social structure. Then, I intuitively use old habits and skills with the new technology, which causes problems, and diminishes my efficiency, and still it is lots of fun, and it makes me learn something new. Once again, as I translate this personal experience into collective patterns of behaviour, the greater the relative distance between the new technology and the old one, the more trial and error, the more learning required, thus the deeper is the trough in efficiency, and the greater is the leap caused by learning for the new technology. Relating it to the old concept of technological determinism by Karl Marx, I can see the weakness of his thinking. We assumed that the greater the economic power of a technology, so the greater possible technical improvements it can bring, the greater power it has to bend the social structure around it. Still, my little experiment brings a new variable: the greater the transformative power of a new technology, the more learning it requires and the less we can predict about how the hell it will change the social structure around it.

Advertisements

Leave a Reply