mdod 1.0.9__tar.gz → 2.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mdod-1.0.9 → mdod-2.0.0}/PKG-INFO +4 -1
- mdod-2.0.0/mdod/mdod.py +55 -0
- {mdod-1.0.9 → mdod-2.0.0}/mdod.egg-info/PKG-INFO +4 -1
- {mdod-1.0.9 → mdod-2.0.0}/setup.py +1 -1
- mdod-1.0.9/mdod/mdod.py +0 -39
- {mdod-1.0.9 → mdod-2.0.0}/LICENSE.txt +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/README.md +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/mdod/__init__.py +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/mdod.egg-info/SOURCES.txt +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/mdod.egg-info/dependency_links.txt +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/mdod.egg-info/top_level.txt +0 -0
- {mdod-1.0.9 → mdod-2.0.0}/setup.cfg +0 -0
@@ -1,11 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mdod
|
3
|
-
Version:
|
3
|
+
Version: 2.0.0
|
4
4
|
Summary: MDOD, Multi-Dimensional data Outlier Detection
|
5
5
|
Home-page: https://github.com/mddod/mdod
|
6
6
|
Author: Z Shen
|
7
7
|
Author-email: 626456708@qq.com
|
8
8
|
License: BSD 3-Clause License
|
9
|
+
Platform: UNKNOWN
|
9
10
|
Classifier: Development Status :: 5 - Production/Stable
|
10
11
|
Classifier: Intended Audience :: Developers
|
11
12
|
Classifier: Programming Language :: Python
|
@@ -82,3 +83,5 @@ data1,data2,data3,data4,data5,data6
|
|
82
83
|
Please visit https://github.com/mddod/mdod, or https://mddod.github.io/
|
83
84
|
|
84
85
|
|
86
|
+
|
87
|
+
|
mdod-2.0.0/mdod/mdod.py
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
import numpy as np
|
2
|
+
|
3
|
+
def md(detections, norm_distance, top_n):
|
4
|
+
"""
|
5
|
+
Calculate the vector cosine similarity score and return the sum of the first top_n scores of each vector.
|
6
|
+
|
7
|
+
Args:
|
8
|
+
detections: Array data
|
9
|
+
norm_distance: Standardized distance value (scalar) in the new dimension
|
10
|
+
top_n: The number of highest similarity scores retained
|
11
|
+
|
12
|
+
Returns:
|
13
|
+
List of [score_sum, original_vector, index]
|
14
|
+
"""
|
15
|
+
# Input verification: check whether detections is empty or whether top_n is valid
|
16
|
+
if detections is None or detections.size == 0 or top_n <= 0:
|
17
|
+
return []
|
18
|
+
|
19
|
+
# Make sure the input is a NumPy array
|
20
|
+
dets_array = np.array(detections, dtype=float)
|
21
|
+
n_samples, n_features = dets_array.shape
|
22
|
+
|
23
|
+
# Precomputed constant term
|
24
|
+
nd_squared = norm_distance ** 2
|
25
|
+
denominator_left = norm_distance
|
26
|
+
|
27
|
+
# Result storage
|
28
|
+
result_list = []
|
29
|
+
|
30
|
+
# Vectorize each vector
|
31
|
+
for i in range(n_samples):
|
32
|
+
current_vector = dets_array[i]
|
33
|
+
|
34
|
+
# Calculate the sum of squares of the difference between all vectors and the current vector
|
35
|
+
diff = dets_array - current_vector
|
36
|
+
diff_squared_sum = np.sum(diff ** 2, axis=1)
|
37
|
+
|
38
|
+
# Calculate the right part of the denominator
|
39
|
+
denominator_right = np.sqrt(diff_squared_sum + nd_squared)
|
40
|
+
denominator = denominator_left * denominator_right
|
41
|
+
|
42
|
+
# Calculate the molecule
|
43
|
+
numerator = nd_squared * np.ones(n_samples)
|
44
|
+
|
45
|
+
# Calculate the similarity score and avoid dividing by zero
|
46
|
+
similarity_scores = np.where(denominator == 0, 0, numerator / denominator)
|
47
|
+
similarity_scores[i] = -np.inf
|
48
|
+
|
49
|
+
# Get the sum of the top_n scores
|
50
|
+
top_scores_sum = np.sum(np.partition(similarity_scores, -top_n)[-top_n:])
|
51
|
+
|
52
|
+
# Save result
|
53
|
+
result_list.append([top_scores_sum, detections[i].tolist(), i])
|
54
|
+
|
55
|
+
return result_list
|
@@ -1,11 +1,12 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: mdod
|
3
|
-
Version:
|
3
|
+
Version: 2.0.0
|
4
4
|
Summary: MDOD, Multi-Dimensional data Outlier Detection
|
5
5
|
Home-page: https://github.com/mddod/mdod
|
6
6
|
Author: Z Shen
|
7
7
|
Author-email: 626456708@qq.com
|
8
8
|
License: BSD 3-Clause License
|
9
|
+
Platform: UNKNOWN
|
9
10
|
Classifier: Development Status :: 5 - Production/Stable
|
10
11
|
Classifier: Intended Audience :: Developers
|
11
12
|
Classifier: Programming Language :: Python
|
@@ -82,3 +83,5 @@ data1,data2,data3,data4,data5,data6
|
|
82
83
|
Please visit https://github.com/mddod/mdod, or https://mddod.github.io/
|
83
84
|
|
84
85
|
|
86
|
+
|
87
|
+
|
mdod-1.0.9/mdod/mdod.py
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
# -*-coding: utf-8- -*-
|
2
|
-
#MDOD, Multi-Dimensional data Outlier Detection
|
3
|
-
# Author: Z Shen<626456708@qq.com>
|
4
|
-
# License: BSD 3-Clause License
|
5
|
-
|
6
|
-
import numpy as np
|
7
|
-
|
8
|
-
def md(dets0, nd, sn):
|
9
|
-
VCS_list = []
|
10
|
-
i = 0
|
11
|
-
|
12
|
-
for line0 in dets0:
|
13
|
-
VCSResult_list = []
|
14
|
-
line0_arr = np.array(line0, dtype=float)
|
15
|
-
|
16
|
-
for j, line1 in enumerate(dets0):
|
17
|
-
if j == i:
|
18
|
-
continue
|
19
|
-
|
20
|
-
line1_arr = np.array(line1, dtype=float)
|
21
|
-
|
22
|
-
DenominatorLeft = np.sqrt(np.sum((line0_arr - line0_arr) ** 2) + (nd - 0) ** 2)
|
23
|
-
DenominatorRight = np.sqrt(np.sum((line0_arr - line1_arr) ** 2) + (nd - 0) ** 2)
|
24
|
-
DenominatorSum = DenominatorLeft * DenominatorRight
|
25
|
-
|
26
|
-
NumeratorSum = np.sum(np.sqrt((line0_arr - line0_arr) ** 2) * np.sqrt((line0_arr - line1_arr) ** 2))
|
27
|
-
NumeratorPlus = np.sqrt((nd - 0) ** 2) * np.sqrt((nd - 0) ** 2)
|
28
|
-
NumeratorSum += NumeratorPlus
|
29
|
-
|
30
|
-
VCSResult = 0 if DenominatorSum == 0 else NumeratorSum / DenominatorSum
|
31
|
-
VCSResult_list.append(VCSResult)
|
32
|
-
|
33
|
-
VCSResult_list.sort(reverse=True)
|
34
|
-
VCSTotal = sum(VCSResult_list[:min(sn, len(VCSResult_list))])
|
35
|
-
|
36
|
-
VCS_list.append([VCSTotal, line0.tolist(), i])
|
37
|
-
i += 1
|
38
|
-
|
39
|
-
return VCS_list
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|