Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
4 |
-
def entropy(
|
5 |
-
n = len(
|
6 |
|
7 |
counts = np.bincount(X)
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
for i in range(len(
|
12 |
-
|
13 |
|
14 |
-
return
|
15 |
|
16 |
def string_to_list(string):
|
17 |
# Divide the string into a list of substrings separated by commas
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
|
4 |
+
def entropy(numbers):
|
5 |
+
n = len(numbers)
|
6 |
|
7 |
counts = np.bincount(X)
|
8 |
+
probabilities = counts[np.nonzero(counts)] / n
|
9 |
+
|
10 |
+
entropy_value = 0
|
11 |
+
for i in range(len(probabilities)):
|
12 |
+
result = result - probabilities[i] * np.log(probabilities[i])/np.log(2)
|
13 |
|
14 |
+
return result
|
15 |
|
16 |
def string_to_list(string):
|
17 |
# Divide the string into a list of substrings separated by commas
|