Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Engineering Digital Service
Metabase
Commits
e8c1c0d6
Commit
e8c1c0d6
authored
7 years ago
by
Simon Belak
Browse files
Options
Downloads
Patches
Plain Diff
Speed up variation-trend and stationarity insight
parent
2c33fef8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/test/xray/xray.integ.spec.js
+2
-2
2 additions, 2 deletions
frontend/test/xray/xray.integ.spec.js
src/metabase/feature_extraction/insights.clj
+24
-22
24 additions, 22 deletions
src/metabase/feature_extraction/insights.clj
with
26 additions
and
24 deletions
frontend/test/xray/xray.integ.spec.js
+
2
−
2
View file @
e8c1c0d6
...
...
@@ -286,7 +286,7 @@ describe("xray integration tests", () => {
})
it
(
"
let you see card xray for a timeseries question
"
,
async
()
=>
{
await
SettingsApi
.
put
({
key
:
'
xray-max-cost
'
,
value
:
'
ex
act
'
})
await
SettingsApi
.
put
({
key
:
'
xray-max-cost
'
,
value
:
'
ex
tended
'
})
const
store
=
await
createTestStore
()
// make sure xrays are on and at the proper cost
store
.
pushPath
(
Urls
.
question
(
timeBreakoutQuestion
.
id
()))
...
...
@@ -310,7 +310,7 @@ describe("xray integration tests", () => {
expect
(
cardXRay
.
text
()).
toMatch
(
/Time breakout question/
);
// Should contain the expected insights
expect
(
app
.
find
(
InsightCard
).
length
).
toBe
(
2
)
expect
(
app
.
find
(
InsightCard
).
length
>
0
).
toBe
(
true
)
expect
(
app
.
find
(
NoisinessInsight
).
length
).
toBe
(
1
)
expect
(
app
.
find
(
AutocorrelationInsight
).
length
).
toBe
(
1
)
})
...
...
This diff is collapsed.
Click to expand it.
src/metabase/feature_extraction/insights.clj
+
24
−
22
View file @
e8c1c0d6
...
...
@@ -73,8 +73,10 @@
"Is there a consistent thrend in changes of variation from one period to the
next?
We determine the trend by fitting a linear regression and test the hypothesis
that slope is not significantly different from 0.
We determine the trend by calculating relative variance for each period window
and fit a linear regression to the resulting sequence of variances. We then
test the hypothesis that the slope of this regression is not significantly
different from 0.
https://en.wikipedia.org/wiki/Simple_linear_regression
https://msu.edu/course/msc/317/slr-reg.htm
https://en.wikipedia.org/wiki/Variance"
...
...
@@ -86,10 +88,10 @@
(
map-indexed
(
fn
[
i
xsi
]
[
i
(
transduce
(
map
second
)
(
redux/post-complete
(
redux/juxt
stats/variance
stats/mean
)
(
fn
[[
var
mean
]]
(
/
var
mean
)))
h/histogram
(
fn
[
histogram
]
(
/
(
h.impl/variance
histogram
)
(
h.impl/mean
histogram
)
)))
xsi
)]))
(
redux/post-complete
(
redux/juxt
...
...
@@ -109,11 +111,10 @@
(
sq
s-y
)
(
*
(
sq
slope
)
(
-
(
*
n
s-xx
)
(
sq
s-x
)))))]
(
when
(
math/significant?
(
if
(
zero?
slope
)
0
(
/
slope
slope-error
))
(
d/t-distribution
(
-
n
2
))
(
/
0.05
2
))
(
when
(
and
(
not=
slope
0
)
(
math/significant?
(
/
slope
slope-error
)
(
d/t-distribution
(
-
n
2
))
(
/
0.05
2
)))
{
:mode
(
if
(
pos?
slope
)
:increasing
:decreasing
)})))))))))
...
...
@@ -187,15 +188,16 @@
https://en.wikipedia.org/wiki/Welch%27s_t-test
https://en.wikipedia.org/wiki/Stationary_process"
[
series
resolution
]
(
when
resolution
(
let
[
n
(
ts/period-length
resolution
)]
(
->>
series
(
partition
n
1
)
(
map
(
partial
transduce
(
map
second
)
(
redux/fuse
{
:mean
stats/mean
:var
stats/variance
})))
(
partition
2
1
)
(
map
(
fn
[[{
mean1
:mean
variance1
:var
}
{
mean2
:mean
variance2
:var
}]]
(
when-let
[
n
(
ts/period-length
resolution
)]
(
->>
series
(
partition
n
1
)
(
map
(
partial
transduce
(
map
second
)
h/histogram
))
(
partition
2
1
)
(
map
(
fn
[[
h1
h2
]]
(
let
[
mean1
(
h.impl/mean
h1
)
mean2
(
h.impl/mean
h2
)
variance1
(
h.impl/variance
h1
)
variance2
(
h.impl/variance
h2
)]
(
if
(
=
variance1
variance2
0
)
false
(
let
[
t
(
/
(
-
mean1
mean2
)
...
...
@@ -205,5 +207,5 @@
(
/
(
+
(
sq
variance1
)
(
sq
variance2
))
(
*
n
(
-
n
1
)))))]
(
math/significant?
t
(
d/t-distribution
k
)
(
/
0.05
2
))))))
(
every?
false?
))))
)
(
math/significant?
t
(
d/t-distribution
k
)
(
/
0.05
2
))))))
)
(
every?
false?
))))
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