Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ local_test/
paper_tests/m4_test/metrics_results/
paper_tests/m4_test/results_ARIMA/
paper_tests/m4_test/results_SSL/
paper_tests/m4_test/init_SSL/

paper_tests/simulation_test/results_simulation_raw/
paper_tests/mv_probabilistic_forecast/

docs/build
docs/build
longhorizon/
test.jl
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StateSpaceLearning"
uuid = "971c4b7c-2c4e-4bac-8525-e842df3cde7b"
authors = ["andreramosfc <[email protected]>"]
version = "1.0.2"
version = "1.1.0"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ using Plots
airp = CSV.File(StateSpaceLearning.AIR_PASSENGERS) |> DataFrame
log_air_passengers = log.(airp.passengers)

airpassengers = Float64.(airp.passengers)
airpassengers = AbstractFloat.(airp.passengers)
log_air_passengers[60:72] .= NaN

model = StructuralModel(log_air_passengers)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ using Plots
airp = CSV.File(StateSpaceLearning.AIR_PASSENGERS) |> DataFrame
log_air_passengers = log.(airp.passengers)

airpassengers = Float64.(airp.passengers)
airpassengers = AbstractFloat.(airp.passengers)
log_air_passengers[60:72] .= NaN

model = StructuralModel(log_air_passengers)
Expand Down
6 changes: 3 additions & 3 deletions paper_tests/m4_test/evaluate_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ function evaluate_SSL(
results_df::DataFrame,
input::Dict,
outlier::Bool,
α::Float64,
H::Int64,
sample_size::Int64,
α::AbstractFloat,
H::Int,
sample_size::Int,
information_criteria::String,
)
normalized_y = input["normalized_train"]
Expand Down
12 changes: 6 additions & 6 deletions paper_tests/m4_test/m4_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ function run_config(
results_table::DataFrame,
outlier::Bool,
information_criteria::String,
α::Float64,
α::AbstractFloat,
save_init::Bool,
sample_size::Int64,
sample_size::Int,
)
NAIVE_sMAPE = 14.427 #M4 Paper
NAIVE_MASE = 1.063 #M4 Paper
Expand Down Expand Up @@ -98,9 +98,9 @@ end
# Main script
function main()
results_table = DataFrame()
for outlier in [true, false]
for information_criteria in ["aic", "bic"]
for α in vcat([0.0], collect(0.1:0.2:0.9), [1.0])
for outlier in [true]
for information_criteria in ["aic"]
for α in [0.1]
@info "Running SSL with outlier = $outlier, information_criteria = $information_criteria, α = $α"
results_table = run_config(
results_table, outlier, information_criteria, α, false, 60
Expand Down Expand Up @@ -140,4 +140,4 @@ create_dirs()

main()

run_config(DataFrame(), false, "aic", 0.1, true, 2794)#max sample size
#run_config(DataFrame(), false, "aic", 0.1, true, 2794)#max sample size
2 changes: 1 addition & 1 deletion paper_tests/m4_test/metrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function sMAPE(y_test::Vector, prediction::Vector)
return (200 / H) * sum(abs(y_test[i] - prediction[i]) / (denominator[i]) for i in 1:H)
end

function MASE(y_train::Vector, y_test::Vector, prediction::Vector; m::Int64=12)
function MASE(y_train::Vector, y_test::Vector, prediction::Vector; m::Int=12)
T = length(y_train)
H = length(y_test)

Expand Down
4 changes: 2 additions & 2 deletions paper_tests/m4_test/prepare_data.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function normalize(y::Vector, max_y::Float64, min_y::Float64)
function normalize(y::Vector, max_y::AbstractFloat, min_y::AbstractFloat)
return (y .- min_y) ./ (max_y - min_y)
end

function de_normalize(y::Vector, max_y::Float64, min_y::Float64)
function de_normalize(y::Vector, max_y::AbstractFloat, min_y::AbstractFloat)
return (y .* (max_y - min_y)) .+ min_y
end

Expand Down
40 changes: 21 additions & 19 deletions paper_tests/simulation_test/evaluate_models.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ function get_confusion_matrix(selected, true_features, false_features)
end

function get_SSL_results(
y_train::Vector{Float64},
true_features::Vector{Int64},
false_features::Vector{Int64},
X_train::Matrix{Float64},
y_train::Vector{Fl},
true_features::Vector{Int},
false_features::Vector{Int},
X_train::Matrix{Fl},
inf_criteria::String,
true_β::Vector{Float64},
)
true_β::Vector{Fl},
) where {Fl<:AbstractFloat}
series_result = nothing

model = StateSpaceLearning.StructuralModel(
Expand Down Expand Up @@ -72,13 +72,13 @@ function get_SSL_results(
end

function get_SS_res_results(
y_train::Vector{Float64},
true_features::Vector{Int64},
false_features::Vector{Int64},
X_train::Matrix{Float64},
y_train::Vector{Fl},
true_features::Vector{Int},
false_features::Vector{Int},
X_train::Matrix{Fl},
inf_criteria::String,
true_β::Vector{Float64},
)
true_β::Vector{Fl},
) where {Fl<:AbstractFloat}
py"""
import math
import statsmodels.api as sm
Expand Down Expand Up @@ -141,7 +141,9 @@ function get_SS_res_results(
return series_result, converged
end

function get_exogenous_ss_inf_criteria(y_train::Vector{Float64}, X_train::Matrix{Float64})
function get_exogenous_ss_inf_criteria(
y_train::Vector{Fl}, X_train::Matrix{Fl}
) where {Fl<:AbstractFloat}
py"""
import math
import statsmodels.api as sm
Expand All @@ -160,13 +162,13 @@ function get_exogenous_ss_inf_criteria(y_train::Vector{Float64}, X_train::Matrix
end

function get_forward_ss(
y_train::Vector{Float64},
true_features::Vector{Int64},
false_features::Vector{Int64},
X_train::Matrix{Float64},
y_train::Vector{Fl},
true_features::Vector{Int},
false_features::Vector{Int},
X_train::Matrix{Fl},
inf_criteria::String,
true_β::Vector{Float64},
)
true_β::Vector{Fl},
) where {Fl<:AbstractFloat}
best_inf_crit = Inf
current_inf_crit = 0
coefs = nothing
Expand Down
2 changes: 1 addition & 1 deletion paper_tests/simulation_test/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ CSV.write("paper_tests/simulation_test/results_metrics/metrics_confusion_matrix.

df_mse_bias = DataFrame()

function convert_to_sci_notation(num::Float64)
function convert_to_sci_notation(num::AbstractFloat)
# Get the exponent part of the number in scientific notation
exp_part = floor(log10(abs(num)))

Expand Down
4 changes: 2 additions & 2 deletions paper_tests/simulation_test/simulation_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function assert_invertibility(q::Vector{Fl}) where {Fl}
return all(abs.(roots_of_inverse_polinomial(poly)) .< 1)
end

function generate_sarima_exog(T::Int64, M::Int64)
function generate_sarima_exog(T::Int, M::Int)
X = zeros(T, M)
s = 12
for j in 1:M
Expand Down Expand Up @@ -87,7 +87,7 @@ function generate_sarima_exog(T::Int64, M::Int64)
return X
end

function generate_subset(T::Int64, M::Int64, K::Int64)
function generate_subset(T::Int, M::Int, K::Int)
s = 12

μ1 = 1.0
Expand Down
Loading
Loading