@@ -18,3 +18,44 @@ $TYPEDFIELDS
1818 " instance object (optional)"
1919 instance:: I = nothing
2020end
21+
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+
32+ """
33+ $TYPEDSIGNATURES
34+
35+ Compute the mean and standard deviation of the features in the dataset.
36+ """
37+ function StatsBase. fit (transform_type, dataset:: AbstractVector{<:DataSample} ; kwargs... )
38+ x = hcat ([d. x for d in dataset]. .. )
39+ return StatsBase. fit (transform_type, x; kwargs... )
40+ end
41+
42+ """
43+ $TYPEDSIGNATURES
44+
45+ Transform the features in the dataset.
46+ """
47+ function StatsBase. transform (t, dataset:: AbstractVector{<:DataSample} )
48+ return map (dataset) do d
49+ (; instance, x, θ_true, y_true) = d
50+ DataSample (; instance, x= StatsBase. transform (t, x), θ_true, y_true)
51+ end
52+ end
53+
54+ # TODO : reconstruct, transform!, reconstruct!
55+
56+ function StatsBase. reconstruct (t, dataset:: AbstractVector{<:DataSample} )
57+ return map (dataset) do d
58+ (; instance, x, θ_true, y_true) = d
59+ DataSample (; instance, x= StatsBase. reconstruct (t, x), θ_true, y_true)
60+ end
61+ end
0 commit comments