All Questions
301
questions
-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 "<...
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 ...
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(...
-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"]=="...
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....
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]],
[[...
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 ...
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 ...
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 ...
-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 ...
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)?
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, ...
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))
...
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)
)
}
...
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,...