Skip to main content

All Questions

Tagged with
-3 votes
0 answers
39 views

cannot reshape array of size 1000 into shape (100,100) [closed]

>>> cent_rand = np.random.randint(1919, 3946, 1000) >>> len(cent_rand) 1000 >>> two_d_cent = cent_rand.reshape((100,100)) Traceback (most recent call last): File "<...
rosa elena's user avatar
0 votes
1 answer
90 views

How to reshape (n,) array to (n,3) array? [closed]

I have an array with (n,) dimension and for a project I need to have this array with (n,3) shape. This array is a set of a 3-dimensional points. This is the code : vertices = np.array([line[7:] for ...
Margot Berranger's user avatar
1 vote
1 answer
67 views

Compute row sums and column sums efficiently in Julia

Consider the code below test_vector = 1:100 group_size = 10 num_groups = div(length(test_vector), group_size) res_1 = sum(reshape(test_vector, group_size, num_groups), dims=1) res_2 = sum(reshape(...
user1691278's user avatar
  • 1,845
-1 votes
1 answer
152 views

ValueError: Expected 2D array

I try to make a SVC. from sklearn.svm import SVC import numpy as np import pandas as pd import matplotlib.pyplot as plt df = pd.read_csv("iris.csv") df.loc[df["species"]=="...
Joo's user avatar
  • 37
0 votes
1 answer
68 views

reshape problem in LogisticRegression code

I try to make a LogisticRegression. import pandas import matplotlib.pyplot as plt from sklearn.linear_model import LogisticRegression import numpy as np df = pd.read_csv("tested.csv") df....
Joo's user avatar
  • 37
1 vote
1 answer
72 views

Why does .reshape(a, b) != .reshape(b, a).T?

I ran into this problem whilst flattening images. Consider the following array >>> import numpy as np >>> arr = np.array([[[1, 2], [3, 4]], [[...
Magnus Sesodia's user avatar
0 votes
0 answers
26 views

Classification report while scoring on a multi-class production dataset

I built a multiclass model with top 5 classes using FRCB Consumer complaints dataset. Following is the distribution of train and test samples. Volume Distr of Train and Test samples After hyper ...
Rohit Jain's user avatar
1 vote
1 answer
41 views

reshape 2d numpy array with most frequent elements

I would like to reshape 2d numpy arrays to smaller shapes and populate it with the most frequent elements within a specified block. For example to go from a shape (4,4) to (2,2) I can use reshape and ...
D.Vrebos's user avatar
0 votes
0 answers
45 views

Reshaping a 5D array to a 2D - different results in Python and Matlab

I have a 5D array of shape (5, 2, 40, 100, 32), which is a dataset. 5 and 40 refer to the number of classes and samples per each class, respectively. The correct conversion will mean that we will have ...
Danny's user avatar
  • 379
-4 votes
1 answer
429 views

How can I reshape my numpy array from (512) to (512,) in Python 3.x?

I am a new one in python. For maniputing the numpy array, I tried to reshape an array size several times like my expectation. But didn't cover it up. Currently my array shape is 512 But I want to ...
Rajib- Research Lab's user avatar
0 votes
1 answer
29 views

How to find the mean and reshape an array in python

I have an array of the shape (901, 201, 3, 20). Please, how can I find the mean of the third matrix to give me (901, 201, 20) or (901, 201, 1, 20)?
TThoye's user avatar
  • 15
2 votes
1 answer
42 views

How do i sample 6000 elements out of my 4-d array in numpy

So I'm working with an array named train_images of shape (25036, 12, 15, 15) , I need to select 6000 random samples from this array, I've tried using np.random.choice() It returned the error above, ...
Kalu Samuel's user avatar
0 votes
1 answer
21 views

How to understand B=np.reshape(A, (a, a, b)) and reverse back by B[:,:,1]

I am quite confused about the following import numpy as np A = np.array([[1,2,3], [2,3,4], [3,4,5]]) A is a 3x3 matrix obviously. Now consider B = np.reshape(A, (3, 3, 1)) ...
Denny's user avatar
  • 225
1 vote
2 answers
105 views

How to transform this list of lists into an array?

How can I transform the following list of lists n = 10 m = 10 p = 5 l = list() for(i in 1:m) { l[[i]] = list( X = matrix(rnorm(n * p), nrow = n), Y = matrix(rnorm(n * p), nrow = n) ) } ...
Mr Frog's user avatar
  • 446
0 votes
1 answer
34 views

Can not reshape 2 dimensional array to 3 dimensional array for RNN in python

I can not reshape the array into 3-dimensional one. Here is the example dataset: import pandas as pd import numpy as np df = { "a": [0.06 , 0.07, 0.45, 0.98, 0.97 ], "b": [12,45,...
Shu's user avatar
  • 67

15 30 50 per page
1
2 3 4 5
21