PythonPro #36: igraph Network Visualization, ControlFlow AI Workflow, and Python Polars 1.0.0-rc.1 Release
Bite-sized actionable content, practical tutorials, and resources for Python programmers and data scientists
Welcome to a brand new issue of PythonPro!
In today’s Expert Insight we bring you an excerpt from the recently published book,
Modern Graph Theory Algorithms with Python, which discusses the creation and visualization of networks in Python using the igraph library.
News Highlights: ControlFlow, a new open-source Python framework by Prefect 3.0, streamlines AI workflow management; RStudio's maker introduces a new R and Python IDE with simplified setup and OpenVSX compatibility; and Python Polars 1.0.0-rc.1 is released, boosting data manipulation.
Here are my top 5 picks from our learning resources today:
In today’s Featured Study, we are covering a newly introduced framework that simplifies the creation of Case-Based Reasoning (CBR) applications for Python users.
Stay awesome!
Divya Anne Selvaraj
Editor-in-Chief
P.S.: This month’s survey opens today. Do take the opportunity to tell us what you think of PythonPro, request learning resources, and earn your one Packt Credit for this month.
🐍 Python in the Tech 💻 Jungle 🌳
🗞️News
Introducing ControlFlow - A framework for building agentic workflows, powered by Prefect 3.0: ControlFlow is a new open-source Python framework designed to simplify and enhance AI workflow management. Read to learn how it works.
Maker of RStudio launches new R and Python IDE: This simplifies setup for both languages. Read to learn about features such as built-in functionality, a data explorer, and compatibility with OpenVSX extensions.
Python Polars 1.0.0-rc.1 released: Polars supports efficient data manipulation for Python, R, and NodeJS. Read to learn about breaking changes and more.
💼Case Studies and Experiments🔬
Pricing VIX options using the Heston model: Leverages stochastic volatility to capture market phenomena like volatility smile. Read to discover tools for more accurate financial modeling and options pricing strategies.
Improving Customer Service Efficiency Using Demand Forecasting with Leagile and Lean Six Sigma Concepts - A Case Study: Explores how to boost efficiency in small coffee shops. Read to learn how to utilize Python and the Autoregressive Integrated Moving Average (ARIMA) model for accurate demand forecasting in business applications.
📊Analysis
All Set! Looking Under the Hood of Python's Set Data Structure: Dives deep into the use of hash tables for efficient data handling. Read to learn about the inner workings of Python's set data structure.
Did Google Just Kill Streamlit?: Explores Google's new Python framework, Mesop, positioned as a potential alternative to Streamlit for internal tooling and rapid prototyping. Read to gain insight into getting started with Mesop for building UIs.
🎓 Tutorials and Guides 🤓
Understanding the Python Mock Object Library: Explains how Python’s unittest.mock library works to improve test reliability and efficiency. Read to learn how to create and manage mock objects, configure their behavior, and write robust, reliable tests.
Creating Great README Files for Your Python Projects: Explains the purpose and structure of a README. Read to learn about recommended document formats, preparing for PyPI and GitHub, and tools for automating README creation.
Website Scraping with Python Using BeautifulSoup and Scrapy: Emphasizes the use of proxies, particularly mobile proxies, to avoid IP bans and rate limits. Read to learn best practices to avoid detection and improve data gathering.
📖Open Access Book | Minimalist Data Wrangling with Python: Introduces you to data science, emphasizing data cleaning, transformation, exploratory analysis, and reporting, using diverse data sources. Read to gain skills applicable in real-world data science contexts.
Secure Environment Variables using dotenvx – Node.js, Python & Java: Details the installation, configuration, and usage of dotenvx in Python. Read to learn how to encrypt .env files and securely handle environment variables using public and private keys.
Building Auto-Analyst — A data analytics AI agentic system: The system consists of a planner agent, several analysis agents, a code combiner agent, and additional support agents. Read to learn how to design, implement, and evaluate an AI-driven data analytics system.
How to run Ollama locally on GPU with Docker: Details the setup of Ollama on a laptop using Docker without external costs. Read to learn how to deploy and utilize Ollama for generating AI models on personal hardware.
🔑Best Practices, Advice, and Code Optimization🔏
How to install Python the smart way: Guides readers on installing Python efficiently on Windows, macOS, and Linux. Read to learn how to install Python correctly, manage multiple versions, and maintain clean project environments.
4 keys to writing modern Python: Discusses type hinting, virtual environments, new syntax features, and testing. Read to learn how to leverage the latest Python features and tools to write more efficient, maintainable, and robust code.
Modern Good Practices for Python Development: Discusses using tools that support multiple Python versions. Read to discover best practices for code formatting, testing with pytest, type hinting, f-strings, and more.
Designing Pythonic library APIs: Outlines principles for creating effective Python library APIs, including structure, naming, error handling, type annotations, and more. Read to learn best practices for designing user-friendly Python library APIs.
3 Essential Questions to Address When Building an API-Involved Incremental Data Loading Script: Outlines how to incrementally sync data from API endpoints to a database using Python's dlt library. Read to learn practical approaches to incremental data loading.
🔍Featured Study: CBRkit trumps ProCAKE for Python-Based AI Development💥
In their paper, “CBRkit: An Intuitive Case-Based Reasoning Toolkit for Python,” researchers from Trier University and German Research Center for Artificial Intelligence introduce CBRkit. This Python framework simplifies Case-Based Reasoning (CBR) application development and integrates machine learning, tackling the complexity of existing CBR frameworks.
Context
CBR is a problem-solving method in AI that uses past cases and experiences to understand and solve new complex problems. Examples of CBR applications include IBM Watson providing customer support solutions by accessing a repository of past inquiries, and Isabel Healthcare aiding in medical diagnosis by comparing patient symptoms against a database of clinical cases. Existing Python-based CBR frameworks such as Clood CBR, pycbr, and cbrlib, are complex and lack usability, which CBRkit aims to address.
Key Features
CBRkit is designed to simplify the development of CBR applications through the following:
Generic Functions: Provides generic and easily extensible functions for building CBR applications.
ML Integration: Facilitates the integration of machine learning techniques, enhancing the functionality of CBR systems.
User Accessibility: Demonstrated through a user study to be more accessible and effective than the traditional Java-based ProCAKE framework.
Open Source: Available under the permissive MIT license, encouraging community use and contribution.
Documentation and Support: Well-documented and supported, ensuring ease of use and community engagement.
What This Means
For Python programmers and ML practitioners, CBRkit offers a straightforward approach to developing powerful CBR systems without deep expertise in the domain. It allows for easy installation and use alongside popular Python libraries, enhancing productivity in developing AI solutions.
Examining the Details
CBRkit is developed using modern software engineering practices suitable for Python, focusing on strong type safety. It works seamlessly with well-known Python libraries like pandas and spaCy and supports sophisticated machine learning methods, including the use of embeddings and tailored classifiers. Designed for ease of use, its structure allows developers to easily create and modify similarity measures, facilitating the development of flexible and powerful CBR applications.
You can learn more by reading the entire paper and access the framework here.
Take the Survey, Get a Packt Credit!
🧠 Expert insight 📚
Here’s an excerpt from “Chapter 1: What is a Network?” in the book, Modern Graph Theory Algorithms with Python by Colleen M. Farrelly and Franck Kalala Mutombo, published in May 2024.
Creating networks in Python
…let’s explore how (networks) are created with… igraph….
igraph is a network science software available in C, R, and Python. igraph
provides many network science tools, including network creation options, many network analytics algorithms, and network visualization plots. Let’s explore igraph network creation and visualization using our hackathon network (example).
First, let’s install igraph:
#install igraph and pycairo
!pip install igraph
!pip install pycairo
We’ll then import igraph and its Graph module:
#import igraph
import igraph as ig
from igraph import Graph
Next, we’ll use the Graph module to create a graph with three vertices with undirected edges connecting each vertex with the remaining vertices:
#create hackathon network
g_colleagues=ig.Graph(
edges=[(0,1),(0,2),(1,2)],n=3,directed=False)
Now, we can use the plot function to visualize our hackathon network. igraph offers many customization options, including vertex color, vertex size, edge color, edge size, labeling of vertices, and the size of the plot (among others). For this plot, we’ll bound the size of the image and create vertices large enough to label with the first initials of our hackathon network members:
#plot the hackathon network
ig.plot(g_colleagues,bbox= (200,200), vertex_size=40,
vertex_label=["M","A","G"])
This should give you a plot that looks like Figure 1.6, showing … (three members’) hackathon network:
Figure 1.6 – A plot of the hackathon network in igraph
Packt library subscribers can continue reading the entire book for free. You can buy Modern Graph Theory Algorithms with Python by Colleen M. Farrelly and Franck Kalala Mutombo, here.
On a scale of 1-10, how would you rate today’s issue of PythonPro in terms of being informative, engaging, and useful?
lowest 1 2 3 4 5 6 7 8 9 10 highest
And that’s a wrap.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most useful here. The complete PythonPro archives can be found here.
If you have any suggestions or feedback, or would like us to find you a Python learning resource on a particular subject, take the survey or leave a comment below!