matrix

使用python绘制混淆矩阵

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-14 04:48:28
使用python绘制混淆矩阵 # 可视化分类器性能 # load libraries import matplotlib . pyplot as plt import seaborn as sns from sklearn import datasets from sklearn . linear_model import LogisticRegression from sklearn . model_selection import train_test_split from sklearn . metrics import confusion_matrix import pandas as pd # load data 加载数据 iris = datasets . load_iris ( ) # create feature matrix features = iris . data # create target vector target = iris . target # create list of target class names class_names = iris . target_names # split into training and test sets # 创建 训练集 测试集 features_train , features_test ,

Three.js: how to apply rotation matrix to some base object's state?

假如想象 提交于 2020-01-14 03:49:07
问题 In this question Three.js: chaotic mesh rotation after applyMatrix I asked about an issue. Now I'll try to look at the issue from another end: to describe the desired behaviour of the program. I have an array of rotation matrices for each time point of object's state. Each rotation matrix represents a difference between some initial object state (point zero) and the desired state. User should be able at any time select any desired rotation matrix from the array. How to implement the correct

make a mask for each well in a grid

亡梦爱人 提交于 2020-01-14 03:32:27
问题 I have a grid of wells in an image and I'm trying to analyze this in Matlab. I want to create a box around each well to use as a mask. The way I am trying to go about this is to find the offset vectors from the X and Y normal and then use that to make a grid since I know the size of the wells. I can mask out some of the wells but not all of them---but this doesn't matter since I know that there is a well in every position (see here). I can use regionprops to get the centers but I can't figure

Javascript matrix inversion

▼魔方 西西 提交于 2020-01-14 03:18:06
问题 I am creating a javascript code for matrix inversion.But the function doesn't seem to run. I want my inverted matrix to be displayed where the input matrix was.I have tried alerting values of the invertedMatrix instead of putting them into s but that didn't work either.Would be grateful for any help html <div id = "table3"> <div class = "header">Macierz odwrotna [2x2]</div> <form id = "row1"> <input type = "text" class = "det2"/><!--first row--> <input type = "text" class = "det2"/> </form>

48. 旋转图像(中等题)

时光总嘲笑我的痴心妄想 提交于 2020-01-14 01:54:18
题目描述: 给定一个 n × n 的二维矩阵表示一个图像。 将图像顺时针旋转 90 度。 说明: 你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。 示例 1: 给定 matrix = [ [1,2,3], [4,5,6], [7,8,9] ], 原地旋转输入矩阵,使其变为: [ [7,4,1], [8,5,2], [9,6,3] ] 示例 2: 给定 matrix = [ [ 5, 1, 9,11], [ 2, 4, 8,10], [13, 3, 6, 7], [15,14,12,16] ], 原地旋转输入矩阵,使其变为: [ [15,13, 2, 5], [14, 3, 4, 1], [12, 6, 8, 9], [16, 7,10,11] ] 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/rotate-image 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 解法: class Solution { public void rotate ( int [ ] [ ] matrix ) { if ( matrix == null || matrix . length == 0 || matrix [ 0 ] . length == 0 ) { return

Matlab output - Space padding?

穿精又带淫゛_ 提交于 2020-01-13 19:56:40
问题 I'm trying to output a Matrix: M = [1 20 3; 22 3 24; 100 150 2]; Using: for i=1:3 fprintf('%f\t%f\t%f\n', M(i), M(i+length(M)), M(i+length(M)*2)); end And the output is turning out something like: 1 20 3 22 3 24 100 150 2 Which is obviously not great. How can I get it so the front of integers are padded with spaces? Like so: 1 20 3 22 3 24 100 150 2 Any ideas? Thanks! 回答1: You can use string formatting to allocate specific number of characters per displayed number. For example fprintf('% 5d\n

Java Tetris rotation

前提是你 提交于 2020-01-13 13:04:39
问题 I know this has been asked a lot but I'd like to know how to rotate a Tetris piece? I already made a long and bad solution (~170 lines of code) but there should be easier way to do it. My tetris pieces consist of 4 blocks which all know their location (row and column) in the matrix. Matrix itself is char-typed, so 4 blocks are all letters. It looks like this for example: ...... ..T... .TTT.. ...... I tried to simulate my matrix as coordinate system by counting the middle row and column and

A question about printf arguments. C/C++

拥有回忆 提交于 2020-01-13 11:27:07
问题 We have the following code fragment: char tab[2][3] = {'1', '2', '\0', '3', '4', '\0'}; printf("%s\n", tab); And I don't understand why we don't get an error / warning in the call to printf . I DO get a warning but not an error, and the program runs fine. It prints ' 12 '. printf is expecting an argument of type char * , i.e. a pointer to char . So if I declared char arr[3] , then arr is an address of a memory unit which contains a char , so if I called printf with it, it would decay to

Is there a transformation matrix that can scale the x and/or y axis logarithmically?

狂风中的少年 提交于 2020-01-13 10:03:03
问题 I'm using .net WPF geometry classes to graph waveforms. I've been using the matrix transformations to convert from the screen coordinate space to my coordinate space for the waveform. Everything works great and it's really simple to keep track of my window and scaling, etc. I can even use the inverse transform to calculate the mouse position in terms of the coordinate space. I use the built in Scaling and Translation classes and then a custom matrix to do the y-axis flipping (there's not a

Is there a transformation matrix that can scale the x and/or y axis logarithmically?

大城市里の小女人 提交于 2020-01-13 10:02:18
问题 I'm using .net WPF geometry classes to graph waveforms. I've been using the matrix transformations to convert from the screen coordinate space to my coordinate space for the waveform. Everything works great and it's really simple to keep track of my window and scaling, etc. I can even use the inverse transform to calculate the mouse position in terms of the coordinate space. I use the built in Scaling and Translation classes and then a custom matrix to do the y-axis flipping (there's not a