johannfaouzi / pyts

A Python package for time series classification
https://pyts.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.76k stars 163 forks source link

For the images part, it seems to accept same width and height of images (ex: 32*32) and not different width and height (ex: 32*39). Any fix? #67

Open zneha opened 4 years ago

zneha commented 4 years ago

Description

Steps/Code to Reproduce

<< your code here >>

Versions

johannfaouzi commented 4 years ago

Are you talking about the algorithms in the pyts.image module? For all of them it does not make much sense to have different width and height, since the idea overall is to get some information between time points: f(x_i, x_j).

zneha commented 4 years ago

Yes it’s for the algorithms in pyts. I am using this module for a different purpose and was wondering if I could use it to generate different width and height images.

Ex: To get an image from data of length 1225, we can give size of image to be 35*35, but what if we give data of length 1248? I cannot definitely have same width and height in this case.

On Thu, Mar 5, 2020 at 3:14 AM Johann Faouzi notifications@github.com wrote:

Are you talking about the algorithms in the pyts.image https://pyts.readthedocs.io/en/stable/api.html#module-pyts.image module? For all of them it does not make much sense to have different width and height, since the idea overall is to get some information between time points: f(x_i, x_j).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johannfaouzi/pyts/issues/67?email_source=notifications&email_token=AHYJLSKPBCWYULBY5K5K6TDRF5NODA5CNFSM4LB3ZCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN4FHQI#issuecomment-595088321, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYJLSNV56MVJBNMD35O3NTRF5NODANCNFSM4LB3ZCZQ .

--

johannfaouzi commented 4 years ago

If you give a float between 0 and 1, the size of the image will be proportional to the length of your time series.

So if you set image_size=p, the size of the image will be (ceil(p * length), ceil(p * length)).

With p=0.5 for instance, it would give:

zneha commented 4 years ago

How can I directly input the first value as 32 and second value as 39 i.e., (ceil(p length), ceil(p length)) = (32,39)

On Thu, Mar 5, 2020 at 8:12 AM Johann Faouzi notifications@github.com wrote:

If you give a float between 0 and 1, the size of the image will be proportional to the length of your time series.

So if you set image_size=p, the size of the image will be (ceil(p length), ceil(p length)).

With p=0.5 for instance, it would give:

  • ceil(0.5 * 1225) = 613
  • ceil(0.5 * 1248) = 624

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johannfaouzi/pyts/issues/67?email_source=notifications&email_token=AHYJLSL26I6ILQRKTEUTKOTRF6QLLA5CNFSM4LB3ZCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN5FWTQ#issuecomment-595221326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYJLSI6WXDDPE7CIZUXPJ3RF6QLLANCNFSM4LB3ZCZQ .

--

johannfaouzi commented 4 years ago

I don't understand why you want different values as it does not make sense.

If you really want different width and height, just set image_size to the larger value (39), you will get an image with shape (39, 39) and you can crop / downsample this image so that its new shape is (32, 39).

zneha commented 4 years ago

I am using the pyts module not specifically for this project. What I trying to do is take an array, say [ 1 2 3 4 5 6 ] and trying to make it into an image/ matrix, ex: [1 2 3; which is a 2*3 matrix.

      4 5 6]

So basically trying to set my image size to get a gaf/ mtf image/matrix.

I cannot crop the image as, this is leading to data drop.

On Thu, Mar 5, 2020 at 8:38 AM Johann Faouzi notifications@github.com wrote:

I don't understand why you want different values as it does not make sense.

If you really want different width and height, just set image_size to the larger value (39), you will get an image with shape (39, 39) and you can crop / downsample this image so that its new shape is (32, 39).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johannfaouzi/pyts/issues/67?email_source=notifications&email_token=AHYJLSPLHMXO3SEKZA53JITRF6TO5A5CNFSM4LB3ZCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN5I3HI#issuecomment-595234205, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYJLSPMG2EVHZOOFF5YCKDRF6TO5ANCNFSM4LB3ZCZQ .

--

zneha commented 4 years ago

As of now , if my array length is 1225, I am giving my input as size = 35 (expecting GramianAngularField takes my image size as 35*35) gasf = GramianAngularField(image_size = size, methos = 'summation')

Was trying to get around, if my array length is 1248, I want my image size to be 32*39, so what should be my input to GramianAngularField for the size parameter?

On Thu, Mar 5, 2020 at 8:43 AM Neha Reddy Sanagala neha.vdf22@gmail.com wrote:

I am using the pyts module not specifically for this project. What I trying to do is take an array, say [ 1 2 3 4 5 6 ] and trying to make it into an image/ matrix, ex: [1 2 3; which is a 2*3 matrix.

        4 5 6]

So basically trying to set my image size to get a gaf/ mtf image/matrix.

I cannot crop the image as, this is leading to data drop.

On Thu, Mar 5, 2020 at 8:38 AM Johann Faouzi notifications@github.com wrote:

I don't understand why you want different values as it does not make sense.

If you really want different width and height, just set image_size to the larger value (39), you will get an image with shape (39, 39) and you can crop / downsample this image so that its new shape is (32, 39).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johannfaouzi/pyts/issues/67?email_source=notifications&email_token=AHYJLSPLHMXO3SEKZA53JITRF6TO5A5CNFSM4LB3ZCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN5I3HI#issuecomment-595234205, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYJLSPMG2EVHZOOFF5YCKDRF6TO5ANCNFSM4LB3ZCZQ .

--

--

johannfaouzi commented 4 years ago

The thing is that there is no relationship of this kind. If you want to transform your 1D-time series into an 2D-array without performing in any modification of the values, you can use numpy.reshape. But it is totally different from what the algorithms in the pyts.image module do.

zneha commented 4 years ago

Is it not that, this entire module is to convert a time series to a matrix (image esentially)?

johannfaouzi commented 4 years ago

Yes, and the image will always be a square matrix.

zneha commented 4 years ago

Any way that I could get a rectangular image?

On Thu, Mar 5, 2020 at 10:21 AM Johann Faouzi notifications@github.com wrote:

Yes, and the image will always be a square matrix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/johannfaouzi/pyts/issues/67?email_source=notifications&email_token=AHYJLSM5HZVQDSG2WOWNIOLRF67Q7A5CNFSM4LB3ZCZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEN5VOSQ#issuecomment-595285834, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHYJLSNHRN4OD227FDER7WTRF67Q7ANCNFSM4LB3ZCZQ .

--

Neha Reddy Sanagala Graduate student, Department of Electrical Engineering & Computer Science

AHA Precision Medicine Fellow, Machine Learning & Artificial Intelligence Complex Adaptive Systems Lab (University of Cincinnati College of Engineering and Applied Science) Computational Lab, AI Center of Excellence (University of Cincinnati College of Medicine, Cardiovascular Research Center)

johannfaouzi commented 4 years ago

No.