Update README.md
Browse files
README.md
CHANGED
|
@@ -28,3 +28,31 @@ It is saved as a pickle file: `model.pkl` and includes all custom layers (e.g.,
|
|
| 28 |
|
| 29 |
```bash
|
| 30 |
pip install torch pandas
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
```bash
|
| 30 |
pip install torch pandas
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
import torch
|
| 34 |
+
|
| 35 |
+
# Load the model from pickle
|
| 36 |
+
with open("model.pkl", "rb") as f:
|
| 37 |
+
model = torch.load(f)
|
| 38 |
+
|
| 39 |
+
model.eval()
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
# Example dummy input
|
| 43 |
+
x_num = torch.rand((1, 10)) # Replace 10 with your actual num_features
|
| 44 |
+
x_cat = torch.randint(0, 5, (1, 3)) # Replace with your actual number of categories
|
| 45 |
+
|
| 46 |
+
# Predict
|
| 47 |
+
churn_prob, predicted_tenure, predicted_ltv = model(x_num, x_cat)
|
| 48 |
+
|
| 49 |
+
print("Churn probability:", churn_prob.item())
|
| 50 |
+
print("Predicted tenure:", predicted_tenure.item())
|
| 51 |
+
print("Predicted LTV:", predicted_ltv.item())
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
(
|
| 55 |
+
churn_prob: FloatTensor of shape (B, 1),
|
| 56 |
+
predicted_tenure: FloatTensor of shape (B, 1),
|
| 57 |
+
predicted_ltv: FloatTensor of shape (B, 1)
|
| 58 |
+
)
|