Python Forum
Can't properly shape an array
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't properly shape an array
#1
Hello everybody. I'm running a script where I'm trying to predict with sklearn the values of a variable, called involvement (measured as a number from 1 to 6) from a variable called valence (number from -1 to 1). These values came from a questionnaire where some people rated a list of sentences (valence) or answered some personality questions (immersion).
I should obtain an array (51, 125) for my independent variable and an array (51, 1) for my dependent variable, but when I apply the numpy.array method to my list I only get one dimensional array.

To be clear I should get something like this:
train_valence (20, 125) [[1. 2. 4. ... 5. 5. 6.]
 [5. 3. 5. ... 4. 4. 6.]
 [5. 5. 4. ... 5. 6. 7.]
 ...
 [4. 4. 3. ... 4. 4. 4.]
 [6. 6. 7. ... 6. 7. 6.]
 [6. 2. 7. ... 4. 4. 5.]]
but instead I get
train_valence (51,) [list([4.0, 2.0, 3.0, 2.0, 2.0, 4.0, 3.0, 4.0, 4.0, 3.0, 2.0, 4.0, 3.0, 4.0, 3.0, 3.0, 4.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 1.0, 1.0, 4.0, 3.0, 5.0, 4.0, 4.0, 2.0, 3.0, 5.0, 4.0, 4.0, 3.0, 2.0, 4.0, 4.0, 3.0, 3.0, 3.0, 5.0, 3.0, 3.0, 2.0, 3.0, 2.0, 2.0, 3.0, 2.0, 3.0, 4.0, 2.0, 3.0, 3.0, 3.0, 2.0, 3.0, 3.0, 3.0, 4.0, 3.0, 3.0, 2.0, 3.0, 3.0, 4.0, 3.0, 3.0, 3.0, 2.0, 3.0, 4.0, 1.0, 3.0, 3.0, 3.0, 4.0, 4.0, 3.0, 4.0, 4.0, 3.0, 3.0, 2.0, 3.0, 3.0, 4.0, 4.0, 3.0, 4.0, 3.0, 3.0, 4.0, 4.0, 4.0, 3.0, 4.0, 4.0, 3.0, 3.0, 3.0, 4.0, 3.0, 4.0, 3.0, 4.0, 3.0, 3.0, 4.0, 3.0, 4.0, 4.0, 2.0, 4.0, 3.0, 3.0, 4.0, 3.0, 3.0, 4.0, 4.0, 4.0, 4.0])
 list([2.0, 5.0, 2.0, 2.0, 1.0, 4.0, 2.0, 2.0, 4.0, 3.0, 3.0, 4.0, 2.0, 3.0, 4.0, 4.0, 2.0, 4.0, 1.0, 2.0, 2.0, 4.0, 4.0, 4.0, 3.0, 2.0, 3.0, 4.0, 4.0, 4.0, 3.0, 2.0, 5.0, 5.0, 4.0, 1.0, 4.0, 2.0, 3.0, 1.0, 2.0, 2.0, 3.0, 2.0, 2.0, 4.0, 5.0, 2.0, 2.0, 2.0, 2.0, 4.0, 2.0, 2.0, 2.0, 3.0, 2.0, 5.0, 3.0, 4.0, 4.0, 2.0, 3.0, 2.0, 2.0, 2.0, 2.0, 2.0, 4.0, 2.0, 2.0, 2.0, 3.0, 2.0, 4.0, 4.0, 4.0, 3.0, 2.0, 3.0, 3.0, 3.0, 5.0, 3.0, 2.0, 4.0, 1.0, 2.0, 4.0, 2.0, 3.0, 4.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 4.0, 3.0, 4.0, 3.0, 2.0, 2.0, 4.0, 2.0, 2.0, 4.0, 2.0, 3.0, 3.0, 2.0, 4.0, 4.0, 5.0, 3.0, 2.0, 3.0, 4.0, 2.0, 3.0, 4.0, 3.0, 4.0, 3.0]) #(...)
Thanks in advance for your help
Reply


Messages In This Thread
Can't properly shape an array - by maaaa2401 - Dec-16-2020, 11:26 AM
RE: Can't properly shape an array - by jefsummers - Dec-16-2020, 02:40 PM
RE: Can't properly shape an array - by maaaa2401 - Dec-16-2020, 02:54 PM
RE: Can't properly shape an array - by maaaa2401 - Dec-18-2020, 09:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  ValueError: could not broadcast input array from shape makingwithheld 1 2,178 Jul-06-2024, 03:02 PM
Last Post: paul18fr
  output shape problem with np.arange alan6690 5 2,239 Dec-26-2023, 05:44 PM
Last Post: deanhystad
  simplekml change shape&color issac_n 2 4,039 Aug-20-2022, 07:15 PM
Last Post: Joseph_Paintsil
  ValueError: shape mismatched: objects cannot be broadcast to a single shape Laplace12 0 5,150 Jul-14-2020, 11:45 AM
Last Post: Laplace12
  Receiving ValueError("bad input shape {0}".format(shape)) error SuryaCitizen 2 4,221 Jun-01-2020, 06:45 AM
Last Post: pyzyx3qwerty
  Fill a value in triangle shape in Matrix lynx 0 2,438 Dec-07-2019, 06:32 AM
Last Post: lynx
  ValueError: could not broadcast input array from shape (1555200) into shape (0) promach 1 4,468 Jun-18-2018, 08:00 AM
Last Post: promach

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020