Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- from numpy import genfromtxt
- from copy import copy
- X = genfromtxt('data1', delimiter=',')
- Y = genfromtxt('Y', delimiter=',')
- Y = np.float32(Y)
- print X[0, :]
- sample_n, var_n = X.shape
- var_types = np.array([cv2.CV_VAR_NUMERICAL] * var_n + [cv2.CV_VAR_ORDERED], np.float32)
- model = cv2.RTrees()
- params = dict(max_depth=10, max_num_of_trees_in_the_forest=10, cv_folds=5, regression_accuracy=0.0001)
- features = ['PEF', 'FEV1', 'FVC', 'TIFF']
- a = model
- save_f = np.zeros((np.shape(X)[0], np.shape(X)[1]/len(features)))
- save_all = {}
- for r in xrange(0, len(features)):
- for j in xrange(0, np.shape(X)[0]):
- u = 0
- for i in range(r, np.shape(X)[1], len(features)):
- save_f[j, u] = X[j, i]
- u += 1
- save_all[features[r]] = copy(np.float32(save_f))
- print 'save_all'
- for r in xrange(0, len(features)):
- print save_all[features[r]][0, :]
- print X.dtype
- print Y.dtype
- #print Y
- print save_all['PEF'].dtype
- for i in range(0, len(features)):
- print 'Starting: ' + features[i]
- #print (X[train,:][:, [0,4,8,12,16,20]])
- print 'one cycle'
- print save_all[features[i]]
- print (Y[:][:, 0])
- print save_all[features[i]].shape
- print (Y[:][:, 0]).shape
- a.train(save_all[features[i]], cv2.CV_ROW_SAMPLE, Y[:][:, i], params=params, varType=var_types)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement