On Structuring Python Projects

Types of Projects The term Python project can be somewhat misleading. While languages like Swift are designed for specific purposes such as generating macOS/iOS apps, components, and frameworks, Python is used in a much more versatile manner. A Python project might range from an analytical solution developed across multiple Jupyter notebooks to a standalone script querying a database API and extracting results to an application or package facilitating the deployment of models. Each of these projects has its own key usability requirements. For instance, if end-users will utilize our project through a command-line interface, we will focus on argument parsing and other elements facilitating user-friendly execution. ...

16 March 2022 · 4 min · Konrad Zdeb

Beauty of R and Big-O

Big-O The purpose of this is not to provide yet another primer on the Big-O/$\Omega$/$\Theta$ notation but to share my enduring appreciation for working with R. I will introduce Big-O only briefly to provide context but I would refer all of those who are interested to the linked materials. What is Big-sth notation When analysing functions, we may be interested in knowing how fast a function grows. For instance, for function \(T(n)=4n^2-2n+2\), after ignoring constants, we would say that \(T(n)\) grows at the order of \(n^2\). With respect to the Big-O notation we would write \(T(n)=O(n^2)\)^[MIT. (2021, December 9). Big O notation. Introduction to Computers and Programming. Retrieved December 26, 2021, from https://web.mit.edu/16.070/www/lecture/big_o.pdf]. Most commonly, in computer science, we would differentiate between Big O, Big Theta \((\Theta)\) and Big Omega \((\Omega)\). In a nutshell, the differences between those common notations can be summarised as follows: ...

9 December 2021 · 6 min · Konrad Zdeb

Why regex is not fuzzy matching

Recently, I cam across an interesting discussion on StackOverflow^[SO discussion on: Fuzzy Join with Partial String Match in R] pertaining to approach to fuzzy matching tables in R. Good answer contributed by one of the most resilient and excellent contributors to whom I owe a lot of thanks for help suggested relying on regular expression, combining this with basic string removal and transformations like toupper to deterministically match the tables. The solution solved the problem and was accepted. ...

29 June 2021 · 7 min · Konrad Zdeb

On Sorting Arrays...or why it's good to read the actual assignment

Problem Solving challenges on project Euler or HackerRank is a good past time. For folks working in the wider analaytical / data science field, places like project Euler provide an excellent opportunity to work with academic programming concepts that do not frequently appear in real-life. I was looking at common problem: You are given an unordered array consisting of consecutive integers [1, 2, 3, …, n] without any duplicates. You are allowed to swap any two elements. Find the minimum number of swaps required to sort the array in ascending order. Example Perform the following steps: ...

23 May 2021 · 4 min · Konrad Zdeb

Three-Way Operator in R

Is there a merit for a three-way operator in R? Background In C++20 revision added “spaceship operator”, which is defined as follows: 1 2 3 (a <=> b) < 0 # if lhs < rhs (a <=> b) > 0 # if lhs > rhs (a <=> b) == 0 # if lhs and rhs are equal/equivalent. R implementation The behaviour can be achieved in R in multiple ways. A one straightforward approach would involve making use of the ifelse statement ifelse implementation Basic approach would involve comparing the two figures and respectively returning -1 or 1 consistently with the definition above. ...

8 May 2020 · 6 min · Konrad

Amusing way to get user input windows in R

In an unlikely scenario that beautiful Shiny apps do not meet your analytical requirements and developing a full-blown user interface. in RGtk2 may seem to be a little too much, there is a third, often overlooked solution, - package svDialogs by Philippe Grosjean. The package in a convenient way enables user to create various interface gadgets. For example the code: 1 2 3 4 require(svDialogs) ## Let's keep some data in one place user_figure <- svDialogs::dlg_input() would result in the following window being presented to the user: ...

1 February 2012 · 1 min · Konrad