Home > Software design >  How do i make my data 1-dimensional? - neural network
How do i make my data 1-dimensional? - neural network

Time:02-24

When I output this below code through some other functions (sigmoid/weight functions etc). I get the output that my data 'must be one dimensional'.

The data is from a csv that is 329 X 31, I have split this as I need the first column as my 'y' value, and then the remaining 30 columns and all its rows will be my 'x'. How do I go about making this 1 dimensional for my functions?

Is this section of code where I process my data even the issue? could it be an issue from a later functional call? im new to python so im not sure what the issue could be caused by, I was wondering if I converted my data into an array correctly.

df = pd.read_csv('data.csv', header=None)

#splitting dataframe into 70/30 split
trainingdata = df.sample(frac=0.7)
testingdata = df.drop(trainingdata.index)

#splitting very first column to 'y' value
y =  trainingdata.loc[:,0]

#splitting rest of columns to 'X' value
X = trainingdata.loc[:,1:]

#printing shape for testing
print(X.shape, y.shape)

CodePudding user response:

if I understand your question correctly, you can flatten the array using the flatten(), or you can use reshape() for more information, read the documentation

y=y.flatten()
print(y.ndim)

doc

  • Related