Skip to content
Snippets Groups Projects
Commit 9b0a19d7 authored by Simon Belak's avatar Simon Belak
Browse files

Correctly handle output of nil best-fit and linear-regression

parent 704b3983
No related branches found
No related tags found
No related merge requests found
......@@ -468,15 +468,16 @@
((get-method comparison-vector :default))))
(defn- unpack-linear-regression
[keyfn x-field series {:keys [offset slope]}]
(series->dataset keyfn
[x-field
{:name "TREND"
:display_name "Linear regression trend"
:base_type :type/Float}]
; 2 points fully define a line
(for [[x y] [(first series) (last series)]]
[x (+ (* slope x) offset)])))
[keyfn x-field series {:keys [offset slope] :as model}]
(when model
(series->dataset keyfn
[x-field
{:name "TREND"
:display_name "Linear regression trend"
:base_type :type/Float}]
; 2 points fully define a line
(for [[x y] [(first series) (last series)]]
[x (+ (* slope x) offset)]))))
(defmethod x-ray [DateTime Num]
[{:keys [field series] :as features}]
......
......@@ -216,9 +216,10 @@
http://mathworld.wolfram.com/LeastSquaresFittingPowerLaw.html
http://mathworld.wolfram.com/LeastSquaresFittingLogarithmic.html"
[best-fit]
{:mode (if (-> best-fit :params second pos?)
:growing
:decreasing)
:shape ({:linear-regression :linearly
:power-law-regression :exponentally
:log-linear-regression :logarithmically} (:model best-fit))})
(when best-fit
{:mode (if (-> best-fit :params second pos?)
:growing
:decreasing)
:shape ({:linear-regression :linearly
:power-law-regression :exponentally
:log-linear-regression :logarithmically} (:model best-fit))}))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment