-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi_test_DT_classifier.html
More file actions
88 lines (75 loc) · 2.68 KB
/
api_test_DT_classifier.html
File metadata and controls
88 lines (75 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Decision Tree Classifier - Predict Customer Churn</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 40px;
max-width: 500px;
}
input[type="number"] {
width: 100%;
padding: 8px;
margin: 8px 0;
box-sizing: border-box;
}
button {
padding: 10px 15px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
margin-top: 10px;
}
#result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<h2>Predict Customer Churn using a Decision Tree Classifier</h2>
<form id="predictForm">
<label for="monthly_fee">Monthly Fee:</label>
<input type="number" id="monthly_fee" name="monthly_fee" required>
<label for="customer_age">Customer Age:</label>
<input type="number" id="customer_age" name="customer_age" required>
<label for="support_calls">Support Calls:</label>
<input type="number" id="support_calls" name="support_calls" required>
<button type="submit">Predict</button>
</form>
<div id="result"></div>
<script>
document.getElementById('predictForm').addEventListener('submit', async function(event) {
event.preventDefault();
// Read form values
const monthly_fee = parseFloat(document.getElementById('monthly_fee').value);
const customer_age = parseFloat(document.getElementById('customer_age').value);
const support_calls = parseFloat(document.getElementById('support_calls').value);
// Create JSON payload
const data = {
monthly_fee: monthly_fee,
customer_age: customer_age,
support_calls: support_calls
};
try {
const response = await fetch('http://127.0.0.1:5000/api/v1/models/decision-tree-classifier/predictions', {
// const response = await fetch('https://127.0.0.1:443/api/v1/models/decision-tree-classifier/predictions', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
const result = await response.json();
document.getElementById('result').innerText = 'Prediction: ' + result['Predicted Class = '];
} catch (error) {
console.error('Error:', error);
document.getElementById('result').innerText = 'An error occurred while making the prediction.';
}
});
</script>
</body>
</html>