Approval voting
Children approving their teacher (Photo credit: Wikipedia)
This article is an update of the the previous one.
It adds the approval voting method and fix few errors.
Method explanation
Each voter can apprrove as many candidate as he wants.
It can be seen as a majority judgement with only two possible notes.
It can also be presented as the same process as a time management system
(such as doodle).
Implementation
To compare with other methods, I start with the ballots for majority judgment
and for each ballot approve all candidates whose note is above a threshold.
def jm_to_approval(jm_vote):
"""transform vote for "juement majoritaire" to approval list."""
notes = MajorityJudgement.notes
values = dict(zip(notes, range(7)))
return [name for name, appr in jm_vote.items() if values[appr] < 4]
For the rest, simple counters are enough:
- to count number for each candidate
- to count the total number of voters
Graphical representation rely on plot bar.
Results
The results can be different from the one from other voting methods.
I'm surprised by the difference between Borda method and approval method.
In Borda method, the candidates after the third one have really few points
compared to the first ones.
In the approval method, if a voter approve 4 candidates, all those candidates
have the same approval (no distinction between them).
Approval method
Borda method (same votes)
This may also come from the threshold I put.
I choose this threshold because I think a voter approve
all the OK.
Nevertheless, it seems
the number of approval
(archive)
can be less than expected (less than 2 approval in average).
I find this number really really low.
Perhaps it is due to the political offer that does not correspond to voters
expectations.
Alternative voting systems
(not Condorcet) duel (Photo credit: Wikipedia)
Many voting methods exists, and I want to explore results yields by some of
those.
For the argument stating one specific voting method is better than another
one, I let the reader see
this article from science étonnante (fr) ,
this video from la statitique …
Read More
Cache implementation using weakref
Bird's cache (Photo credit: Wikipedia)
This article presents a quick example of how to use
weakref to implement a
home-made cache mechanism.
Let's use the following use case:
- Let's consider items:
- items can be stored on a storage
- items can be retrieved from storage
- items are identify by an ID …
Read More
Tkinter and Asyncio
Asynchronous process results waiting (Photo credit: Wikipedia)
Graphical interfaces are typically the kind of object that can take advantage
of asynchrounous programming as a GUI spend lot of time waiting for user input.
Tkinter <https://docs.python.org/3/library/tkinter.html#module-tkinter>_
is a kind of standard for …
Read More
Latex generator using Jinja
Kawasukune-jinja (Photo creadit: Wikipedia)
The goal is to generate a PDF file using python.
I decided to generate \(\LaTeX\).
Pipeline
I decided to use jinja as its documentation
mention it.
\begin{equation*}
\boxed{\text{Jinja template}} \xrightarrow[\text{python}]{}
\boxed{\LaTeX} \xrightarrow[\text{pdflatex}]{}
\boxed{\text{PDF}}
\end{equation*}
The …
Read More
Wikipedia crawling (part II)
Crawling (Photo credit: Wikipedia)
This article is the follow up of the one about
wikidata crawling.
Wikipedia has specific
infobox templates.
This is the normalized way to enter specification inside wikipedia articles.
It provides templates with already defined fields.
For example the
planet template
has fields such as periapsis or …
Read More
Wikidata crawling
Graph database representation (Photo credit: Wikipedia)
I wish to have reliable data about vehicles. I decided to rely
on one large source, namely Wikipedia. I chose it because it is reviewable and
most of the time reviewed, and regularly updated and completed.
Wikipedia - Wikidata relationship
Wikidata items are made to …
Read More
Differential equation in python
Second order differential equation (Photo credit: Wikipedia)
In python, differential equations can be numerically solved thanks to scipy .
Is usage is not as intuitive as I expected.
Simple equation
Let's start small.
The first equation will be really simple:
\begin{equation*}
\frac{\partial{f}}{\partial{t}} = a \times f …
Read More
Zombie propagation
Zombie favorite food warning (Photo credit: wikipedia)
I recently read a paper trying to model a disease propagation.
I wanted to play with this model.
The model
The model is know as "SIR" as it divide the population into 3 groups:
- S: suceptible to become a zombie
- I: infected …
Read More
Virtual Jupyter
Jupyter and a Python (almost) (Photo credit: Wikipedia)
Following the isolation of python environements
and given I use jupyter notebooks,
isolating jupyter kernels inside virtualenv is a logical step.
To do so, you must install a new kernel using the ipython you installed inside
your virtualenv:
- Create your virtualenv
- Install …
Read More