Public holidays in Ethiopia

I enjoyed hearing from people who liked the Current Ethiopian time page. I thought it would be a good complement to have another page with a list of Ethiopian holidays, and most importantly, the upcoming holiday. You can see it live on www.time.ertale.com/holiday.

The following holidays are listed,

ገና / Christmas
ጥምቀት / Epiphany
አድዋ ድል ቀን / Adwa
ስቅለት / Good Friday
ፋሲካ / Easter
የላብ አደሮች ቀን / Labour Day
የአርበኞች ቀን / Patriots’ Day
ደርግ የወደቀበት ቀን / National Day
ረመዳን / End Al Fitre
አረፋ / Eid Al Adaha
እንቁጣጣሽ / New Year
መስቀል / Discovery of The True Cross
መውሊድ / Birthday of the Prophet Mohammed

Enjoy!

Using R from Java and thoughts on technology choice

******Please read this post at my new blog site, AInsightful. Thanks!******

R has some very useful statistics libraries. It’s an excellent langauge for manipulating and graphing data. What would take multiple lines of Java (or even Scala) code can elegantly be written in R without code looking obscure. One downside is that all that good stuff is hidden from the software industry which mostly uses the mainstream languages such as Java, C# and C++.

Dockerr

That’s is why I recently put together dockerr, a dockerized R server with sample java/scala clients. All the ingredients were available. All I did was put things together and document them.

But why?

Any engineer would naturally want to avoid complications and look for a solution that doesn’t involve calling yet another service. A new service is an additional worry. You need a host, monitoring, upgrades. However the only mainstream language that has excellent coverage of statistical and machine learning methods is Python through Scikit and supporting data analysis libraries Pandas, Numpy and Matplotlib. Although Weka is written in Java, it doesn’t have a strong community like R and Scikit do. Being written in Java has its downsides too. Import statements, class declarations, OO paradigm and generally its verbosity make it less favourable for data analysis tasks. Here is for example code fragments to work out the mean of three numbers in R, Scala and Java.

mean(c(1, 2, 3))
val x = List(1, 2, 3) x.sum/x.length
import java.util.Arrays;
import java.util.List;
List<Double> integers = Arrays.asList(1.0, 2.0, 3.0);
double x = integers.stream().mapToDouble(Double::doubleValue).sum()/integers.size();

One doesn’t suddenly make their code compile against a data analysis library and start using it in production. There is a bit of work to do before that happy moment – data cleaning and several iterations involving various data plumbing work, data visualisation, training, tweaking parameters, testing and graphing results. So it’s wise to pick a language that makes these tasks relatively straightforward. And like what I discovered, it’s wise not to spend too much time searching for good data analysis libraries written in Java.

There are also MLlib and H2O, powerful machine learning frameworks written in Java. They put big data at the core of their architecture. The array of algorithms supported and their community size is not a match to what R and python have to offer. So support is limited. If the method you are after isn’t implemented then you may have to do it yourself or wait until someone does it. Their suitability for big data comes at a cost too, particularly for MLlib since setting up the framework and following the Spark programming model can be an overkill for small problems. H2O’s sdk for R and Python make it more attractive here. Running an H2O server is easy as well. You just download and run the jar.

Since I talked about Rserve, I should also mention the Java-R interface JRI. It provides a Java API to locally installed R. It sounds nice in the beginning, and even though I haven’t investigated it in anger, I wouldn’t choose it as a solution because it leads to a monolithic application that runs inside a single JVM. The micro service architecture works better here.

I’m now convinced that calling Rserve from java isn’t a bad idea after all. Dockerr is just a start. More can be done to an Rserve container to improve it. It can be set up to load functions only once. You can also put a number of containers behind a load balancer for better performance. One big flaw is that containers won’t be able to work together. If you have huge data and an algorithm that needs multiple machines to crunch it then H2O and MLlib are worth considering.

There will be other solutions implemented in other languages/frameworks too. There is no one single technology that solves all problems. Data manipulation, graphing, availability of algorithm implementation and performance are some of the factors behind choice of technology for the data scientist. Anyone who is serious about data analysis will need to be flexible about technologies. Remember The Law of Instrument :)

Current date and time in Ethiopia, UI, code, and API

I previously wrote about a page that shows the current date and time in Ethiopia. It’s good to see people using it. Someone was kind enough to comment recently that it was broken. Either I didn’t implement the algorithm correctly or maybe the algorithm itself is erroneous. Date calculations can get really complex. So it was easier to write it from scratch.

To see it working

To see current Ethiopian date go here: http://time.ertale.com

Code

PHP code: http://github.com/tilaye/ethiopiandate
Example use: http://time.ertale.com

API

Feel free to use my backend if you want to do conversions. You can pass any time on, or after January 1, 1970 and the year 2099. Here is an example:

Gregorian Date to convert in GMT: February 7, 2015 16:09:12
Corresponding Unix time: 1423325352
Conversion URL: http://time.ertale.com/time.php?t=1423325352
Result returned is: 2007-5-30-1-09-12-3-6

The result is in the format year-month-day-hour-minute-seconds-timeofday-weekofday where,

