Beispiel #1
0
def home():
    message = None
    if request.method == 'POST':
        matrixfromjs = request.form['mydata']
        checker = request.form['counter']
        print(checker)
        np.set_printoptions(precision=1)
        matrix = np.asmatrix(genfromtxt('car_real.csv', delimiter=','))
        matrix = matrix.T

        if checker == '0':
            result = matrix.tolist()
            result = json.dumps(result)
        elif checker == '1':
            output = []
            f = open('car.csv', 'rU')  #open the file in read universal mode
            for line in f:
                cells = line.split(",")
                output.append(
                    (cells[0]
                     ))  #since we want the first, second and third column
            f.close()
            result = json.dumps(output)
        # print(result)
        resp = make_response(result)
        resp.headers['Content-Type'] = "application/json"
        return resp
    return render_template('home.html', message='')
Beispiel #2
0
def login():
    message = None
    if request.method == 'POST':
        matrixfromjs = request.form['mydata']
        checker=request.form['counter']
        print(checker)
        np.set_printoptions(precision=1)
        matrix = np.asmatrix(genfromtxt('car.csv', delimiter=','))
        matrix = matrix.T
			 
        mean_attribute=[]
        mean_vector=[]
        for i in range(0,len(matrix)):
            mean_attribute.append(np.mean(matrix[i,:]))
            mean_vector.append([mean_attribute[i]]);
       
        scatter_matrix = np.zeros((len(matrix),len(matrix)))
        for i in range(matrix.shape[1]):
            scatter_matrix += (matrix[:,i].reshape(len(matrix),1) - mean_vector).dot(
                (matrix[:,i].reshape(len(matrix),1) - mean_vector).T)
				
        eig_val_sc, eig_vec_sc = np.linalg.eig(scatter_matrix)

        for i in range(len(eig_val_sc)):
            eigvec_sc = eig_vec_sc[:,i].reshape(1,len(matrix)).T
			
        eig_pairs = [(np.abs(eig_val_sc[i]), eig_vec_sc[:,i])
                for i in range(len(eig_val_sc))]
				
        if checker=='0':
            result= matrix.tolist()
            result=json.dumps(result) 	
        elif checker=='1':
            eig_pairs.sort()
            eig_pairs.reverse()
            matrix_w = np.hstack((eig_pairs[0][1].reshape(len(matrix),1),
                        eig_pairs[1][1].reshape(len(matrix),1)))
            transformed_matrix = matrix_w.T.dot(matrix)
            result= transformed_matrix.T
            result= result.tolist()
            result=json.dumps(result) 
            print(result)
        resp = make_response(result)
        resp.headers['Content-Type'] = "application/json"
        return resp
    return render_template('login.html', message='')
Beispiel #3
0
def matrixToString(matrix):
    ml = matrix.tolist()
    ans = ';'.join(','.join(str(y) for y in x) for x in ml)
    return ans
Beispiel #4
0
def sendMatrix4(shaderProgram, varName, matrix):
    # determine location of uniform variable varName
    varLocation = glGetUniformLocation(shaderProgram, varName)
    # pass value to shader
    #glUniformMatrix4fv(varLocation, 1, GL_TRUE, matrix.tostring())
    glUniformMatrix4fv(varLocation, 1, GL_TRUE, matrix.tolist())
def sendMat4(shaderProgram, varName, matrix):
        varLocation = glGetUniformLocation(shaderProgram, varName)
        glUniformMatrix4fv(varLocation, 1, GL_TRUE, matrix.tolist())
Beispiel #6
0
def sendMat4(shaderProgram, varName, matrix):
    varLocation = glGetUniformLocation(shaderProgram, varName)
    glUniformMatrix4fv(varLocation, 1, GL_TRUE, matrix.tolist())