In this program, dashboards and prediction models have been created using Streamlit on the AdventureWorks 2019 dataset. The app uses a machine learning model (Linear Regression) trained on sales data to make predictions. It is built using Streamlit for the frontend interface and scikit-learn for machine learning model development.
The Sales Dashboard app allows users to input various sales-related data fields such as SalesOrderID
, OrderQty
, LineTotal
, StandardCost
, and more. The application uses a pre-trained Linear Regression model to predict the total due for the given input data. This app can be used by businesses to estimate future order dues based on historical data. With the smart dashboard, you can view the current sales situation.
- Input fields for all relevant sales order information, including order quantity, line total, costs, and dates.
- Predict the TotalDue using a pre-trained machine learning model.
- Automatically fills the date fields with the current date.
- Displays an error message if any required fields are missing.
- Easy-to-use web interface powered by Streamlit.
- A dashboard and prediction model based on the AdventureWorks 2019 dataset, completely free to use.
- Python: Main programming language.
- Streamlit: Web framework for building the user interface.
- Plotly: For visualition data on streamlit.
- scikit-learn: For training and using the machine learning model.
- joblib: For saving and loading the trained model.
- MySQL: Database for storing sales data.
To run this application locally, follow these steps:
- Python 3.7 or higher
- Streamlit
- scikit-learn
- joblib
- MySQL (optional if you're using a local MySQL database)
-
Clone the repository to your local machine:
git clone https://github.com/UznetDev/AdventureWorks-Dashboard.git
-
Navigate to the project directory:
cd AdventureWorks-Dashboard
-
Create and activate a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Linux: venv\Scripts\activate # Oon windows
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a .env file:
- On Windows:
wsl nano .env
- On macOS and Linux:
nano .env
- On Windows:
-
Write in the .env file:
HOST= <host default localhost>
MYSQL_USER= <your MySQL user>
MYSQL_PASSWORD= <your MySQL password>
MYSQL_DATABASE= <your MySQL database>
-
Create a run.py file:
- On Windows:
wsl nano run.py
- On macOS and Linux:
nano run.py
- On Windows:
-
Write in the run.py file:
import sys from streamlit.web import cli as stcli if __name__ == "__main__": script_path = " <PATH DIRECTORY> /AdventureWorks-Dashboard/π _Home.py" sys.argv = ["streamlit", "run", script_path, "--server.port", "1003"] stcli.main()
-
Include database:
mysql -u [your MySQL user] -p [your MySQL database] < database/database.sql
-
Run the Streamlit application:
streamlit run app.py
The app should now be running on http://localhost:1003/
.
AdventureWorks-Dashboard/
βββ README.md # Project documentation
βββ loader.py # Python script to load and prepare data
βββ requirements.txt # Project dependencies
βββ LICENSE # License file
β
βββ data/ # Folder for storing raw data
β βββ config.py # A collection of necessary variables
βββ database/ # Database folder
β βββ database.sql # Database for MySql
β
βββ db/ # SQL queries and database operations
β βββ mysql_db.py # Class for working with MySQL database
β
βββ function/ # Python functions for data manipulation
β βββ function.py # Core bot functionalities
β
βββ app/ # aplication Page
β
βββ model.pkl # Pretrained machine learning model (if applicable)
βββ π _Home.py # Main script for π Home page
Once the app is running, you can enter the following fields:
- SalesOrderID: The unique identifier of the sales order.
- OrderQty: The quantity of products ordered.
- LineTotal: The total line cost for the order.
- StandardCost: The standard cost of the product.
- ListPrice: The list price of the product.
- CustomerID: The unique identifier of the customer.
- AccountNumber: The account number associated with the customer.
- OrderDate, DueDate, ShipDate: These fields will be auto-filled with the current date but can be modified if necessary.
After filling in the required fields, press the Predict TotalDue button. The predicted TotalDue
will be displayed on the screen.
The model used in this application is a Linear Regression model trained on historical sales data. The model was trained using the following features:
- OrderQty: Number of units ordered.
- LineTotal: The total value of the order line.
- StandardCost: The cost to produce the product.
- ListPrice: The sales price of the product.
- CustomerID: Customer identifier.
- AccountNumber: Customer's account number.
The prediction is made based on the relationship between these features and the total amount due for previous sales.
We welcome contributions! Please follow these steps:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
If you find any issues with the bot or have suggestions, please open an issue in this repository.
This project is licensed under the MIT License. See the LICENSE file for details.
If you have any questions or suggestions, please contact:
- Email: uznetdev@example.com
- GitHub Issues: Issues section
- GitHub Profile: UznetDev
- Telegram: UZNet_Dev
- Linkedin: Abdurahmon Niyozaliev