简体   繁体   中英

How do I change the dimension of an array

I am trying to use sklearn Linear Regression, however whenever I run my code it comes up with an error: Expected 2D array, got 1D array instead: array=[1.16 2.51 1.15 1.52 1.11 1.84 1.07 3. 2. 1.71 0.48 1.85 1.32 1.17 1.48 2.59].

Anyone know How I can fix this?

You have only one element in the array because you didn't but "," between your numbers. Try it like this: array=[1.16, 2.51, 1.15, 1.52, 1.11, 1.84, 1.07, 3, 2, 1.71, 0.48, 1.85, 1.32, 1.17, 1.48, 2.59] . If this isn't what you wanted, describe your problem a bit more.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM