I would like to obtain a matrix from some vector x=(x_1,x_2, ..., x_I)
where each row i in this matrix corresponds to x(i) := (x_1,...,x_{i-1},x_{i+1},...,x_I)
.
I know that
from sklearn.cross_validation import LeaveOneOut
I = 30
myrowiterator = LeaveOneOut(I)
for eachrow, _ in myrowiterator:
print(eachrow) # prints [1,2,...,29]
# [0,2,...,29] and so on ...
provides a routine to obtain each row for the above matrix. But I would rather like to obtain the matrix directly in one step to operate directly on this matrix instead of looping through its rows. That would save me some computation time.