matrix

How to normalize a confusion matrix?

拜拜、爱过 提交于 2021-02-04 09:45:49
问题 I calculated a confusion matrix for my classifier using the method confusion_matrix() from the sklearn package. The diagonal elements of the confusion matrix represent the number of points for which the predicted label is equal to the true label, while off-diagonal elements are those that are mislabeled by the classifier. I would like to normalize my confusion matrix so that it contains only numbers between 0 and 1. I would like to read the percentage of correctly classified samples from the

Rotating a NxN matrix in Java

左心房为你撑大大i 提交于 2021-02-01 05:49:45
问题 This is a question from Cracking the Coding Interview. The solution says that the program rotates the exterior edges, then the interior edges. However, I'm having trouble following the logic of both the for loops. Could somebody explain the logic of the code (e.g. why they do "layer < n/2" and the four steps of "left -> top" and "bottom -> left" etc)? On a side note, how would one's thought process be when coming up with this during a coding interview? Given an image represented by an NxN

Rotating a NxN matrix in Java

故事扮演 提交于 2021-02-01 05:49:05
问题 This is a question from Cracking the Coding Interview. The solution says that the program rotates the exterior edges, then the interior edges. However, I'm having trouble following the logic of both the for loops. Could somebody explain the logic of the code (e.g. why they do "layer < n/2" and the four steps of "left -> top" and "bottom -> left" etc)? On a side note, how would one's thought process be when coming up with this during a coding interview? Given an image represented by an NxN

Projection Matrix

假装没事ソ 提交于 2021-01-29 20:34:53
问题 I tried to understand the mathematics behind the projection matrix and I found this page. The matrix from this page: I found this matrix is similar to the matrix of Xna. I understood how they got to m33 and m44 columns of the matrix, but how they got to m11 and m22? And I didn't understand why I have to give the aspect ratio if I already give the field of view angle. The last thing I want to know is: what is the equation for transfaring from ndc space to window space and how they get to this

Does every matrix correspond to a graph conceptually?

我与影子孤独终老i 提交于 2021-01-29 19:27:54
问题 I understand there are 3 common ways to represent graphs: Adjacency Matrix Adjacency List Edge list That said, problems I’ve solved on LeetCode often use matrices and the solution requires DFS or BFS. For example, given the matrix below, find if a target string exists when you go left, right, up, and down (but not diagonal). [ [‘a’,‘p’,’p’], [‘e’,’a’,’l’], [‘r’,’t’,’e’] ] This required a DFS approach. Is this because this matrix represents a graph or does DFS and BFS apply to matrices too and

equalizing matrices for combining in abind R

99封情书 提交于 2021-01-29 18:14:33
问题 I believe that a similar question was asked here, but I can't seem to find it anymore. I have two matrices with different dimensions, and I want to equalise them so that I can combine them in an array. for example, I have the following two matrices: a <- matrix(1:6, 3, 2) b <- matrix(1:12, 4, 3) a [,1] [,2] [1,] 1 4 [2,] 2 5 [3,] 3 6 b [,1] [,2] [,3] [1,] 1 5 9 [2,] 2 6 10 [3,] 3 7 11 [4,] 4 8 12 Because I am working with time series data, I would like the added rows/colums to have NAs in

fortran matrix vector multiplication optimization

為{幸葍}努か 提交于 2021-01-29 16:30:58
问题 I tried to measure the difference of different matrix-vector-multiplication schemes in Fortran. I have actually written the following code: http://pastebin.com/dmKXdnX6 The 'optimized version' is meant to respect the memory layout of the matrix, by swapping the loops to access the matrix-elements. The provided code should compile with gfortran and it runs with the following rather surprising results: Vectors match! Calculations are OK. Optimized time: 0.34133333333333332 Naive time: 1

Sklearn how to get the 10 words from each topic

佐手、 提交于 2021-01-29 14:46:03
问题 I want to get the top 10 frequency of words from each topic, and after I use TfidfTransformer, I get: and the type is scipy.sparse.csr.csr_matrix But I don't know how to get the highest ten from each list, in the data, (0, ****) means the 0 list, until (5170, *****) means the 5170 list. I've tried to convert it into numpy, but it fails. (0, 19016) 0.024214182003181053 (0, 28002) 0.03661443306612277 (0, 6710) 0.02292100371816788 (0, 27683) 0.013973969726506812 (0, 27104) 0.02236713272585597 (0

AVX intrinsics for tiled matrix multiplication [closed]

我怕爱的太早我们不能终老 提交于 2021-01-29 13:18:23
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 1 year ago . Improve this question I was trying to use AVX512 intrinsics to vectorize my loop of matrix multiplication (tiled). I used __mm256d as variables to store intermediate results and store them in my results. However, somehow this triggers memory corruption. I've got no hint why this is the case, as the non

R loop over multiple matrices

穿精又带淫゛_ 提交于 2021-01-29 10:16:41
问题 I have 472 matrices with 405 columns each (matrix1 , ... , matrix400) and want to have 472 new matrices with only the first 244 columns of that matrix. How can I do that? I tried: for (i in 1:472) { assign(paste("new_matrix",i,sep=""), matrix[[i]][,c(1:244)]) } I created the matrices by splitting one dataframe by one identifier (for the groups): for (i in 1:472){ assign(paste("matrix", i, sep=""), subset(data, ID==i)) } Somehow I cannot speak to each matrix but I have no clue how I can do