I am trying to load columns 1 to 15 of the data.txt file into array X and column 16 into array y, and normalize all 15 columns in X in the for loop and array y in a single statement. Loading is working properly, but after trying to print results of normalization I get this error:
TypeError: 'tuple' object cannot be interpreted as an integer
Please help, the code is being done in python in the Jupyter notebook.
import numpy as np
import matplotlib.pyplot as plt
data = np.loadtxt('data.txt')
X = np.array(data[:, 1:16])
y = np.array(data[:, 16], ndmin=2).T
n = X.shape
for i in range(n):
X[:, i] = (X[:, i]-np.min(X[:, i])) / (np.max(X[:, i])-np.min(X[:, i]))
y = ( y-np.min(y) ) / ( np.max(y)-np.min(y) )
print(X)
print(y)
.shapeof a 2-dimensional array has 2 elements. Whatido you expect the loop to iterate over?