lynn-twinkl
commited on
Commit
·
d15bf17
1
Parent(s):
d3f625e
Added minmax scaler
Browse files- functions/necessity_index.py +10 -0
functions/necessity_index.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import pandas as pd
|
|
|
|
| 2 |
import re
|
| 3 |
|
| 4 |
# ---------------- MARKERS ----------------
|
|
@@ -91,3 +92,12 @@ def compute_necessity(text):
|
|
| 91 |
totals['vulnerability_score'] += category_count
|
| 92 |
|
| 93 |
return pd.Series(totals)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
import numpy as np
|
| 3 |
import re
|
| 4 |
|
| 5 |
# ---------------- MARKERS ----------------
|
|
|
|
| 92 |
totals['vulnerability_score'] += category_count
|
| 93 |
|
| 94 |
return pd.Series(totals)
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
## -------- SCALING FUNCTION --------
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def index_scaler(values):
|
| 101 |
+
x_min = np.min(values)
|
| 102 |
+
x_max = np.max(values)
|
| 103 |
+
return [(x - x_min) / (x_max - x_min) if x_max != x_min else 0.5 for x in values]
|