This shows you the differences between two versions of the page.
| wiki:ai:notebook-collectibles-deployment [2025/06/05 12:16] – created ddehamer | wiki:ai:notebook-collectibles-deployment [2025/06/05 12:23] (current) – ddehamer | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| ===== Process ===== | ===== Process ===== | ||
| - | | + | |
| I exported my home MySQL database of collectibles to a csv file using: | I exported my home MySQL database of collectibles to a csv file using: | ||
| - | < | + | |
| + | < | ||
| mysql -u root -p -e " | mysql -u root -p -e " | ||
| </ | </ | ||
| That gave me a file that looked like this: | That gave me a file that looked like this: | ||
| - | < | + | |
| + | < | ||
| " | " | ||
| " | " | ||
| Line 30: | Line 32: | ||
| ===== Final Working Code ===== | ===== Final Working Code ===== | ||
| - | |||
| ==== Step 1: Upload CSV to Azure ML Notebooks ==== | ==== Step 1: Upload CSV to Azure ML Notebooks ==== | ||
| + | Upload your local ' | ||
| - | Upload | + | **Purpose**: |
| ==== Step 2: Initialize MLClient ==== | ==== Step 2: Initialize MLClient ==== | ||
| - | < | + | < |
| from azure.ai.ml import MLClient | from azure.ai.ml import MLClient | ||
| from azure.identity import DefaultAzureCredential | from azure.identity import DefaultAzureCredential | ||
| Line 50: | Line 52: | ||
| ) | ) | ||
| </ | </ | ||
| + | |||
| + | **Purpose**: | ||
| ==== Step 3: Load CSV and Train Model ==== | ==== Step 3: Load CSV and Train Model ==== | ||
| - | < | + | < |
| import pandas as pd | import pandas as pd | ||
| from sklearn.ensemble import RandomForestRegressor | from sklearn.ensemble import RandomForestRegressor | ||
| Line 78: | Line 82: | ||
| model.fit(X, | model.fit(X, | ||
| joblib.dump(model, | joblib.dump(model, | ||
| - | |||
| </ | </ | ||
| + | |||
| + | **Purpose**: | ||
| ==== Step 4: Create score.py ==== | ==== Step 4: Create score.py ==== | ||
| - | < | + | < |
| # score.py | # score.py | ||
| import joblib | import joblib | ||
| Line 102: | Line 107: | ||
| except Exception as e: | except Exception as e: | ||
| return {" | return {" | ||
| - | |||
| </ | </ | ||
| - | ===== Step 5: Register Model ===== | + | **Purpose**: |
| + | |||
| + | ==== Step 5: Register Model ==== | ||
| - | < | + | < |
| from azure.ai.ml.entities import Model | from azure.ai.ml.entities import Model | ||
| Line 118: | Line 124: | ||
| ) | ) | ||
| ) | ) | ||
| - | |||
| </ | </ | ||
| + | |||
| + | **Purpose**: | ||
| ==== Step 6: Create and Deploy Endpoint ==== | ==== Step 6: Create and Deploy Endpoint ==== | ||
| - | < | + | < |
| from azure.ai.ml.entities import ManagedOnlineEndpoint, | from azure.ai.ml.entities import ManagedOnlineEndpoint, | ||
| import uuid | import uuid | ||
| Line 149: | Line 156: | ||
| update_parameters={" | update_parameters={" | ||
| ).result() | ).result() | ||
| - | |||
| </ | </ | ||
| + | |||
| + | **Purpose**: | ||
| ==== Step 7: Query the Endpoint ==== | ==== Step 7: Query the Endpoint ==== | ||
| - | < | + | < |
| import requests | import requests | ||
| import json | import json | ||
| Line 175: | Line 183: | ||
| print(" | print(" | ||
| print(" | print(" | ||
| - | |||
| </ | </ | ||
| + | |||
| + | **Purpose**: | ||
| [[ai_knowledge|AI Knowledge]] | [[ai_knowledge|AI Knowledge]] | ||
| + | |||
| + | |||