The vast majority of hands-on artificial intelligence work is currently done using the Python programming language. As such, some understanding of Python, in particular, and computer programming, in general, is needed to be successful in applying AI. That said, it is truly astounding how much complex AI research can be accomplished with a few lines of code!
The content in this workshop is aimed at beginning coders who may have never programmed before. As with the rest of the Practicum AI workshops, we use Jupyter Notebooks for the learning experience. Jupyter Notebooks are an easy to use, yet powerful tool that allow interactive coding as well as nicely formatted explanatory text. Much of exploratory AI research is conducted in Jupyter Notebooks, and it is easy to transfer code from Notebooks to scripts when it is time to scale up analyses.
Learning a new programming language can be a challenge. That's why it's important to start off on the right foot. In this pre-module, we introduce you to some strategies you can use to accelerate the learning process. We present some basic ideas to ensure that the code you write performs well in a high-performance computing (HPC) environment.
Topics: The following topics are covered in this module:
- How to Learn a Programming Language
- Code Performance in HPC Environments
- About Practicum AI, our courses and badges
- Meet your instructors
- Introduction to Python and How to Learn a Programming Language
- Slides:
Introduction to Python
- Slides:
- A quick introduction to Canvas
- Getting help on the discussion board
- Providing feedback via Issues
- Python Pre-Workshop (QuickQuiz)
The art of Python programming begins with a basic understanding of how the language works, the JupyterLab notebook environment, and the importance of developing a consistent coding style supported by clear documentation. These topics are covered in this first module as well as an initial look at the versatile Python string variable.
Topics: The following topics are covered in this module:
- Variables and Memory
- Coding Style, Naming Conventions, and Documentation
- String Variables and printing strings
By the end of this module, students will be able to:
- Define what a variable is and how the basic Python operators work.
- Recognize the importance of a consistent coding style and clear documentation.
- Use basic string methods (indexing, slicing, etc.) when writing Python code.
- Analyze Python error messages and identify corrective action to fix them.
- Variables and Memory
- Slides:
Variables
- Slides:
- 01.1_getting_started Notebook
- Variables and Memory (QuickQuiz)
- Coding Style (QuickQuiz)
- String Variable (QuickQuiz)
For those with no programming experience, the Python for Everybody website, where you can also download the free textbook by Charles Severance, is a wonderful resource. If, on the other hand, you have prior programming experience, Brian Overland's Python without Fear is a great introduction to the language and includes advanced chapters on object-oriented programming.
In Python, every variable is of a specific type. A variable's datatype, in turn, determines the kinds of operations that can be performed on it. For that reason, a clear understanding of this concept, including typecasting, is of utmost importance. Also, by including, or import
ing Python libraries, you can extend functionality and do more in less time by leveraging the work of other developers. You will learn about these two key concepts (datatypes and reusability) in this module.
Topics: The following topics are covered in this module:
- Printing Strings
- DataTypes
- Importing Libraries
By the end of this module, students will be able to:
- Use string format methods to create and display custom text when writing Python code.
- Access a variable's methods using the dir() function and JupyterLab tab completion.
- Describe the various Python datatypes and be able to typecast a variable.
- Discuss the importance of reusability and how libraries implement this concept.
- Use import statements to access library functions.
- 02.0_getting_started Notebook
- 02.1_libraries Notebook
- Printing Strings (QuickQuiz)
- DataTypes (QuickQuiz)
- Importing Libraries (QuickQuiz)
This module introduces additional programming foundations. These include loops, conditionals, and writing functions. By snapping these together like Lego blocks, a software developer can create a wide variety of sophisticated applications. This module introduces these building blocks and how to develop a personal coding style which reflects coding best practices.
Topics: The following topics are covered in this module:
- For & While Loops
- Conditionals
- Functions
By the end of this module, students will be able to:
- Implement for and while loops in Python code and understand how the two differ.
- Use if, elif, else, and Boolean opera
- Write clearly documented single-purpose functions.
- Correctly nest calls to Python built-in functions.
- Develop a personal coding style which reflects coding best practices.
- Loops
- Conditionals
- Functions
- 03.1_loops Notebook
- 03.2_conditionals Notebook
- 03.3_functions Notebook
- For & While Loops (QuickQuiz)
- Conditionals (QuickQuiz)
- Functions (QuickQuiz)
Because most AI projects devote about 80% of their time to data wrangling, it is only fitting that our Python series end on this note. Pandas is the go-to library for all things data. Thus, the topics presented in this module include Pandas dataframes, loading data into dataframes from csv files, slicing and dicing data, using statistics to summarize a dataset, and visualizing data with matplotlib
.
Topics: The following topics are covered in this module:
- Anatomy of a Dataframe
- Slicing & Dicing Data
- Dataframe Basic Statistics
- Data Visualization with Matplotlib
By the end of this module, students will be able to:
- Explain the various components of a Pandas dataframe and be able to construct one.
- Use
read_csv()
and related variants to create and populate a dataframe from a file. - Slice and dice data with Pandas index and dataframe management functions.
- Illustrate the appropriate use of basic statistical functions to summarize a dataset.
- Use
matplotlib
functions to generate clear graphs and plots.
- Data Wrangling
- 04.1_data_wrangling Notebook
- 04.2_data_wrangling Notebook
- Anatomy of a Dataframe (QuickQuiz)
- Slicing & Dicing Data (QuickQuiz)
- Dataframe Statistics (QuickQuiz)
- Data Visualization (QuickQuiz)