alexandremoraisdarosa commited on
Commit
21af66c
·
verified ·
1 Parent(s): cea3583

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +260 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Matriz Confusao
3
- emoji:
4
- colorFrom: yellow
5
- colorTo: indigo
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: matriz-confusao
3
+ emoji: ⚛️
4
+ colorFrom: pink
5
+ colorTo: gray
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - QwenSite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,260 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pt-BR">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
6
+ <title>Matriz de Confusão</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
9
+ <style>
10
+ body {
11
+ background-color: #ffffff;
12
+ color: #000000;
13
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
14
+ }
15
+ #center {
16
+ @apply max-w-4xl mx-auto p-6 bg-blue-950 rounded-lg shadow-xl text-white mt-8;
17
+ }
18
+ #title {
19
+ @apply text-4xl font-extrabold text-center mb-2 text-white;
20
+ text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
21
+ }
22
+ #breadcrumps ol {
23
+ @apply flex text-sm mb-6 space-x-2 text-gray-300;
24
+ }
25
+ #breadcrumps a {
26
+ @apply hover:text-white transition-colors;
27
+ }
28
+ .info {
29
+ @apply text-sm text-gray-300 mt-3 mb-1;
30
+ }
31
+ label {
32
+ @apply block mt-2 text-white font-medium;
33
+ }
34
+ input[type="text"] {
35
+ @apply border border-gray-600 rounded px-3 py-1 bg-gray-800 text-white focus:outline-none focus:ring-2 focus:ring-blue-500;
36
+ }
37
+ button {
38
+ @apply mt-4 bg-blue-600 hover:bg-blue-700 text-white font-bold py-2 px-6 rounded transition-colors duration-200 shadow-md;
39
+ }
40
+ button:hover {
41
+ @apply transform scale-105;
42
+ }
43
+ .cf {
44
+ @apply mt-4 text-sm text-gray-400;
45
+ }
46
+ .cf a {
47
+ @apply text-blue-300 hover:underline;
48
+ }
49
+ .matrix {
50
+ @apply mt-6 grid grid-cols-2 gap-0 border border-gray-500 text-center text-lg font-bold;
51
+ box-shadow: inset 0 0 10px rgba(255, 255, 255, 0.1);
52
+ }
53
+ .matrix-cell {
54
+ @apply p-4 border border-gray-600 flex flex-col justify-center items-center;
55
+ }
56
+ .matrix-header {
57
+ @apply bg-gray-800 text-white py-2 font-semibold;
58
+ }
59
+ .metric-card {
60
+ @apply mt-6 p-4 bg-gray-800 rounded-lg shadow border border-gray-700;
61
+ }
62
+ .metric-title {
63
+ @apply font-bold text-blue-300 text-sm uppercase tracking-wider;
64
+ }
65
+ .metric-value {
66
+ @apply text-2xl font-extrabold text-white;
67
+ }
68
+ .instructions {
69
+ @apply mt-8 p-5 bg-gray-800 rounded-lg text-gray-200 text-sm leading-relaxed border border-gray-700;
70
+ }
71
+ .instructions h3 {
72
+ @apply font-bold text-white text-lg mb-2;
73
+ }
74
+ .instructions ul {
75
+ @apply list-disc list-inside ml-4 space-y-1 mb-3;
76
+ }
77
+ </style>
78
+ </head>
79
+ <body class="bg-white text-black">
80
+
81
+ <!-- Header -->
82
+ <header class="bg-blue-950 text-white py-6 shadow-md">
83
+ <div class="container mx-auto text-center">
84
+ <h1 class="text-3xl font-bold"><i class="fas fa-project-diagram mr-2"></i>Aplicativo de Matriz de Confusão</h1>
85
+ <p class="mt-2 text-blue-200">Analise o desempenho do seu modelo de classificação com precisão</p>
86
+ </div>
87
+ </header>
88
+
89
+ <!-- Main Content -->
90
+ <div id="center" class="transition-all duration-300 ease-in-out">
91
+
92
+ <!-- Breadcrumb -->
93
+ <div id="breadcrumps">
94
+ <ol itemscope itemtype="http://schema.org/BreadcrumbList" class="flex">
95
+ <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
96
+ <a itemprop="item" href="#" class="flex items-center">
97
+ <span itemprop="name">Processamento de Dados</span>
98
+ </a>
99
+ <meta itemprop="position" content="1" />
100
+ </li>
101
+ <span class="mx-2">›</span>
102
+ <li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
103
+ <a itemprop="item" href="#" class="flex items-center">
104
+ <span itemprop="name">Matriz de Confusão</span>
105
+ </a>
106
+ <meta itemprop="position" content="2" />
107
+ </li>
108
+ </ol>
109
+ </div>
110
+
111
+ <!-- Confusion Matrix Form -->
112
+ <h2 class="h2_form text-2xl font-bold text-white mb-4">Matriz de Confusão</h2>
113
+ <form id="confusion_matrix" method="post" class="bg-gray-900 p-6 rounded-lg shadow-inner">
114
+
115
+ <!-- True Positive -->
116
+ <p class="info">
117
+ <i class="fas fa-check-circle text-green-400 mr-1"></i>
118
+ Positivo Verdadeiro (PV): item declarado VERDADEIRO, e na realidade VERDADEIRO
119
+ </p>
120
+ <label for="confusion_matrix_tp">Número de Positivos Verdadeiros (PV)</label>
121
+ <input type="text" id="confusion_matrix_tp" name="tp" value="70" size="8" spellcheck="false" class="w-full" />
122
+
123
+ <!-- False Positive -->
124
+ <p class="info mt-4">
125
+ <i class="fas fa-exclamation-triangle text-yellow-400 mr-1"></i>
126
+ Falso Positivo (FP) ou Erro Tipo I: item declarado VERDADEIRO mas na realidade FALSO
127
+ </p>
128
+ <label for="confusion_matrix_fp">Número de Falsos Positivos (FP)</label>
129
+ <input type="text" id="confusion_matrix_fp" name="fp" value="5" size="8" spellcheck="false" class="w-full" />
130
+
131
+ <!-- True Negative -->
132
+ <p class="info mt-4">
133
+ <i class="fas fa-check-circle text-green-400 mr-1"></i>
134
+ Negativo Verdadeiro (NV): item declarado FALSO, e na realidade FALSO
135
+ </p>
136
+ <label for="confusion_matrix_tn">Número de Negativos Verdadeiros (NV)</label>
137
+ <input type="text" id="confusion_matrix_tn" name="tn" value="15" size="8" spellcheck="false" class="w-full" />
138
+
139
+ <!-- False Negative -->
140
+ <p class="info mt-4">
141
+ <i class="fas fa-times-circle text-red-400 mr-1"></i>
142
+ Falso Negativo (FN) ou Erro Tipo II: item declarado FALSO mas na realidade VERDADEIRO
143
+ </p>
144
+ <label for="confusion_matrix_fn">Número de Falsos Negativos (FN)</label>
145
+ <input type="text" id="confusion_matrix_fn" name="fn" value="10" size="8" spellcheck="false" class="w-full" />
146
+
147
+ <!-- Analyze Button -->
148
+ <button type="button" id="analyzeBtn" class="mt-6 flex items-center justify-center">
149
+ <i class="fas fa-calculator mr-2"></i> Analisar
150
+ </button>
151
+
152
+ <!-- Related Tools -->
153
+ <div class="cf mt-6 text-center">
154
+ <span>Consulte também:</span>
155
+ <a href="#" class="ml-1">Precisão e Revocação</a> —
156
+ <a href="#" class="ml-1">Sensibilidade e Especificidade</a>
157
+ </div>
158
+ </form>
159
+
160
+ <!-- Confusion Matrix Display -->
161
+ <div id="matrixContainer" class="mt-8 hidden">
162
+ <h3 class="text-xl font-bold text-center text-white mb-4">Matriz de Confusão</h3>
163
+ <div class="flex justify-center">
164
+ <table class="matrix border-collapse text-white text-center">
165
+ <thead>
166
+ <tr>
167
+ <th class="matrix-header"></th>
168
+ <th class="matrix-header">Previsto: Sim</th>
169
+ <th class="matrix-header">Previsto: Não</th>
170
+ </tr>
171
+ </thead>
172
+ <tbody>
173
+ <tr>
174
+ <td class="matrix-header">Real: Sim</td>
175
+ <td id="cell_tp" class="matrix-cell bg-green-900/50">PV</td>
176
+ <td id="cell_fn" class="matrix-cell bg-red-900/50">FN</td>
177
+ </tr>
178
+ <tr>
179
+ <td class="matrix-header">Real: Não</td>
180
+ <td id="cell_fp" class="matrix-cell bg-yellow-900/50">FP</td>
181
+ <td id="cell_tn" class="matrix-cell bg-blue-900/50">NV</td>
182
+ </tr>
183
+ </tbody>
184
+ </table>
185
+ </div>
186
+ </div>
187
+
188
+ <!-- Metrics Display -->
189
+ <div id="metricsContainer" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mt-6 hidden">
190
+ <div class="metric-card">
191
+ <div class="metric-title">Acurácia</div>
192
+ <div id="accuracy" class="metric-value">--</div>
193
+ </div>
194
+ <div class="metric-card">
195
+ <div class="metric-title">Precisão (PV)</div>
196
+ <div id="precision" class="metric-value">--</div>
197
+ </div>
198
+ <div class="metric-card">
199
+ <div class="metric-title">Sensibilidade</div>
200
+ <div id="recall" class="metric-value">--</div>
201
+ </div>
202
+ <div class="metric-card">
203
+ <div class="metric-title">Especificidade</div>
204
+ <div id="specificity" class="metric-value">--</div>
205
+ </div>
206
+ </div>
207
+
208
+ <!-- Instructions -->
209
+ <div class="instructions mt-8">
210
+ <h3><i class="fas fa-lightbulb mr-2"></i>Instruções de Uso</h3>
211
+ <ul>
212
+ <li><strong>PV (Positivo Verdadeiro):</strong> Quantidade de instâncias corretamente classificadas como positivas.</li>
213
+ <li><strong>FP (Falso Positivo):</strong> Quantidade de instâncias negativas classificadas incorretamente como positivas (Erro Tipo I).</li>
214
+ <li><strong>NV (Negativo Verdadeiro):</strong> Quantidade de instâncias corretamente classificadas como negativas.</li>
215
+ <li><strong>FN (Falso Negativo):</strong> Quantidade de instâncias positivas classificadas incorretamente como negativas (Erro Tipo II).</li>
216
+ </ul>
217
+ <p>Após preencher os valores, clique em <strong>Analisar</strong> para gerar a matriz e visualizar métricas de desempenho do modelo.</p>
218
+ <p class="mt-2"><i class="fas fa-info-circle text-blue-400 mr-1"></i> Este aplicativo é ideal para cientistas de dados, analistas e estudantes que desejam avaliar modelos de classificação binária.</p>
219
+ </div>
220
+
221
+ </div>
222
+
223
+ <!-- Footer -->
224
+ <footer class="bg-blue-950 text-gray-400 py-4 text-center text-sm mt-12">
225
+ <p>© 2023 Aplicativo de Matriz de Confusão | Desenvolvido para análise de modelos de classificação</p>
226
+ </footer>
227
+
228
+ <script>
229
+ document.getElementById('analyzeBtn').addEventListener('click', function () {
230
+ // Get values
231
+ const tp = parseFloat(document.getElementById('confusion_matrix_tp').value) || 0;
232
+ const fp = parseFloat(document.getElementById('confusion_matrix_fp').value) || 0;
233
+ const tn = parseFloat(document.getElementById('confusion_matrix_tn').value) || 0;
234
+ const fn = parseFloat(document.getElementById('confusion_matrix_fn').value) || 0;
235
+
236
+ // Update matrix
237
+ document.getElementById('cell_tp').textContent = tp;
238
+ document.getElementById('cell_fp').textContent = fp;
239
+ document.getElementById('cell_tn').textContent = tn;
240
+ document.getElementById('cell_fn').textContent = fn;
241
+
242
+ // Show matrix and metrics
243
+ document.getElementById('matrixContainer').classList.remove('hidden');
244
+ document.getElementById('metricsContainer').classList.remove('hidden');
245
+
246
+ // Calculate metrics
247
+ const accuracy = (tp + tn) / (tp + fp + tn + fn);
248
+ const precision = tp / (tp + fp) || 0;
249
+ const recall = tp / (tp + fn) || 0; // also known as sensitivity
250
+ const specificity = tn / (tn + fp) || 0;
251
+
252
+ // Display metrics
253
+ document.getElementById('accuracy').textContent = accuracy.toFixed(3);
254
+ document.getElementById('precision').textContent = precision.toFixed(3);
255
+ document.getElementById('recall').textContent = recall.toFixed(3);
256
+ document.getElementById('specificity').textContent = specificity.toFixed(3);
257
+ });
258
+ </script>
259
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-qwensite.hf.space/logo.svg" alt="qwensite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-qwensite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >QwenSite</a> - 🧬 <a href="https://enzostvs-qwensite.hf.space?remix=alexandremoraisdarosa/matriz-confusao" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
260
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Em português. Use as cores branca, preta e azul escuro. Crie um Aplicativo de Matriz de Confusão. Gere instruções de uso. Considere parte do código: <!-- center --> <div id="center"> <h1 id="title">Confusion Matrix</h1> <div id="breadcrumps"><ol itemscope itemtype="http://schema.org/BreadcrumbList"><li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="https://www.dcode.fr/tools-list#data_processing"><span itemprop="name">Data Processing</span></a><meta itemprop="position" content="1" /></li><li itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a itemprop="item" href="https://www.dcode.fr/confusion-matrix"><span itemprop="name">Confusion Matrix</span></a><meta itemprop="position" content="2" /></li></ol></div> <!-- advert --> <div id='div-gpt-ad-1407836191040-0' style='min-width:320px;min-height:100px'></div> <!-- !advert --> <div id="forms"> <h2 class="h2_form" id="f0">Confusion Matrix</h2> <form id="confusion_matrix" method="post"> <p class="info">True Positive (TP) : item declared TRUE, and in reality TRUE</p> <label for="confusion_matrix_tp">Number of True Positive (TP)</label> <input type="text" id="confusion_matrix_tp" name="tp" value="70" size="8" spellcheck="false" class="" /><br/> <p class="info">False Positive (FP) or Type I error: item declared TRUE but in reality FALSE</p> <label for="confusion_matrix_fp">Number of False Positive (FP)</label> <input type="text" id="confusion_matrix_fp" name="fp" value="5" size="8" spellcheck="false" class="" /><br/> <p class="info">True Negative (TN): item declared FALSE, and in reality FALSE</p> <label for="confusion_matrix_tn">Number of True Negative (TN)</label> <input type="text" id="confusion_matrix_tn" name="tn" value="15" size="8" spellcheck="false" class="" /><br/> <p class="info">False Negative (FN) or Type II error: item declared FALSE but in reality TRUE</p> <label for="confusion_matrix_fn">Number of False Negative (FN)</label> <input type="text" id="confusion_matrix_fn" name="fn" value="10" size="8" spellcheck="false" class="" /><br/> <button data-post="tp,fp,tn,fn" post="tp,fp,tn,fn">Analyze</button> <div class="cf "><span>See also:</span> <a href="/precision-recall">Precision and Recall</a> — <a href="/sensibility-specificity">Sensitivity and Specificity</a></div> </form> </div> <!-- advert --> <div id='div-gpt-ad-1407836210596-0' style='min-width:336px;min-height:280px'></div>