This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (11)
- # babashka (82)
- # beginners (51)
- # calva (11)
- # cider (3)
- # clj-kondo (62)
- # cljdoc (10)
- # cljs-dev (22)
- # clojure (75)
- # clojure-boston (1)
- # clojure-brasil (3)
- # clojure-czech (4)
- # clojure-europe (49)
- # clojure-france (10)
- # clojure-italy (16)
- # clojure-nl (5)
- # clojure-uk (9)
- # clojurescript (69)
- # community-development (33)
- # conjure (12)
- # core-async (6)
- # cursive (2)
- # datalevin (7)
- # datomic (6)
- # graalvm (13)
- # gratitude (2)
- # honeysql (3)
- # introduce-yourself (1)
- # lsp (37)
- # nextjournal (62)
- # off-topic (29)
- # pathom (1)
- # quil (2)
- # reitit (4)
- # releases (2)
- # sci (1)
- # shadow-cljs (28)
- # spacemacs (10)
- # sql (1)
- # tools-build (3)
- # vim (3)
QUick math questions, I have a series of dates, my x-axis and a series of values for each date (my y-axis), the dates are 15 minutes segments. What do I want to DDG to figure out the trend of the values and see when that trend will cut the x axis ?
Say my points look something like this (sorry for hte terrible MS Paint) Would linear regression have a way to ignore the big spike that is so far outside the normal range ? OR would I have to figure out way to remove this first before doing the linear regression part ?
The second. Linear regression just finds a, well, line, that fits your data better than any other. To filter out such spikes, you have to do it yourself - either by manually filtering for outliers or by using some statistical tool with some cut-offs.
Thanks, What I basically have is data recorded from a device, but it contains some rare spikes. However if the values outside that spike are trending down, I'd like to be able to figure out after each recording a rough prediction when it will be at 0
Does removing the spikes then linear regression seem like a reasonable way to achieve this ?
The easiest way is, no joke, to use Excel for that. :D Or LibreOffice Calc or whatever else spreadsheet software you might have. Assuming the amount of data is not huge.
> Does removing the spikes then linear regression seem like a reasonable way to achieve this ? Yes. Without any model behind the data, it's pretty much the way to do it.
I'd like to somehow automate it, the data coming in is automated, and I'd like to somehow get an alert to me that I need to do something
So I was thinking do this is at the service that is pulling the data off a rabbit MQ queue I have setup
Well, I'd also add "create a model for your data" as the step 0 above - otherwise, you can't really clean your data.
One possibility is to determine the mean μ, and standard deviation σ, and then filter out (or clip) all data that differs from the mean by, say, 2σ.
(filter #(< (abs (- % mean)) (* 2 std-dev)) data)
or to clip:
That tends to clean up most extreme outliers. It’s not perfect. If outliers are really extreme, then it can change the mean to pull the some data outside of a 2σ range (this is incredibly unlikely). If that were to happen, then a 2 step process can help, where standard deviation is calculated once, then some large multiple of σ is used to filter the data, and then repeat the process with a more modest multiple of σ. (I’ve never seen this needed)
(map #(let [std-dev2 (* 2 std-dev) diff (- % mean)] (if (> 0 diff) (max % (- mean std-dev2)) (min % (+ mean std-dev2)))) data)
As a bit of trivia, clipping extreme values is called https://en.wikipedia.org/wiki/Winsorizing
@U0K1RLM99 might just have som info on this.
Hello. I’m with @U2FRKM4TW on this, Excel/LibreOffice is the perfect starting point for any sort of Linear Regression. In the book I used Apache Commons Math to put together a 2D array of double values, that will output LR as well. Easy enough to retrain from RabbitMQ as well but you’ll have to persist the data somewhere obviously. I’m only skim reading the thread, so apologies if it’s already been covered.
Or you can also use linear model, but fitted with different error function. Normally, one uses Least squares error, but then outliers (e.g. your spike) can have disproportionate effect. So you might want to checkout Huber loss. Other keywords are outlier detection/removal, as @U051N6TTC suggests. You can also do that by "distance from the fitted line", ie, remove the points, that are most far away from the fit (instead of data mean).
+1 on @U051N6TTC technique. I'd plot the values on a histogram, and if it looks reasonably bell-curvy, clipping out values 3 or 2 std deviations from the mean might work well. But convince yourself that you’re genuinely trimming the tails/outliers.
I’d filter it out - you know unless you’ve just discovered another particle past the Higgs.
Anyone here got this watch - any good? https://shop.espruino.com/banglejs2
It seems like the thing I'm after for while: good battery life, nothing fancy: time + pedometer, that's it. But this thing is even programmable.
I have the original bangle but haven't used it much, it was too big. This looks much more manageable I thought about making a bangle-cljs wrapper lib back when I first got it :p
@U04V15CAJ Did you end up ordering one? Looks quite interesting.