Location>code7788 >text

What is Streamlit

Popularity:163 ℃/2024-10-11 11:42:43

Recently, I've been experimenting with some of my data analysis tasks with the long-knownStreamlitAnd once again, I feelPythonThe powerful thing about it.

So, get ready to write an introduction based on your mastery ofStreamlitThe Series.

This article is the first to introduce theStreamlitWhat it is, and what it has to do withJupytercap (a poem)Traditional Web ApplicationsThe difference.

1. What it is

Streamlitis a Python library for rapidly building data science and machine learning applications.

utilizationStreamlitWe can use a simplePythonCode to create interactive and visual applications without having to have an in-depth knowledge of front-end technologies or writing large amounts of underlying code.

StreamlitThe history of the development of theOctober 2019at that timeStreamlitis released as an application development framework specifically for machine learning and data science.

The initial design goal was to replaceFlaskplace in machine learning projects and help machine learning engineers rapidly develop user interaction tools.

StreamlitThe core idea is "Scriptability", i.e., users can build a complete application by writing simple Python scripts.

So.StreamlitIt encapsulates a large number of interactive components and supports rendering of objects such as tables, charts, datasheets, etc., and has rasterized responsive layout capabilities.

Subsequently.Streamlitevolved and received a lot of attention from the data science community.

Its open-source nature and clean and efficient design philosophy are favored by a growing number of data scientists and developers who use theStreamlitCreate and share a variety of beautiful, interactive web applications.

StreamlitIt is also starting to support a growing number of data visualization libraries such asMatplotlibPlotlycap (a poem)Altairetc., making it very easy to integrate rich charts and visualization elements in your application.

It is worth noting thatStreamlitIn the course of its development it has also experienced beingSnowflakeimportant event of the acquisition.

This acquisition further boosts theStreamlitApplications and developments in data science and machine learning.

For me, usingStreamlitThe great thing is that anyone who knows Python can build a nice interactive application that

No need to get stuck in the pain of writing a front-end and tossing around half a dozen times to adjust a style.

2. Where it is used

In my own experience of usingStreamlitIt is used in two main places.

One is in data analytics and machine learningEarly days of the projectUseStreamlitQuickly build an app to explore the possibilities in your project.

It can also be used for prototyping projects, which is much better than making static prototypes, on the one hand, you can easily implement a variety of interactions that

On the other hand, one of the charting components can show the results dynamically, better demonstrating to the client the possible effects of the project.

Another place where it can be used isTeaching DemonstrationFor example, when you want to do an online course, it allows the instructor to easily convert complex data into visual charts and images, helping the participants to better understand the data and the knowledge behind it.

Meanwhile.StreamlitThe interactive nature of the interface allows learners to manipulate and explore the interface in real time, which greatly enhances the engagement and interactivity of learning.

In addition.StreamlitIt also supports the integration of multiple data science libraries and tools, enabling instructors to freely select and combine different tools according to their teaching needs, further enriching the content and form of teaching.

For applications with a certain scale of users, such as those requiring authentication, permissions, and other business functions, thenot recommendedutilizationStreamlit

After all, the traditional front-end and back-end development methods are still easier to cope with frequent changes in the business, and also conducive to collaborative development.

3. Comparison with Jupyter

utilizationStreamlitPreviously, I used it more early on in the project withJupyter notebook

JupyterIt's also interactive, allowing you to look at the results while coding, and it can be combined with themarkdownWrite some instructional documents.

After using it, I feel that the main differences between the two are:

3.1 Interactivity

StreamlitProvides a clean user interface in which various controls (e.g. buttons, sliders, etc.) can be easily added.

(indicates contrast)JupyterIs organized in notebooks with code, text and visual output. Supports on-the-fly execution of code blocks and presentation of results.

In comparison.Jupyteris shared as code, which is better suited for trying out various data analysis paths on your own, as well as sharing among developers.

StreamlitSharing in the form of an app does not require knowledge of the code and allows you to directly manipulate the interface, making it more suitable for sharing with clients.

3.2 Visualization capabilities

StreamlitBuilt-in rich visualization components, support for multiple chart types and interactive data presentation, you can easily present the data analysis results to the user in the form of charts.

JupyterVarious visualization charts need to be generated through code blocks, usually by importing other third-party libraries (e.g., matplotlib, seaborn, etc.) to help implement them. Its visualization capabilities depend heavily on the libraries used and the developer's programming skills.

In comparison.StreamlitRequires somewhat less programming skills from the developer, as it is much easier to use built-in packaged components than to use third-party visualization libraries directly.

3.3 Extensibility

StreamlitIn itself, it's purePythoncode file, so it's easy to convert an existingPythonCode to integrate intoStreamlitin the application and enhance the application by adding controls and visualization components.

Jupyteris a block of code organized in the form of a notebook, and is not pure Python code; code reuse and extension relies more on the combination of the block and the editing of the notebook, which requires more consideration.

In comparison.StreamlitExpansion is simpler, and after the complexity of the functionality is increased, encapsulating some of the generic functionality and laying out the code structure is more intuitive.

4. Comparison with Web applications

StreamlitFunctions are betweenJupyterand traditional web applications thanJupyterStrong but weaker than traditional web applications.

I haven't done much data analytics and machine learning related web apps lately, so I may not have given much thought to comparing the two.

Streamlitof interactivity has been mentioned in the previous section.Traditional Web ApplicationsIt goes without saying that there is almost no upper limit to the interactivity, just look at the wide variety of Web applications on the Internet nowadays.

However, for developers focusing on the data analytics and machine learning aspects of the

Traditional Web Applicationsdevelopment is overly difficult, requiring not only mastery of multiple technologies and tools, but also the writing of large amounts of front-end and back-end code, as well as complex debugging and testing.

The other two points mentioned in the previous section.visualization capabilitycap (a poem)scalability

Traditional Web ApplicationsThe ones that can do it are also certainly better thanStreamlitStrong, web applications have evolved over the years.

Especially with the rapid growth of front-end in recent years, theweb applicationIt can be used for a variety of complex games, as well as e-commerce platforms with complex business, and so on.

The question remains how difficult it is to develop, and the choice has to depend on how complex your application is and whether your team can cover the development of theweb applicationThe types of technology needed.

5. Summary

Overall.StreamlitJupytercap (a poem)Traditional Web ApplicationsEach of the three has its own suitable application scenarios, and not one can completely replace the other.

You can refer to the chart below for details on how to choose:

For individuals or students focusing on a data analytics and machine learning orientationStreamlitDefinitely worth a try.