ProgrammingPro #8: Top Python GUI Libraries, Scikit-LLM, ChainForge LLM, and Selection Algorithms
Hi,
Hello and welcome to today’s issue of the ProgrammingPro! In this special edition, we
deep dive into top 5 Python GUI Libraries in 2023. We also explore ChatGPT - Your Personal Python Coding Mentor, How to Start a Go Project in 2023 and take a look at trending AI tools and LLMs such as ChainForge, LoopGPT, and Scikit-LLM.
In addition, we also have tutorial on Selection Algorithms, and an assortment of the most relevant industry insights and useful tools and resources for developers and software engineers.
In today’s issue:
Secret Knowledge: Learning Resources
TechWave: News and Analysis
Top 5 Python GUI Libraries in 2023
HackerHub: Trending AI/LLM Tools
Tutorial: Selection Algorithms
My promise with this newsletter is to act as your personal assistant and help you navigate and keep up-to-date with what's happening in the world of software development. What did you think of today's newsletter? Please consider taking the short survey below to share your thoughts and you will get a free PDF of the “The Cybersecurity Beginner’s Guide” eBook upon completion.
Thanks for reading.
Until next time!
Kartikey Pandey, Kirolos Adeib
Editor-in-Chief
Complete the Survey. Get a Packt eBook for Free!
⚡ Secret Knowledge: Learning Resources
ChatGPT - Your Personal Python Coding Mentor: Large language models have gained popularity since OpenAI released ChatGPT. In this tutorial, you’ll learn how to use ChatGPT as your Python coding mentor. You’ll study a variety of use cases, learn how to interpret results, and learn to beware of incorrect and irrelevant responses.
Comprehensive Rust: Comprehensive Rust is a three-day course used internally at Google to teach Rust to experienced software engineers. Created by the Android team, it covers the full spectrum of Rust, from basic syntax to advanced topics like generics and error handling. It also includes Android-specific content on the last day. The course assumes no prior Rust knowledge.
How to Start a Go Project in 2023: This comprehensive guide goes over how to get started with Go in 2023. It covers all the topics needed to be set up with Go in a productive manner, such as unit testing, profiling, OS specific code, and useful tools.
SOLID Principles: Improve Object-Oriented Design in Python: In this tutorial, you’ll learn about the SOLID principles, which are five well-established standards for improving your object-oriented design in Python. By applying these principles, you can create object-oriented code that is more maintainable, extensible, scalable, and testable.
Pandas vs Julia: Cheat Sheet and Comparison: This is a Python/Pandas vs Julia cheatsheet and comparison. You can find what is the equivalent of Pandas in Julia or vice versa.
go-datastructures 1.1 - Numerous Threadsafe Data Structures: There’s a lot packed in here: queues, heaps, trees, sets, tries, skiplists, graphs, and often multiple types of each.
TechWave: News and Analysis
New Library Updates in PyTorch 2.0: Learn what’s changed in the newly released PyTorch 2.0 library. Includes new data collectors, augmentation operators, vision features, and loads more.
Meta Releases Megabyte: Meta AI has proposed a new AI model architecture called Megabyte which can generate more than 1 million tokens across multiple formats. Megabyte addresses scalability issues in current models and performs calculations in parallel, boosting efficiency and outperforming Transformers.
Built-in ChatGPT-driven Copilot Will be Added to Windows 11: Microsoft is adding a new ChatGPT-driven Copilot feature in Windows 11 that can be used alongside other Windows apps. It will be available to Windows Insiders in June. It can change Windows settings, rearrange windows with Snap Layouts, summarize and rewrite documents, open apps, and more. There will also be a dedicated button for Windows Copilot on the taskbar.
Top 5 Python GUI Libraries in 2023
In this module, we’ll take a look at the top 5 Python GUI libraries alongside supplementary resources on how to learn them.
Tkinter: Tkinter is the standard python GUI library. It is pre-installed in python. Although it isn’t the preferred solution to handle large-scale projects, it remains the best choice for simple tool GUIs and smart portable applications.
The visual elements are called widgets and each widget comes with a different level of customizability. It is cross-platform but the widgets can look outdated, particularly on windows platforms. You can start learning Tkinter by checking this article Python GUI Programming With Tkinter – Real Python and explore the course titled Tkinter Course - Create Graphic User Interfaces in Python Tutorial - YouTube .
PyQt: PyQt is one of the most popular Python frameworks for GUI development. The latest version can be obtained by downloading it from their official website or by directly installing it in Python using the “pip” command.The framework is built around the Qt framework, which is a group of C++ libraries and tools providing platform-independent abstractions for GUIs. PyQt enables the developers to create applications of various scales, ranging from small-scale to large-scale projects.
It is a cross platform that allows you to create modern interfaces on any platform, including Windows, macOS, Linux and Android. Qt allows large applications to be built from reusable and isolated components. This comes at the expense of a steeper learning curve. However, for smaller projects Qt is similar to other libraries.
There are two approaches to creating visual elements in PyQt: by writing code directly or by utilizing the QtGUI & QtDesigner modules, which provide visual elements through drag-and-drop interface. A Valuable resource is PyQt5 Tutorial (tutorialspoint.com)
WxPython: WxPython is a wrapper for the popular, cross-platform GUI toolkit called WxWidgets.You can install WxPython using the pip command. It is implemented as a set of Python extension modules that wrap the GUI components of the popular wxWidgets cross platform library, which is written in C++. It is best suitable for small portable desktop applications.
It is important to note that WxPython may have certain platform-specific quirks that can impact the ease of maintaining cross-platform compatibility for your application. WxPython has a large library of widgets that allows programmers to create highly functional GUIs. The framework is currently under active development and is also being reimplemented from scratch under the name ‘WxPython Phoenix’. To start your journey in WxPython, you can start by exploring WxGladeFirstSteps - wxPyWiki (wxpython.org)
PySimpleGUI: PySimple GUI stands out as the most beginner-friendly framework for developing complex GUI. It provides a wrapper around four existing frameworks :Tkinter, Qt, wxPython and Remi. By incorporating the majority of their code, no prior knowledge of the built-on frameworks is needed. Additionally , it allows effortless migration from one GUI framework to another by only modifying the import statement. PySimpleGUI is ideally suited for building user interfaces for simple tools and offers a high level of portability. To guide you through the installation and execution of the package, you can refer to the : PySimpleGUI: An easy way to create GUIs in Python - AskPython . The developer of the library offers a udemy course titled Python GUIs - "The Official PySimpleGUI Course" | Udemy that can be a good point to start from.
Kivy: Kivy is the only framework primarily written in pure python without any dependencies on toolkits written in other programming languages. The framework supports both GUI and NUI programming, making it well suited for touchscreen-oriented interfaces and mobile interfaces like Android and iOS. Moreover, The framework enables modern graphics capabilities and advanced techniques. The developers of Kivy released several separate libraries that can offer access to certain platform-specific features. To access one of the top viewed Kivy course videos, you can check : Kivy Course - Create Python Games and Mobile Apps - YouTube.
HackerHub: Trending AI/LLM Tools
ChainForge: ChainForge is an open source visual programming environment for battle-testing prompts to LLMs. ChainForge is a data flow prompt engineering environment for analyzing and evaluating LLM responses. It is geared towards early-stage, quick-and-dirty exploration of prompts and response quality that goes beyond ad-hoc chatting with individual LLMs.
LoopGPT: LoopGPT is a modular Auto-GPT Framework as a proper python package, written with modularity and extensibility in mind.
Scikit-LLM: Scikit-LLM allows developers to seamlessly integrate language models into scikit-learn for enhanced text analysis tasks. Scikit-LLM is still under development and it plans to add support for more models and fine-tuning. It features zero-shot text classification, multi-label zero-shot text classification, and text vectorization. GitHub repo here.
StanGirard/Quivr: Quivr calls itself “your second brain in the cloud”. It’s very convenient to dump all your files and thoughts and retrieve unstructured information, powered by generative AI.
FlowiseAI/Flowise: Drag & drop UI to build your customized LLM flow using LangchainJS.
Ricklamers/gpt-code-ui: An open-source implementation of OpenAI's ChatGPT Code interpreter.
VideoLLM: VideoLLM is a tool for video analysis using LLMs. By successfully testing on multiple datasets, VideoLLM proves that it can handle various tasks, suggesting that language model's reasoning abilities can be effectively used for understanding and analyzing video content.
Tutorial: Selection Algorithms
One interesting set of algorithms related to finding elements in an unordered list of items is selection algorithms. Given a list of elements, selection algorithms are used to find the kth smallest or largest element from the list. So given a list of data elements and a number (k), the aim is to find the kth smallest or largest element. The simplest case of selection algorithms is to find the minimum or maximum data element from the list. However, sometimes, we may need to find the kth smallest or largest element in the list. The simplest way is to first sort the list using any sorting algorithm, and then we can easily obtain the kth smallest (or largest) element. However, when the list is very large, then it is not efficient to sort the list to get the kth smallest or largest element. In that case, we can use different selection algorithms that can efficiently produce the kth smallest or largest element.
In this module, we will cover the following topics:
Selection by sorting
Randomized selection
Deterministic selection
Selection by Sorting
Items in a list may undergo statistical inquiries such as finding the mean, median, and mode values. Finding the mean and mode values does not require the list to be ordered. However, to find the median in a list of numbers, the list must first be ordered. Finding the median requires you to find the element in the middle position of the ordered list. In addition, this can be used when we want to find the kth smallest item in the list. To find the kth smallest number in an unordered list of items, an obvious method is to first sort the list, and after sorting, you can rest assured that the element at index 0 will hold the smallest element in the list. Likewise, the last element in the list will hold the largest element in the list.
For more information on how to order data items within a list, see Chapter 11, Sorting. However, in order to obtain a kth smallest element from the list, it is not a good solution to apply a sorting algorithm to a long list of elements to obtain the minimum or maximum or kth smallest or largest value from the list since sorting is quite an expensive operation. Thus, if we need to find out the kth smallest or largest element from a given list, there is no need to sort the complete list as we have other methods that we can use for this purpose. Let’s discuss better techniques to find the kth smallest element without having to sort the list in the first place, starting with randomized selection.
Randomized Selection
The randomized selection algorithm is used to obtain the kth smallest number that is based on the quicksort algorithm; the randomized selection algorithm is also known as quickselect. The quicksort algorithm is an efficient algorithm to sort an unordered list of items. To summarize, the quicksort algorithm works as follows:
It selects a pivot.
It partitions the unsorted list around the pivot.
It recursively sorts the two halves of the partitioned list using steps 1 and 2.
One important fact about quicksort is that after every partitioning step, the index of the pivot does not change, even after the list becomes sorted. This means that after each iteration, the selected pivot value will be placed in its correct position in the list. This property of quicksort enables us to obtain the kth smallest number without sorting the complete list. Let’s discuss the randomized selection method, which is also known as the quickselect algorithm, to obtain the kth smallest element from a list of n data items.
Quickselect
The quickselect algorithm is used to obtain the kth smallest element in an unordered list of items. It is based on the quicksort algorithm, in which we recursively sort the elements of both the sublists from the pivot point. In each iteration, the pivot value reaches the correct position in the list, which divides the list into two unordered sublists (left and right sublists), where the left sublist has smaller values as compared to the pivot value, and the right sublist has greater values compared to the pivot value. Now, in the case of the quickselect algorithm, we recursively call the function only for the sublist that has the kth smallest element.
In the quickselect algorithm, we compare the index of the pivot point with the k value to obtain the kth smallest element from the given unordered list. There will be three cases in the quickselect algorithm, as follows:
If the index of the pivot point is smaller than k, then we are sure that the kth smallest value will be present on the right-hand sublist of the pivot point. So we only recursively call the quickselect function for the right sublist.
If the index of the pivot point is greater than k, then it is obvious that the kth smallest element will be present on the left-hand side of the pivot point. So we only recursively look for the ith element in the left sublist.
If the index of the pivot point is equal to k, then it means that we have found out the kth smallest value, and we return it.
Let’s understand the working of the quickselect algorithm with an example. Consider a list of elements, {45, 23, 87, 12, 72, 4, 54, 32, 52}. We can use the quickselect algorithm to find the third smallest element in this list.
We start the algorithm by selecting a pivot value, that is, 45. Here we are choosing the first element as the pivot element for simplicity; however, any other element can be chosen as a pivot element. After the first iteration of the algorithm, the pivot value moves to its correct position in the list, which in this example is at index 4 (the index is starting from 0). Next, we check the condition k<pivot point (that is, 2<4). Case- 2 is applicable, so we only consider the left sublist, and recursively call the function. Here, we compare the index of the pivot value (that is, 4) with the value of k (that is, the 3rd position or at index 2).
Next, we take the left sublist and select the pivot point (that is, 4). After the run, the 4 is placed in its correct position (that is, the 0th index). As the index of the pivot is less than the value of k, we consider the right sublist.
Similarly, we take 23 as the pivot point, which is also placed in its correct position.
Now, when we compare the index of the pivot point and the value of k, they are equal, which means we have found the 3rd smallest element, and it will be returned. The complete step-by-step process to find the 3rd smallest element is shown in the figure below.
This tutorial is a content extract from the book Hands-On Data Structures and Algorithms with Python, Third Edition written by Dr Basant Agarwal and published by Packt Publishing.