@@ -104,23 +104,28 @@ corresponding `fractions` of `length(nrows(X))`, where valid fractions
104
104
are floats between 0 and 1 whose sum is less than one. The last
105
105
fraction is not provided, as it is inferred from the preceding ones.
106
106
107
- For " synchronized" partitioning of multiple objects, use the
108
- `multi=true` option described below .
107
+ For synchronized partitioning of multiple objects, use the
108
+ `multi=true` option.
109
109
110
- julia> partition(1:1000, 0.8)
111
- ([1,...,800], [801,...,1000])
110
+ ```julia-repl
111
+ julia> partition(1:1000, 0.8)
112
+ ([1,...,800], [801,...,1000])
112
113
113
- julia> partition(1:1000, 0.2, 0.7)
114
- ([1,...,200], [201,...,900], [901,...,1000])
114
+ julia> partition(1:1000, 0.2, 0.7)
115
+ ([1,...,200], [201,...,900], [901,...,1000])
115
116
116
- julia> partition(reshape(1:10, 5, 2), 0.2, 0.4)
117
- ([1 6], [2 7; 3 8], [4 9; 5 10])
117
+ julia> partition(reshape(1:10, 5, 2), 0.2, 0.4)
118
+ ([1 6], [2 7; 3 8], [4 9; 5 10])
118
119
119
- X, y = make_blobs() # a table and vector
120
- Xtrain, Xtest = partition(X, 0.8, stratify=y)
120
+ julia> X, y = make_blobs() # a table and vector
121
+ julia> Xtrain, Xtest = partition(X, 0.8, stratify=y)
122
+ ```
121
123
122
- (Xtrain, Xtest), (ytrain, ytest) = partition((X, y), 0.8, rng=123, multi=true)
124
+ Here's an example of synchronized partitioning of multiple objects:
123
125
126
+ ```julia-repl
127
+ julia> (Xtrain, Xtest), (ytrain, ytest) = partition((X, y), 0.8, rng=123, multi=true)
128
+ ```
124
129
125
130
## Keywords
126
131
@@ -209,7 +214,7 @@ Returns a tuple of tables/vectors with length one greater than the
209
214
number of supplied predicates, with the last component including all
210
215
previously unselected columns.
211
216
212
- ```
217
+ ```julia-repl
213
218
julia> table = DataFrame(x=[1,2], y=['a', 'b'], z=[10.0, 20.0], w=["A", "B"])
214
219
2×4 DataFrame
215
220
Row │ x y z w
@@ -218,7 +223,7 @@ julia> table = DataFrame(x=[1,2], y=['a', 'b'], z=[10.0, 20.0], w=["A", "B"])
218
223
1 │ 1 a 10.0 A
219
224
2 │ 2 b 20.0 B
220
225
221
- Z, XY, W = unpack(table, ==(:z), !=(:w))
226
+ julia> Z, XY, W = unpack(table, ==(:z), !=(:w));
222
227
julia> Z
223
228
2-element Vector{Float64}:
224
229
10.0
@@ -300,9 +305,11 @@ The method is curried, so that `restrict(folds, i)` is the operator
300
305
on data defined by `restrict(folds, i)(X) = restrict(X, folds, i)`.
301
306
302
307
### Example
303
-
304
- folds = ([1, 2], [3, 4, 5], [6,])
305
- restrict([:x1, :x2, :x3, :x4, :x5, :x6], folds, 2) # [:x3, :x4, :x5]
308
+ #
309
+ ```julia
310
+ folds = ([1, 2], [3, 4, 5], [6,])
311
+ restrict([:x1, :x2, :x3, :x4, :x5, :x6], folds, 2) # [:x3, :x4, :x5]
312
+ ```
306
313
307
314
See also [`corestrict`](@ref)
308
315
@@ -322,7 +329,9 @@ all elements of `folds`. Here `folds` is a vector or tuple of integer
322
329
vectors, typically representing row indices or a vector, matrix or
323
330
table.
324
331
325
- complement(([1,2], [3,], [4, 5]), 2) # [1 ,2, 4, 5]
332
+ ```julia
333
+ complement(([1,2], [3,], [4, 5]), 2) # [1 ,2, 4, 5]
334
+ ```
326
335
327
336
"""
328
337
complement (f, i) = reduce (vcat, collect (f)[Not (i)])
@@ -345,8 +354,10 @@ on data defined by `corestrict(folds, i)(X) = corestrict(X, folds, i)`.
345
354
346
355
### Example
347
356
348
- folds = ([1, 2], [3, 4, 5], [6,])
349
- corestrict([:x1, :x2, :x3, :x4, :x5, :x6], folds, 2) # [:x1, :x2, :x6]
357
+ ```julia
358
+ folds = ([1, 2], [3, 4, 5], [6,])
359
+ corestrict([:x1, :x2, :x3, :x4, :x5, :x6], folds, 2) # [:x1, :x2, :x6]
360
+ ```
350
361
351
362
"""
352
363
corestrict (f:: NTuple{N} , i) where N = FoldComplementRestrictor {i,N} (f)
0 commit comments