Getting Started with Streamlit for Data Science

Book description

Create, deploy, and test your Python applications, analyses, and models with ease using Streamlit

Key Features

  • Learn how to showcase machine learning models in a Streamlit application effectively and efficiently
  • Become an expert Streamlit creator by getting hands-on with complex application creation
  • Discover how Streamlit enables you to create and deploy apps effortlessly

Book Description

Streamlit shortens the development time for the creation of data-focused web applications, allowing data scientists to create web app prototypes using Python in hours instead of days. Getting Started with Streamlit for Data Science takes a hands-on approach to helping you learn the tips and tricks that will have you up and running with Streamlit in no time.

You'll start with the fundamentals of Streamlit by creating a basic app and gradually build on the foundation by producing high-quality graphics with data visualization and testing machine learning models. As you advance through the chapters, you’ll walk through practical examples of both personal data projects and work-related data-focused web applications, and get to grips with more challenging topics such as using Streamlit Components, beautifying your apps, and quick deployment of your new apps.

By the end of this book, you’ll be able to create dynamic web apps in Streamlit quickly and effortlessly using the power of Python.

What you will learn

  • Set up your first development environment and create a basic Streamlit app from scratch
  • Explore methods for uploading, downloading, and manipulating data in Streamlit apps
  • Create dynamic visualizations in Streamlit using built-in and imported Python libraries
  • Discover strategies for creating and deploying machine learning models in Streamlit
  • Use Streamlit sharing for one-click deployment
  • Beautify Streamlit apps using themes, Streamlit Components, and Streamlit sidebar
  • Implement best practices for prototyping your data science work with Streamlit

Who this book is for

This book is for data scientists and machine learning enthusiasts who want to create web apps using Streamlit. Whether you’re a junior data scientist looking to deploy your first machine learning project in Python to improve your resume or a senior data scientist who wants to use Streamlit to make convincing and dynamic data analyses, this book will help you get there! Prior knowledge of Python programming will assist with understanding the concepts covered.

Table of contents

  1. Getting Started with Streamlit for Data Science
  2. Contributors
  3. About the author
  4. About the reviewers
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
    4. Download the example code files
    5. Download the color images
    6. Conventions used
    7. Get in touch
    8. Share Your Thoughts
  6. Section 1: Creating Basic Streamlit Applications
  7. Chapter 1: An Introduction to Streamlit
    1. Technical requirements
    2. Why Streamlit?
    3. Installing Streamlit
    4. Organizing Streamlit apps
    5. Streamlit plotting demo
    6. Making an app from scratch
      1. Using user input in Streamlit apps
      2. Finishing touches – adding text to Streamlit
    7. Summary
  8. Chapter 2: Uploading, Downloading, and Manipulating Data
    1. Technical requirements
    2. The setup – Palmer's Penguins
      1. Exploring Palmer's Penguins
      2. Flow control in Streamlit
    3. Debugging Streamlit apps
      1. Developing in Streamlit
      2. Exploring in Jupyter and then copying to Streamlit
    4. Data manipulation in Streamlit
      1. An introduction to caching
    5. Summary
  9. Chapter 3: Data Visualization
    1. Technical requirements
    2. San Francisco Trees – A new dataset
    3. Streamlit visualization use cases
    4. Streamlit's built-in graphing functions
    5. Streamlit's built-in visualization options
      1. Plotly
      2. Matplotlib and Seaborn
      3. Bokeh
      4. Altair
      5. PyDeck
    6. Summary
  10. Chapter 4: Using Machine Learning with Streamlit
    1. The standard ML workflow
    2. Predicting penguin species
    3. Utilizing a pre-trained ML model in Streamlit
    4. Training models inside Streamlit apps
    5. Understanding ML results
    6. Summary
  11. Chapter 5: Deploying Streamlit with Streamlit Sharing
    1. Technical requirements
    2. Getting started with Streamlit Sharing
    3. A quick primer on GitHub
    4. Deploying with Streamlit Sharing
    5. Debugging Streamlit Sharing
      1. Streamlit Secrets
    6. Summary
  12. Section 2: Advanced Streamlit Applications
  13. Chapter 6: Beautifying Streamlit Apps
    1. Technical requirements
    2. Setting up the SF Trees dataset
    3. Working with columns in Streamlit
    4. Exploring page configuration
    5. Using the Streamlit sidebar
    6. Picking colors with Color Picker
    7. Utilizing Streamlit themes
    8. Summary
  14. Chapter 7: Exploring Streamlit Components
    1. Technical requirements
    2. Using Streamlit Components – streamlit-embedcode
    3. Using Streamlit Components – streamlit-lottie
    4. Using Streamlit Components – streamlit-pandas-profiling
    5. Finding more components
    6. Summary 
  15. Chapter 8: Deploying Streamlit Apps with Heroku and AWS
    1. Technical requirements
    2. Choosing between AWS, Streamlit Sharing, and Heroku
    3. Deploying Streamlit with Heroku
      1. Setting up and logging in to Heroku
      2. Cloning and configuring our local repository
      3. Deploying to Heroku
    4. Deploying Streamlit with AWS
      1. Selecting and launching a virtual machine
      2. Installing the necessary software 
      3. Cloning and running your app
      4. Long-term AWS deployment
  16. Section 3: Streamlit Use Cases
  17. Chapter 9: Improving Job Applications with Streamlit
    1. Technical requirements
    2. Using Streamlit for proof of skill data projects
      1. Machine learning – the Penguins app
      2. Visualization – the Pretty Trees app
    3. Improving job applications in Streamlit
      1. Questions
      2. Answering Question 1
      3. Answering Question 2
    4. Summary
  18. Chapter 10: The Data Project – Prototyping Projects in Streamlit
    1. Technical requirements
    2. Data science ideation
    3. Collecting and cleaning data
    4. Making an MVP
      1. How many books do I read each year?
      2. How long does it take for me to finish a book that I have started?
      3. How long are the books that I have read?
      4. How old are the books that I have read? 
      5. How do I rate books compared to other Goodreads users?
    5. Iterative improvement
      1. Beautification via animation
      2. Organization using columns and width
      3. Narrative building through text and additional statistics
    6. Hosting and promotion
    7. Summary
  19. Chapter 11: Using Streamlit for Teams
    1. Analyzing hypothetical survey costs using Streamlit for Teams
      1. Setting up a new Streamlit app folder
      2. Illustrating the representativeness of the sample
      3. Calculating the cost of the sample
      4. Using interaction to show trade-offs 
    2. Creating and deploying apps from private repositories
    3. User authentication with Streamlit
    4. Summary
  20. Chapter 12: Streamlit Power Users
    1. Interview #1 – Fanilo Andrianasolo
    2. Interview #2 – Johannes Rieke
    3. Interview #3 – Adrien Treuille
    4. Interview #4 – Charly Wargnier
    5. Summary
    6. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Getting Started with Streamlit for Data Science
  • Author(s): Tyler Richards
  • Release date: August 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781800565500