matrix

Evaluate column of matrix

家住魔仙堡 提交于 2020-02-08 09:37:08
问题 I am trying to evaluate the 8th column of a matrix sep <- read.csv("California_SEP_assets_csv.csv") Sub1 <- sep[grep("SEP.11", names(sep))] sep$newCol <- 100*rowSums(Sub1)/rowSums(sep[4:7]) library(sp) coords <- cbind(Longitude = as.numeric(as.character(sep$Longitude)),Latitude=as.numeric(as.character(sep$Latitude))) if (sep[8] > 50){ sep.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)],proj4string = CRS("+init=epsg:4326")) } else { sep2.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)]

Evaluate column of matrix

纵然是瞬间 提交于 2020-02-08 09:36:11
问题 I am trying to evaluate the 8th column of a matrix sep <- read.csv("California_SEP_assets_csv.csv") Sub1 <- sep[grep("SEP.11", names(sep))] sep$newCol <- 100*rowSums(Sub1)/rowSums(sep[4:7]) library(sp) coords <- cbind(Longitude = as.numeric(as.character(sep$Longitude)),Latitude=as.numeric(as.character(sep$Latitude))) if (sep[8] > 50){ sep.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)],proj4string = CRS("+init=epsg:4326")) } else { sep2.pts <- SpatialPointsDataFrame(coords,sep[,-(2:3)]

数据挖掘——预测未来销售

南笙酒味 提交于 2020-02-07 09:14:15
数据挖掘——预测未来销售 处理sale_train_v2.csv和test.csv 处理shop.csv 处理item_categories.csv 处理items.csv 特征添加 该项目来自kaggle比赛, 处理sale_train_v2.csv和test.csv 1、读取训练数据: test = pd . read_csv ( "./test.csv" ) . set_index ( "ID" ) train = pd . read_csv ( "./sales_train_v2.csv" ) 2、删除异常值 先画图查看"item_price"属性的分布: index = [ v for v in range ( 2935849 ) ] plt . scatter ( index , train [ "item_price" ] ) plt . show ( ) 属性"item_price"的分布如上,这里将大于100000的点视为异常值,将其剔除掉: train = train [ train . item_price < 100000 ] 再看"item_cnt_day"属性: 将大于1000视为异常值: train = train [ train . item_cnt_day < 1000 ] 3、将售价低于0的使用中值填充 median = train [ (

JOGL setPerspective wrong?

匆匆过客 提交于 2020-02-05 13:50:04
问题 I've decided to use JOGL for my project. But here is the problem with setting perspective. Simple code: System.out.println("BEFORE:"); projectionMatrix.identity(); projectionMatrix.setPerspective(fovy, aspect, zNear, zFar); System.out.println(projectionMatrix); System.out.println("AFTER:"); projectionMatrix.identity(); projectionMatrix.m00 = (float)(1.0 / (aspect*Math.tan(viewAngle))); projectionMatrix.m11 = (float)(1.0 / Math.tan(viewAngle)); projectionMatrix.m22 = (float)((-zNear-zFar) /

JOGL setPerspective wrong?

梦想与她 提交于 2020-02-05 13:49:28
问题 I've decided to use JOGL for my project. But here is the problem with setting perspective. Simple code: System.out.println("BEFORE:"); projectionMatrix.identity(); projectionMatrix.setPerspective(fovy, aspect, zNear, zFar); System.out.println(projectionMatrix); System.out.println("AFTER:"); projectionMatrix.identity(); projectionMatrix.m00 = (float)(1.0 / (aspect*Math.tan(viewAngle))); projectionMatrix.m11 = (float)(1.0 / Math.tan(viewAngle)); projectionMatrix.m22 = (float)((-zNear-zFar) /

JOGL setPerspective wrong?

北城余情 提交于 2020-02-05 13:48:05
问题 I've decided to use JOGL for my project. But here is the problem with setting perspective. Simple code: System.out.println("BEFORE:"); projectionMatrix.identity(); projectionMatrix.setPerspective(fovy, aspect, zNear, zFar); System.out.println(projectionMatrix); System.out.println("AFTER:"); projectionMatrix.identity(); projectionMatrix.m00 = (float)(1.0 / (aspect*Math.tan(viewAngle))); projectionMatrix.m11 = (float)(1.0 / Math.tan(viewAngle)); projectionMatrix.m22 = (float)((-zNear-zFar) /

How to multiply multi-dimensional arrays/matrices in Julia

半腔热情 提交于 2020-02-05 13:12:27
问题 Multiplying two multi-dimensional arrays, say, a 1-dimensional with a 3-dimensional array: [1 2] * reshape(1:8,2,2,2) gives me the error message: LoadError: MethodError: `*` has no method matching *(::Array{Int64,2}, ::Array{Int64,3}) Closest candidates are: *(::Any, ::Any, !Matched::Any, !Matched::Any...) *{TA,TB}(::Union{DenseArray{TA,1},DenseArray{TA,2},SubArray{TA,1,A<:DenseArray{T,N},I<:Tuple{Vararg{Union{Colon,Int64,Range{Int64}}}},LD},SubArray{TA,2,A<:DenseArray{T,N},I<:Tuple{Vararg

搜索二维矩阵II

三世轮回 提交于 2020-02-05 05:19:50
编写一个高效的算法来搜索 m x n 矩阵 matrix 中的一个目标值 target。该矩阵具有以下特性: 每行的元素从左到右升序排列。 每列的元素从上到下升序排列。 示例: 现有矩阵 matrix 如下: [ [1, 4, 7, 11, 15], [2, 5, 8, 12, 19], [3, 6, 9, 16, 22], [10, 13, 14, 17, 24], [18, 21, 23, 26, 30] ] 给定 target = 5,返回 true。 给定 target = 20,返回 false。 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/search-a-2d-matrix-ii 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 从矩阵左下开始比较,容易一些; class Solution { public : bool searchMatrix ( vector < vector < int >> & matrix , int target ) { int row = matrix . size ( ) ; if ( row == 0 ) { return false ; } int col = matrix [ 0 ] . size ( ) ; if ( col == 0 ) {

Is there a way to speed up Numpy array calculations when they only contain values in upper/lower triangle?

浪尽此生 提交于 2020-02-04 11:27:04
问题 I'm doing some matrix calculations (2d) that only involve values in the upper triangle of the matrices. So far I've found that using Numpy's triu method ("return a copy of a matrix with the elements below the k-th diagonal zeroed") works and is quite fast. But presumably, the calculations are still being carried out for the whole matrix, including unnecessary calculations on the zeros. Or are they?... Here is an example of what I tried first: # Initialize vars N = 160 u = np.empty(N) u[0] =