2

I have a time series t composed of 30 features, with a shape of (5400, 30). To plot it and identify the anomalies I had to reshape it in the following way:

t = t[:,0].reshape(-1)

Now, it became a single tensor of shape (5400,) where I had the possibility to perform my analysis and create a list of 5400 elements composed of True and False, based on the position of the anomalies:

anomaly = [True, False, True, ...., False]

Now I would like to reshape this list of a size (30, 5400) (the reverse of the first one). How can I do that?

EDIT: this is an example of what I'm trying to achieve: I have a time series of size (2, 4)

feature 1 | feature 2 | feature 3 | feature 4
  0.3         0.1        0.24          0.25
  0.62        0.45       0.43          0.9

Coded as:

[[0.3, 0.1, 0.24, 0.25]
[0.62, 0.45, 0.43, 0.9]]

When I reshape it I get this univariate time series of size (8,):

[0.3, 0.1, 0.24, 0.25, 0.62, 0.45, 0.43, 0.9]

On this time series I applied an anomaly detection method which gave me a list of True/False for each value:

[True, False, True, False, False, True, True, False]

I wanna make this list of the reverse of the shape of the original one, so it would be structured as:

feature 1 True, False 
feature 2 False, True
feature 3 True, True
feature 4 False, False

with a shape of (4, 2), so coded it should be:

[[True, False]
[False, True]
[True, True]
[False, False]]
13
  • 1
    How do you reshape 5400 to (30, 5400)? And why? Commented Oct 15, 2021 at 18:47
  • is it sufficient to transpose the original collection? Commented Oct 15, 2021 at 18:50
  • @QuangHoang I haven't reshaped it yet. At the moment I have only the list of 5400 True/False for each observation. I need to make that list of shape (30, 5400) Commented Oct 15, 2021 at 18:50
  • your question has ambiguity. you are reassigning t to t[:,0].reshape(-1). give us clear inputs and be clear about what you want. Commented Oct 15, 2021 at 18:54
  • My question is, say what does your output look like? E.g. what's output[0]? Commented Oct 15, 2021 at 18:55

1 Answer 1

1
t = np.array([[0.3, 0.1, 0.24, 0.25],[0.62, 0.45, 0.43, 0.9]])
anomaly= [True, False, True, False, False, True, True, False]
your_req_array = np.array(anomaly).reshape(2,4).T
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.