year is the Ethiopian year
month is the Ethiopian month, between 1 to 13
day is the Ethiopian day, between 1 and 30
hour  is the Ethiopian hour, the way Ethiopians count time. Here is what you will get,

  • Midnight – 6
  • 6 AM in the morning – 12
  • 7 AM in the morning – 1
  • Noon – 6
  • 6 PM in the evening – 12
  • 7 PM in the evening – 1

You can tell between Ethiopian day and night using the timeofday number (see below).

minute and second are the Ethiopian minute and second. No conversion is done there.
timeofday runs from 0 to 3 corresponding to Lelit ለሊት, Tewat ጠዋት, Keseat ከሰዓት and Misht ምሽት.

  • 0 – ለሊት 6:00 – 11:59
  • 1 – ጠዋት 12:00 – 5:59
  • 2 – ከሰዓት 6:00 – 11:59
  • 3 - ምሽት 12:00 – 5:59

weekofday runs between 1 and 7, where 1 stands for Monday

Hope that helps. Keep the feedback coming!

Mela Keyboard

There are thousands of English keyboard apps on Google Play and a few Ge’ez keyboards. I’m quite satisfied with my choice of English keyboard (I use “iPhone Keyboard for Android”), and I’m sure many Android users have found one they like. However I couldn’t find a good Ge’ez keyboard. I was looking for these features,

1. Must support Ge’ez and English so that I don’t have to switch between different keyboard apps
2. I should be able to switch between the two keyboards seamlessly
3. Must have English spelling suggestion
4. Must have Amharic suggestion
5. Typing Ge’ez letters should be easy

I tried every Ge’ez keyboard on Google Play. None of them had the features I was looking for. They all lacked at least one of the features I had in mind, specially points 4 and 5. Mela Keyboard has all the features that I feel a basic Ge’ez keyboard should have.

And that is why I have been passionately working on Mela Keyboard, an Android keyboard with Ge’ez and Latin letters.

Here is the Ge’ez keyboard with Amharic suggestion. The dictionary of Amharic words being used is so rich that I sometimes get surprised when a lengthy word I have in mind comes up right away. A few percentage of the suggested Amharic words are misspelled. I plan to get those gradually weeded out.

Image
To allow typing Ge’ez letters easily, you use what I call the “Handy Key”. It’s the one in the middle with a yellow border. Every time it is pressed, it switches the current character, eg. from ሁ to ሂ.

Here is the English keyboard with word suggestion.

Image
I used it for about two months while continuously fine tuning it. Now that I think it is a good keyboard, I’m ready to share it with everyone else. I released it this week. I hope fellow Android users enjoy it.

To install it, get Mela Keyboard on Google Play.

If you like it, like Mela Keyboard Facebook page to let others discover it.

If you don’t like it, the app makes it easy to send comments.

I look forward to hearing from users!

WorkSponsors

Five years ago I finished school and didn’t know how to find a job. I was jobless for a few unpleasant months. Among other things, my problem was lack of access to good information, partly because the UK was a new country to me back then.

International students still face a similar problem today. A big problem is not being able to find sponsoring organizations. What UKBA gives out is a list of 27 thousand odd organizations listed in alphabetical order. Imagine how difficult it is to go through that list one by one, hoping to find an organization which can be interested in your skills. Not only international students, but any person who wants to find a UK sponsor will face the same problem. That’s why a friend and myself spent a few weekends developing www.worksponsors.co.uk. I hope people find it useful.

Using Microsoft Kinect for mouse movement and more

Writing my experience in hacking Microsoft Kinect to control mouse movement and a few other actions.

SDK. The kinect SDK provides “Skeleton Tracking” by giving the location of 20 joints in the body. Some of these are left hand, right knee, and head position. Each joint can be considered as a 3D point, the position of which is updated several times per second.

Activating and deactivating gestures 1. I enable the mouse movement gesture if the user stretches their left arm enough (otherwise the mouse will be moving all the time).

Scaling values. To take hand positions and move the mouse I took a hacky approach, which is to scale the values from kinect to [0, 1] and scale them back again using a constant I found by experimentation. A neat approach would be to determine the scale automatically. Some people have a calibration step where the user makes special gestures to fix corners they can reach. I think it may even be possible to automatically work out a reasonable value based on the length of the hands.

Activating and deactivating gestures 2. Once gesture is activated, I keep it activated until the user makes a clear enough gesture to deactivate it. So I separated the activation and deactivation distances.

One slight issue is I’m not able to move the mouse to a specific location and leave it exactly there. Pulling the hand out while keeping it’s x-y position unchanged is challenging!

Smooth mouse movements. Without any smoothing the mouse would be over sensitive and jump here and there. After some experimentation I settled with averaging the past 30 points. This is around 1 second of data (kinect is 30 fps).

Other gestures. I also played with other gestures. Click – left hand pointing down, right click – same as left click but with right hand this time, drag – moving right hand, zoom – stretching both hands and moving hands closer together or far apart, panning – stretching both hands and moving hands together.

Code

Program moves between two states, gesture and no gesture.

.

Here is my code. It’s written in C#. You can reconfigure the gestures to do something else, eg. shift+click instead of just shift. You can also plug your own gestures by implementing a simple interface with methods bool CanHandleEvent(Joints) and bool HandleEvent(Joints).