Business intelligence made simple
Dropped support for R anomaly detection [skip ci]
Andrew Kane8c6d31b13907
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d93ca77c..8e245ae5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1,6 +1,7 @@## 3.0.0 (unreleased)- Dropped support for Ruby < 2.7 and Rails < 6+- Dropped support for R anomaly detection## 2.6.5 (2022-08-31)diff --git a/lib/blazer/detect_anomalies.R b/lib/blazer/detect_anomalies.Rdeleted file mode 100644index cbdc32b2..00000000--- a/lib/blazer/detect_anomalies.R+++ /dev/null@@ -1,19 +0,0 @@-tryCatch({- library(AnomalyDetection)-- args <- commandArgs(trailingOnly = TRUE)-- con <- textConnection(args[2])- data <- read.csv(con, stringsAsFactors = FALSE)- data$timestamp <- as.POSIXct(data$timestamp)-- if (identical(args[1], "ts")) {- res <- AnomalyDetectionTs(data, direction = "both", alpha = 0.05, max_anoms = 0.2)- } else {- res <- AnomalyDetectionVec(data$count, direction = "both", alpha = 0.05, max_anoms = 0.2, period = length(data$count) / 2 - 1)- }-- write.csv(res$anoms)-}, error = function (e) {- write.csv(geterrmessage())-})diff --git a/lib/blazer/result.rb b/lib/blazer/result.rbindex cd090fa3..c97e48c5 100644--- a/lib/blazer/result.rb+++ b/lib/blazer/result.rb@@ -196,40 +196,7 @@ module Blazeranomalies = AnomalyDetection.detect(Hash[series], period: period)anomalies.include?(series.last[0])else- csv_str =- CSV.generate do |csv|- csv << ["timestamp", "count"]- series.each do |row|- csv << row- end- end-- r_script = %x[which Rscript].chomp- type = series.any? && series.last.first.to_time - series.first.first.to_time >= 2.weeks ? "ts" : "vec"- args = [type, csv_str]- raise "R not found" if r_script.empty?- command = "#{r_script} --vanilla #{File.expand_path("../detect_anomalies.R", __FILE__)} #{args.map { |a| Shellwords.escape(a) }.join(" ")}"- output = %x[#{command}]- if output.empty?- raise "Unknown R error"- end-- rows = CSV.parse(output, headers: true)- error = rows.first && rows.first["x"]- raise error if error-- timestamps = []- if type == "ts"- rows.each do |row|- timestamps << Time.parse(row["timestamp"])- end- timestamps.include?(series.last[0].to_time)- else- rows.each do |row|- timestamps << row["index"].to_i- end- timestamps.include?(series.length)- end+ raise "Unknown anomaly detector"endendend