Train Test Split

Viewed 86

I'm doing a Gaussian Process Simulation. I have x and y. I want to divide 85% of them in training and 15% in testing and then model fitting them to predict. How should I write the code? I know in Python the function I use is train_test_split().

    x=rand(100)
    dis = [abs(i-j) for i in x, j in x]

    exp(-dis)
    σ2= 1
    g = 1
    l = Matrix(I,100,100)
    μ = zeros(100)
    Σ = (σ2*exp(-dis/g))+0.1l
    y = MvNormal(μ,Σ)
    Y = rand(y,100)
3 Answers

Or, still use partition from BetaML:

using BetaML
((xtrain,xtest),(ytrain,ytest)) = partition([x,y],[0.85,0.15])

This generalise to n arrays (e.g. train/val/test) and you can also choose the dimension to where to partition and if randomise or not the partition.

Related