Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Last updated: 2025-04-29
- Terraform [Demonstration: Deploying Azure Resources for a Data Platform (Microsoft Fabric)](./infrastructure/msFabric/)
- Terraform [Demonstration: Deploying Azure Resources for an ML Platform](./infrastructure/azMachineLearning/)
- [Demostration: How to integrate AI in Microsoft Fabric](./msFabric-AI_integration/)
- [Demostration: Creating a Machine Learning Model](./azML-modelcreation/)

> Azure Machine Learning (PaaS) is a cloud-based platform from Microsoft designed to help `data scientists and machine learning engineers build, train, deploy, and manage machine learning models at scale`. It supports the `entire machine learning lifecycle, from data preparation and experimentation to deployment and monitoring.` It provides powerful tools for `both code-first and low-code users`, including Jupyter notebooks, drag-and-drop interfaces, and automated machine learning (AutoML). `Azure ML integrates seamlessly with other Azure services and supports popular frameworks like TensorFlow, PyTorch, and Scikit-learn.`

Expand Down Expand Up @@ -228,18 +229,6 @@ Read more about [Endpoints for inference in production](https://learn.microsoft.
| **Attached Compute** | External compute resources manually connected to Azure ML. | Leverage existing infrastructure. | Using Azure VMs, Databricks, or on-prem compute. | Flexibility, hybrid cloud support, reuse of existing resources. |
| **Serverless Instances** | Lightweight, on-demand compute (e.g., Azure Container Instances). | Quick testing and low-scale inference. | Temporary model deployment, dev/test environments. | No infrastructure management, fast startup, cost-effective. |

> How to create a Compute Instance:

1. **Go to Azure Machine Learning Studio**: Navigate to [ml.azure.com](https://ml.azure.com/) and select your workspace.
2. **Select `Compute` from the left menu** Choose the **`Compute instances`** tab.
3. **Click `New`**
- Enter a name for your compute instance.
- Choose a virtual machine size (e.g., `Standard_DS3_v2`).
- Optionally, enable SSH access or assign a user.
4. **Click `Create`**: Azure will provision the compute instance, which may take a few minutes.

https://github.com/user-attachments/assets/bd5f3ce6-7082-4741-8827-8b344cd249a4

</details>

<details>
Expand Down
158 changes: 158 additions & 0 deletions azML-modelcreation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# Demostration: Creating a Machine Learning Model

Costa Rica

[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)

Last updated: 2025-04-29

------------------------------------------


<details>
<summary><b>List of References </b> (Click to expand)</summary>

</details>

<details>
<summary><b>Table of Content </b> (Click to expand)</summary>

</details>

## Step 1: Set Up Your Azure ML Workspace

> You can use the azure portal approach:

- Go to the [Azure Portal](https://portal.azure.com/)
- Create a **Machine Learning workspace**:
- Resource group
- Workspace name
- Region
- Once created, launch **Azure Machine Learning Studio**.

https://github.com/user-attachments/assets/c199156f-96cf-4ed0-a8b5-c88db3e7a552

> Or using terraform configurations for setting up an Azure Machine Learning workspace along with compute clusters and supportive resources to form the core of an ML platform, click here to see [Demonstration: Deploying Azure Resources for an ML Platform](./infrastructure/azMachineLearning/README.md)

## Step 2: Create a Compute Instance

1. **Go to [Azure Machine Learning Studio](https://ml.azure.com/)** and select your workspace.
2. **Select `Compute` from the left menu** Choose the **`Compute instances`** tab.
3. **Click `New`**
- Enter a name for your compute instance.
- Choose a virtual machine size (e.g., `Standard_DS3_v2`).
- Optionally, enable SSH access or assign a user.
4. **Click `Create`**: Azure will provision the compute instance, which may take a few minutes.

https://github.com/user-attachments/assets/bd5f3ce6-7082-4741-8827-8b344cd249a4

## Step 3: Prepare Your Data

- Upload your dataset to **Azure ML datastore** or connect to exrnal sources (e.g., Azure Blob Storage, SQL, etc.).
- Use **Data > Datasets** to register and version your dataset.

> For example: Upload the CSV to Azure ML

1. Under to **Data > + Create > From local files**.
2. Choose:
- **Name**: `employee_data`
- **Type**: Tabular
- **Browse** and upload the [sample_data.csv](./azML-modelcreation/data/sample_data.csv) file.
3. Click **Next**, then **Review + Create**.

> Register the Dataset:

1. After upload, Azure will preview the data.
2. Confirm the schema (column names and types).
3. Click **Create** to register the dataset.

https://github.com/user-attachments/assets/f8cbd32c-94fc-43d3-a7a8-00f63cdc543d


### **4. Create a New Notebook or Script**
- Use the compute instance to open a **Jupyter notebook** or create a Python script.
- Import necessary libraries:
```python
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
```

---

### **5. Load and Explore the Data**
- Load the dataset and perform basic EDA (exploratory data analysis):
```python
data = pd.read_csv('your_dataset.csv')
print(data.head())
```

---

### **6. Train Your Model**
- Split the data and train a model:
```python
X = data.drop('target', axis=1)
y = data['target']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

model = RandomForestClassifier()
model.fit(X_train, y_train)
```

---

### **7. Evaluate the Model**
- Check performance:
```python
predictions = model.predict(X_test)
print("Accuracy:", accuracy_score(y_test, predictions))
```

---

### **8. Register the Model**
- Save and register the model in Azure ML:
```python
import joblib
joblib.dump(model, 'model.pkl')

from azureml.core import Workspace, Model
ws = Workspace.from_config()
Model.register(workspace=ws, model_path="model.pkl", model_name="my_model")
```

---

### **9. Deploy the Model**
- Create an **inference configuration** and deploy to a web service:
```python
from azureml.core.environment import Environment
from azureml.core.model import InferenceConfig
from azureml.core.webservice import AciWebservice

env = Environment.from_conda_specification(name="myenv", file_path="env.yml")
inference_config = InferenceConfig(entry_script="score.py", environment=env)

deployment_config = AciWebservice.deploy_configuration(cpu_cores=1, memory_gb=1)
service = Model.deploy(workspace=ws,
name="my-service",
models=[model],
inference_config=inference_config,
deployment_config=deployment_config)
service.wait_for_deployment(show_output=True)
```

---

### **10. Test the Endpoint**
- Once deployed, you can send HTTP requests to the endpoint to get predictions.



<div align="center">
<h3 style="color: #4CAF50;">Total Visitors</h3>
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
</div>
25 changes: 25 additions & 0 deletions azML-modelcreation/data/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Sample Data

Costa Rica

[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
[brown9804](https://github.com/brown9804)

Last updated: 2025-04-29

------------------------------------------

> This dataset is a synthetic sample of employee records created for demonstration and training purposes in a machine learning workflow. This sample data is designed to simulate a
> realistic HR dataset and will be used to build and evaluate a machine learning model for tasks such as salary prediction, employee segmentation, or attrition analysis.
> It contains > 50,000 rows with the following attributes:

- **Name**: A randomly selected first name.
- **Age**: An integer representing the employee's age (22–65).
- **Department**: The department where the employee works (e.g., HR, Engineering, Sales).
- **Salary**: The employee's annual salary in USD, ranging from \$40,000 to \$120,000.


<div align="center">
<h3 style="color: #4CAF50;">Total Visitors</h3>
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
</div>
Loading