Last active
April 26, 2023 10:46
-
-
Save tamrakarabhishek/725549c60aab29fd006fa6085be247d6 to your computer and use it in GitHub Desktop.
Retail Range Prediction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ML Lifecycle for Range Prediction in Retail | |
| Step 1: Model Creation | |
| MindsDB lets you connect to many databases, data warehouses, data lakes, etc., via the CREATE DATABASE command. | |
| #Query for Database Creation | |
| CREATE DATABASE minds_range_db --- display name for database. | |
| WITH ENGINE = 'postgres', --- name of the mindsdb handler | |
| PARAMETERS = { | |
| "user": "postgres", --- Your database user. | |
| "password": "postgres", --- Your password. | |
| "host": "0.tcp.in.ngrok.io", --- host, it can be an ip or an url. | |
| "port": "14424", --- common port is 5432. | |
| "database": "range_minds_db" --- The name of your database *optional. | |
| }; | |
| Step 2: Training | |
| Once the database is connected and we have data in our AI Tables we can create a model. | |
| The CREATE MODEL statement creates and trains a machine learning (ML) model. Below is the syntax to create a regression model: | |
| #Query for Model Creation & Training | |
| CREATE MODEL mindsdb.range_dates_predictor FROM minds_range_db (SELECT * FROM product_info) | |
| PREDICT on_range_number, off_range_number; | |
| Step 3: Monitor Training | |
| Once the model query is run, it takes some time for the model to get trained based on the size of dataset. One will be able to check the status of the model using the below query: | |
| #Query for Model Training Monitor | |
| SELECT status,error FROM mindsdb.models WHERE name='range_dates_predictor'; | |
| Step 4: QA Test with limited set of products | |
| Once the predictor model status sets to complete, we are now ready to make predictions. | |
| Making predictions is now nothing but querying the predictor model as if it were a table. | |
| The SELECT statement lets you make predictions, follow the below query: | |
| #Query for Model Testing | |
| SELECT on_range_date,on_range_date_explain,off_range_date,off_range_date_explain FROM mindsdb.range_dates_predictor | |
| WHERE primary_color = 'black' AND secondary_color ='blue' AND family_name = 'JACKETS' AND class_name = 'BOMBER' | |
| Step 5: Batch Predict/Serve | |
| After testing and playing out with the predictor now we ready to make batch predictions with real datasets by joining multiple tables. | |
| #Query for Model Prediction | |
| SELECT pi.on_range_date AS 'real_on_range_date',m.on_range_date AS 'predicted_on_range_date', | |
| pi.off_range_date AS 'real_off_range_date', m.off_range_date AS 'predicted_off_range_date', | |
| pi.primary_color,pi.secondary_color,pi.family_name,pi.class_name | |
| FROM product_info AS pi JOIN mindsdb.range_dates_predictor AS m | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment