Skip to content

Commit 34ff75b

Browse files
authored
Merge pull request #20 from ATISLabs/feature/generate_swiss_roll
Feature/generate_swiss_roll
2 parents 22badcb + d4847fb commit 34ff75b

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/sklearn.jl

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,26 @@ function generate_classification(; n_samples::Int = 100,
238238
random_state = random_state)
239239

240240
return convert(features, labels)
241-
end
241+
end
242+
243+
"""
244+
function generate_swiss_roll(; n_samples::Int = 100,
245+
noise::Float64 = 0.0,
246+
random_state::Union{Int,Nothing} = nothing)
247+
Generate a swiss roll dataset.
248+
#Arguments
249+
- `n_samples::Int = 100`: The number of samples.
250+
- `noise::Float64 = 0.0 : Standard deviation of Gaussian noise added to the data.
251+
- `random_state::Union{Int, Nothing} = nothing`: Determines random number generation for dataset creation. Pass an int for reproducible output across multiple function calls. See Glossary.
252+
Reference: [link](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_swiss_roll.htmll)
253+
"""
254+
function generate_swiss_roll(; n_samples::Int = 100,
255+
noise::Float64 = 0.0,
256+
random_state::Union{Int,Nothing} = nothing)
257+
258+
(features, labels) = datasets.make_swiss_roll( n_samples = n_samples,
259+
noise = noise,
260+
random_state = random_state)
261+
262+
return convert(features, labels)
263+
end

test/runtests.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ using Test
4444
n_features = features,
4545
n_classes = 1)
4646

47-
4847
@test size(data)[1] == samples
4948
@test size(data)[2] == features + 1
5049

51-
end
50+
data = SyntheticDatasets.generate_swiss_roll(n_samples =samples,
51+
noise = 2.2,
52+
random_state = 5)
53+
54+
@test size(data)[1] == samples
55+
@test size(data)[2] == 4
56+
end

0 commit comments

Comments
 (0)