Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rdm-software
SaQC
Commits
b6cfbfe7
Commit
b6cfbfe7
authored
4 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Plain Diff
Merge branch 'kNNoperators' into 'develop'
K n noperators See merge request
!204
parents
b6c5cca0
949ab048
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!204
K n noperators
Pipeline
#14747
passed with stages
in 10 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/lib/ts_operators.py
+6
-18
6 additions, 18 deletions
saqc/lib/ts_operators.py
with
6 additions
and
18 deletions
saqc/lib/ts_operators.py
+
6
−
18
View file @
b6cfbfe7
...
...
@@ -124,24 +124,12 @@ def kNN(in_arr, n_neighbors, algorithm="ball_tree", metric='minkowski', p=2, rad
i
+=
1
return
dist
,
np
.
array
([])
def
kNNMaxGap
(
in_arr
,
n_neighbors
=
10
,
algorithm
=
"
ball_tree
"
):
# searches for the "n_neighbors" nearest neighbors of every value in "in_arr"
# and then returns the distance to the neighbor with the "maximum" Gap to its
# predecessor in the neighbor hierarchy
in_arr
=
np
.
asarray
(
in_arr
)
dist
,
*
_
=
kNN
(
in_arr
,
n_neighbors
,
algorithm
=
algorithm
)
sample_size
=
dist
.
shape
[
0
]
to_gap
=
np
.
append
(
np
.
array
([[
0
]
*
sample_size
]).
T
,
dist
,
axis
=
1
)
max_gap_ind
=
np
.
diff
(
to_gap
,
axis
=
1
).
argmax
(
axis
=
1
)
return
dist
[
range
(
0
,
sample_size
),
max_gap_ind
]
def
kNNSum
(
in_arr
,
n_neighbors
=
10
,
algorithm
=
"
ball_tree
"
):
# searches for the "n_neighbors" nearest neighbors of every value in "in_arr"
# and assigns that value the summed up distances to this neighbors
in_arr
=
np
.
asarray
(
in_arr
)
dist
,
*
_
=
kNN
(
in_arr
,
n_neighbors
,
algorithm
=
algorithm
)
return
dist
.
sum
(
axis
=
1
)
def
maxGap
(
in_arr
):
"""
Search for the maximum gap in an array of sorted distances (func for scoring kNN distance matrice)
"""
return
max
(
in_arr
[
0
],
max
(
np
.
diff
(
in_arr
)))
@nb.njit
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment