sauravlchaudhari commited on
Commit
f6f7d44
·
verified ·
1 Parent(s): 736e692

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +86 -3
README.md CHANGED
@@ -1,3 +1,86 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - tabular-classification
5
+ - tabular-regression
6
+ - pytorch
7
+ - multi-task-learning
8
+ - finance
9
+ - business
10
+ - umkm
11
+ ---
12
+
13
+ # UMKM Multi-Task Learning Network (SME Health & Profitability)
14
+
15
+ ## Model Description
16
+ This is a PyTorch-based **Multi-Task Learning (MTL)** neural network designed to analyze the fundamental health and profitability of Micro, Small, and Medium Enterprises (SMEs/UMKMs).
17
+
18
+ Instead of treating business risk and financial performance as isolated metrics, this model utilizes a shared deep learning body to understand core operational patterns before branching into two distinct predictive heads:
19
+ 1. **Classification Head:** Categorizes the business into one of four risk/health tiers (*Elite, Growth, Struggling, or Critical*).
20
+ 2. **Regression Head:** Forecasts the continuous Net Profit Margin (%) of the business.
21
+
22
+ ## Intended Uses & Limitations
23
+ * **Intended Use:** This model is intended for educational purposes, portfolio demonstration, and as a baseline for quantitative business analysis on tabular data.
24
+ * **Limitations:** The model was trained on the *Synthetic UMKM Dataset*. While it realistically mimics economic skews and operational relationships, it does not represent real-world entities and should not be used for actual financial underwriting without fine-tuning on empirical data.
25
+
26
+ ## Model Architecture
27
+ * **Shared Representation Layers:** 2-layer MLP with BatchNorm, GELU activations, and Dropout (0.2). Extracts underlying business dynamics from 11 core operational features.
28
+ * **Classifier Head:** Predicts 4 distinct classes.
29
+ * **Regression Head:** Outputs a single continuous value representing the profit margin percentage.
30
+
31
+ ## Training Data
32
+ The model was trained on the [Synthetic UMKM Dataset](https://www.kaggle.com/datasets/zkyfauzi/umkm-dataset) by ZkyFauzi on Kaggle, which models the interplay between burn rate, transaction volume, latency, and digital adoption in Indonesian MSMEs.
33
+
34
+ ## How to Get Started with the Model
35
+ You can use the `huggingface_hub` library to easily download the model weights, the feature scaler, and the label encoder to run inference on your own machine.
36
+
37
+ ```python
38
+ import torch
39
+ import torch.nn as nn
40
+ import joblib
41
+ from huggingface_hub import hf_hub_download
42
+ import numpy as np
43
+
44
+ # 1. Define the Architecture
45
+ class UMKM_MultiTaskModel(nn.Module):
46
+ def __init__(self, input_dim=11, num_classes=4):
47
+ super().__init__()
48
+ self.shared_layers = nn.Sequential(
49
+ nn.Linear(input_dim, 128), nn.BatchNorm1d(128), nn.GELU(), nn.Dropout(0.2),
50
+ nn.Linear(128, 64), nn.BatchNorm1d(64), nn.GELU()
51
+ )
52
+ self.classifier_head = nn.Sequential(nn.Linear(64, 32), nn.GELU(), nn.Linear(32, num_classes))
53
+ self.regression_head = nn.Sequential(nn.Linear(64, 32), nn.GELU(), nn.Linear(32, 1))
54
+
55
+ def forward(self, x):
56
+ return self.classifier_head(self.shared_layers(x)), self.regression_head(self.shared_layers(x))
57
+
58
+ # 2. Download Artifacts from Hugging Face
59
+ repo_id = "your-username/your-repo-name" # <--- UPDATE THIS
60
+
61
+ model_path = hf_hub_download(repo_id=repo_id, filename="umkm_mtl_model.pth")
62
+ scaler_path = hf_hub_download(repo_id=repo_id, filename="feature_scaler.pkl")
63
+ encoder_path = hf_hub_download(repo_id=repo_id, filename="label_encoder.pkl")
64
+
65
+ # 3. Load Model and Preprocessors
66
+ scaler = joblib.load(scaler_path)
67
+ label_encoder = joblib.load(encoder_path)
68
+
69
+ model = UMKM_MultiTaskModel()
70
+ model.load_state_dict(torch.load(model_path, map_location=torch.device('cpu')))
71
+ model.eval()
72
+
73
+ # 4. Run Inference (Example using random dummy data)
74
+ # Features must match the 11 training columns:
75
+ # [Monthly_Revenue, Burn_Rate_Ratio, Transaction_Count, Avg_Historical_Rating, Review_Volatility, Business_Tenure_Months, Repeat_Order_Rate, Digital_Adoption_Score, Peak_Hour_Latency (0,1,2), Location_Competitiveness, Sentiment_Score]
76
+ dummy_data = np.array([[15000000, 0.6, 500, 4.5, 0.2, 24, 60.0, 8.0, 0, 3, 0.8]])
77
+ scaled_data = scaler.transform(dummy_data)
78
+ tensor_data = torch.FloatTensor(scaled_data)
79
+
80
+ with torch.no_grad():
81
+ class_logits, margin_pred = model(tensor_data)
82
+ predicted_class = label_encoder.inverse_transform([torch.argmax(class_logits, dim=1).item()])[0]
83
+ predicted_margin = margin_pred.item()
84
+
85
+ print(f"Predicted Class: {predicted_class}")
86
+ print(f"Predicted Net Profit Margin: {predicted_margin:.2f}%")