0% found this document useful (0 votes)
7 views

Streamlit_App_Setup_Guide

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Streamlit_App_Setup_Guide

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Step-by-Step Guide to Setting Up and Running a Streamlit App on

Windows Using VS Code

Here's a step-by-step guide to setting up and running the Streamlit app on Windows using
VS Code, including installing the necessary libraries:

Step 1: Install Python


1. 1. Download Python: Go to the official Python website [https://www.python.org/]
(https://www.python.org/) and download the latest version of Python (compatible
with Windows).

2. Install Python:

2. Run the installer.


3. Make sure to check the box "Add Python to PATH".
4. Click on Install Now.

3. Verify Installation:

5. Open Command Prompt (`cmd`) and type:

Command:

python --version

6. It should display the Python version installed.

Step 2: Install VS Code


7. 1. Download VS Code: Visit
[https://code.visualstudio.com/](https://code.visualstudio.com/) and download VS
Code for Windows.

2. Install VS Code:

8. Run the installer and follow the installation instructions.


9. During the installation, ensure you check options like "Add to PATH" and "Add Open
with Code action".
Step 3: Install Necessary Libraries
10. 1. Open VS Code and create a new folder where you want to store your project files.

2. Open Terminal in VS Code:

11. Go to View > Terminal or press `Ctrl + ~`.

3. Install Libraries:

12. In the terminal, run the following command to install Streamlit and other necessary
libraries:

Command:

pip install streamlit pandas numpy scikit-learn matplotlib seaborn

13. This installs all the libraries needed for the app: Streamlit, pandas, numpy, scikit-learn,
matplotlib, and seaborn.

Step 4: Create the Streamlit App File


14. 1. Create a New File:
15. In VS Code, create a new file in your project folder and name it `ml_algo.py`.

2. Paste the Streamlit Code:

16. Copy the Streamlit code I provided earlier and paste it into the `ml_algo.py` file.

Step 5: Run the Streamlit App


17. 1. Open Terminal:
18. Ensure you are in the folder where `ml_algo.py` is located.

2. Run the Streamlit App:

19. In the terminal, type:

Command:

streamlit run ml_algo.py

20. This command will start the Streamlit server, and it should automatically open a new
tab in your default web browser displaying the Streamlit app.
21. If it doesn’t open automatically, go to the URL shown in the terminal (usually
`http://localhost:8501`).
Step 6: Interact with the App
22. 1. Upload Dataset: Upload your CSV file using the file uploader.

2. Select Features and Target: Choose your features and target column from the dataset.

3. Choose Model: Select between "Linear Regression" or "Decision Tree Classifier."

4. Train and Predict:

23. Train the model by clicking the "Train" button.


24. Enter input values for the selected features; the prediction and accuracy will update
dynamically.

5. Scatter Plot: Select the X and Y axis features to view a scatter plot.

Step 7: Stop the Streamlit Server (When Done)


25. Go back to your terminal and press `Ctrl + C` to stop the Streamlit server.

Additional Notes
26. Restart the Server: Anytime you make changes to `ml_algo.py`, save the file, and
Streamlit will automatically refresh the browser window. If it doesn’t refresh, restart
the server with `streamlit run ml_algo.py`.

You might also like