numpy - I get neither output, nor an error using np.linalg.pinv -
i have tried , worked fine:
phi = np.zeros((len(traindata),3)) phi[:,0] = 1 phi[:,1] = traindata[:,0] phi[:,2] = traindata[:,1] wml = np.dot(np.dot((np.linalg.pinv(np.dot((phi.t),phi))),(phi.t)), y_train) print wml, "weight selection" [[ -1.08778441e+01] [ -3.61672723e-02] [ -4.38518378e-03]] weight selection
but when try same more columns following:
phi = np.zeros((len(traindata),5)) phi[:,0] = 1 phi[:,1] = traindata[:,0] phi[:,2] = traindata[:,1] phi[:,3] = traindata[:,2] phi[:,4] = traindata[:,3] wml = np.dot(np.dot((np.linalg.pinv(np.dot((phi.t),phi))),(phi.t)), y_train) print wml, "weight selection"
i did not obtain result or error. missing or doing wrong? have tried different datasets , different sizes , seems works fine until 3 columns 4 columns nothing shows up.
thank in advance!
Comments
Post a Comment