@@ -19,20 +19,10 @@ $TYPEDFIELDS
1919 instance:: I = nothing
2020end
2121
22- function _transform (t, sample:: DataSample ; kwargs... )
23- (; instance, x, θ_true, y_true) = sample
24- return DataSample (; instance, x= StatsBase. transform (t, x; kwargs... ), θ_true, y_true)
25- end
26-
27- function _reconstruct (t, sample:: DataSample ; kwargs... )
28- (; instance, x, θ_true, y_true) = sample
29- return DataSample (; instance, x= StatsBase. reconstruct (t, x; kwargs... ), θ_true, y_true)
30- end
31-
3222"""
3323$TYPEDSIGNATURES
3424
35- Compute the mean and standard deviation of the features in the dataset.
25+ Fit the given transform type (`ZScoreTransform` or `UnitRangeTransform`) on the dataset.
3626"""
3727function StatsBase. fit (transform_type, dataset:: AbstractVector{<:DataSample} ; kwargs... )
3828 x = hcat ([d. x for d in dataset]. .. )
@@ -51,11 +41,36 @@ function StatsBase.transform(t, dataset::AbstractVector{<:DataSample})
5141 end
5242end
5343
54- # TODO : reconstruct, transform!, reconstruct!
44+ """
45+ $TYPEDSIGNATURES
5546
47+ Transform the features in the dataset in place.
48+ """
49+ function StatsBase. transform! (t, dataset:: AbstractVector{<:DataSample} )
50+ for d in dataset
51+ StatsBase. transform! (t, d. x)
52+ end
53+ end
54+
55+ """
56+ $TYPEDSIGNATURES
57+
58+ Reconstruct the features in the dataset.
59+ """
5660function StatsBase. reconstruct (t, dataset:: AbstractVector{<:DataSample} )
5761 return map (dataset) do d
5862 (; instance, x, θ_true, y_true) = d
5963 DataSample (; instance, x= StatsBase. reconstruct (t, x), θ_true, y_true)
6064 end
6165end
66+
67+ """
68+ $TYPEDSIGNATURES
69+
70+ Reconstruct the features in the dataset in place.
71+ """
72+ function StatsBase. reconstruct! (t, dataset:: AbstractVector{<:DataSample} )
73+ for d in dataset
74+ StatsBase. reconstruct! (t, d. x)
75+ end
76+ end
0 commit comments