UnivariateTimeTypeToContinuous returns negative / wrong values for Time data when min_dt + step wraps past midnight
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- data
Hướng nghiên cứu
Bắt đầu với src/transformers/other_transformers/univariate_time_type_to_continuous.jl, nơi issue chỉ ra phép tính độ dài bước và nhánh xử lý thời điểm qua nửa đêm. Tái hiện lỗi với Time(13), Time(14) và Time(19) bằng bước mặc định, Hour(13) và Hour(36), sau đó kiểm tra các bài kiểm thử hiện có cho transformer này. Công việc hoàn tất khi mỗi phép biến đổi trả về các giá trị không âm như mong đợi, được tính theo bước tương ứng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
UnivariateTimeTypeToContinuous gives wrong results, including negative values, for Dates.Time input whenever min_dt + step wraps past midnight. With the default step = Hour(24), that happens as soon as the earliest time in the training data is at or after 12:00.
Minimal example
using MLJBase, MLJTransforms, Dates
fitt(model, X) = (m = machine(model, X); fit!(m, verbosity=0); m)
X1 = [Time(9), Time(10), Time(15)]
X2 = [Time(13), Time(14), Time(19)]
transform(fitt(UnivariateTimeTypeToContinuous(), X1), X1)
# [0.0, 0.041666666666666664, 0.25] (correct: 1/24, 6/24)
transform(fitt(UnivariateTimeTypeToContinuous(), X2), X2)
# [-0.0, -0.041666666666666664, -0.25] (expected [0.0, 1/24, 6/24])
transform(fitt(UnivariateTimeTypeToContinuous(step=Hour(13)), X2), X2)
# [-0.0, -0.0909..., -0.5454...] (expected [0.0, 1/13, 6/13] ≈ [0.0, 0.0769, 0.4615])
transform(fitt(UnivariateTimeTypeToContinuous(step=Hour(36)), X2), X2)
# [-0.0, -0.0833..., -0.5] (expected [0.0, 1/36, 6/36])
transform(fitt(UnivariateTimeTypeToContinuous(step=Hour(1)), X2), X2)
# [0.0, 1.0, 6.0] (correct, because there's no wrap-around)
I ran this on MLJTransforms 0.2.3 with MLJBase 1.15.0 and Julia 1.13.3. The output above is copied from that session.
Cause
In src/transformers/other_transformers/univariate_time_type_to_continuous.jl, transform gets the step size from Dates.value(min_dt + step) - Dates.value(min_dt). In the next_time == min_dt branch it uses min_dt + Hour(12) instead. Time arithmetic wraps modulo 24 h, so:
- with the default
Hour(24)andmin_dt ≥ 12:00,min_dt + Hour(12)wraps,deltacomes out negative, and every output changes sign; - for any other step where
min_dt + stepcrosses midnight (e.g.Hour(13)from 13:00, or any step longer than 24 h that isn't a multiple of 24 h),deltahas the wrong magnitude and usually the wrong sign.
The same code is on dev (184aae1).
Expected
The output should be (X - min_dt) / step no matter what time of day min_dt is, i.e. [0, 1/24, 6/24] for X2 with the default step.
Possible fix (not tested)
For Time data the step length doesn't depend on min_dt, so the wrap-around branch can be skipped by computing the step length directly, e.g.
if min_dt isa Dates.Time
delta = Float64(Dates.value(convert(Nanosecond, step)))
else
delta = Float64(Dates.value(min_dt + step) - Dates.value(min_dt))
end
A regression test could fit on [Time(13), Time(14), Time(19)] with the default step, Hour(13) and Hour(36), and check the outputs are [0, 1, 6] ./ 24, ./ 13 and ./ 36.
- Ngôn ngữ chính
- Julia
- Star
- 1
- Fork
- 5
- Merge trung bình
- 1 ngày 45 phút
- Pull request đã merge (30 ngày)
- 8
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của JuliaAI/MLJTransforms.jl
-
Add a `Transformer` wrapper for models that supervised that transformCó thể làm lại được @ablaom đã nhận 233 ngày trước và không có pull request nào đang mở. Đang mởenhancement
JuliaAI/MLJTransforms.jl#52 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaAI/MLJTransforms.jl#39 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Checklist for first releaseĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
JuliaAI/MLJTransforms.jl#21 · 13 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`asinh` transformationĐang mởenhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
JuliaAI/MLJTransforms.jl#46 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
JuliaAI/MLJTransforms.jl#44 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của JuliaAI/MLJTransforms.jl
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Sienna-Platform/PowerSimulations.jl#1737 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
FluxML/Optimisers.jl#254 ·
-
Minor: floodplain warning percentage, scalar output error message and a never-true identity checkĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
@contents blocks fail to render on Julia 1.14Có thể đã có người làm @sbfnk đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LuxDL/DocumenterVitepress.jl#410 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày