I'm going to repeat something I've said in many answers. Hiring is a sales process. You, as an applicant, have something you're trying to sell (yourself: or at least, your ability to perform a job).
The way you accomplish this is by using sales tools: a resume, a job application, a cover letter, references, and (maybe) a portfolio of work - ie a github account. When evaluating how you use these tools, you must focus on the fact that they're tools to facilitate a sales process.
To get to your specific question:
Is it still worth to put examples of my work on github, even if they are not "perfect"?
Practically, in order to make decisions about your github account as a sales tool, we first must ask: what is an employer looking for when they hire a developer? Then, we must ask: Does my github portfolio help show off those qualities? If the answer is yes, include it. If the answer is no, either don't include it, or modify it to better fit that perspective.
I think you gave some hints as to the answers when you said,
I usually do not take a great deal commenting this code and writing unit tests, if I just want to implement a cool algorithm and play around with its variables. Also I am sure there is the occasional dirty hack where a deadline was tight or I just wanted to get the program running asap.
Your github portfolio is showing off quick and dirty problem solving and fluency in certain languages. While those are both positive things to show off, there's a potential gap: as a hiring manager responsible for software development, more importantly than those characteristics, I look for people who write sustainable code. Developers who think about the long term and understand why things like unit tests are a good idea - not just people who do unit tests because they've been told to, or people who don't do them at all. In other words, I'm as interested in the process and approach (ie you did unit tests and commenting appropriately) as I am the end result (you got the right answer for the quick hackathon challenge). Clearly, there are other hiring managers out there in different types of organizations who may have a slightly different perspective on this. It's not clear from your question exactly what type of job you're going after. If you're looking for a more data science focused position, or a position where the software is secondary to the end result, your ability to write code that solves problems may prove more important than your ability to follow rigorous software development processes.
So - back to the sales process - your github portfolio definitely has value, but it may or may not be the most appropriate value for the exact position you're going after. If you have a resume/cover letter/other portfolio that shows how well rounded you are and fills in any gaps in your github, then the github work can safely remain as-is. However, if you don't have a way to show the specific well-rounded picture you need in order to sell yourself, then you're probably going to come off as lopsided (for example: too much focus on rushing to a result versus understanding the value of good process and approach) and you should consider modifying your code examples, or adding new ones (which are clearly emphasized when someone looks at your github account) that show off your ability to write "production level" code.
In Summary:
- Use your sales tools (resume, portfolio, etc) to specifically address what a hiring manager is looking for
- In software development, process is as important as end results. For a more formal, software development-focused position, ONLY showing that you can solve quick and dirty problems may make you appear risky, compared to candidates that can show off a well-rounded understanding of development processes. For a more data science-oriented position, where the development/maintenance of code may be slightly less important than literally getting an answer, this may not apply.
- Think about the specific type of position you're applying for, and what you want to show off about yourself, and then if there are gaps, you need to solve the gaps - regardless of whether or not you include your github account on your application.