博文

目前显示的是 五月, 2016的博文

升级所有pip包

conda update --all sudo pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs pip install -U

R 与矩阵

library(Matrix) A <- matrix(1:18,3,6) #求秩 rankMatrix(A) #奇异值分解 svd(A) #特征值分解(方阵) B <- matrix(1:9,3) eigen(B) library(numDeriv) sc2.f <- function(x){   n <- length(x)   sum((1:n) * (exp(x) - x)) / n } sc2.g <- function(x){   n <- length(x)   (1:n) * (exp(x) - 1) / n } x0 <- rnorm(5) hess <- hessian(func=sc2.f, x=x0) hessc <- hessian(func=sc2.f, x=x0, "complex") all.equal(hess, hessc, tolerance = .Machine$double.eps) #  Hessian = Jacobian of the gradient jac  <- jacobian(func=sc2.g, x=x0) jacc <- jacobian(func=sc2.g, x=x0, "complex") all.equal(hess, jac, tolerance = .Machine$double.eps) all.equal(hessc, jacc, tolerance = .Machine$double.eps)

data.table的使用(与dplyr包比较)

library(dplyr) library(data.table) library(lubridate) library(jsonlite) library(tidyr) library(ggplot2) library(compare) spending=fromJSON("https://data.medicare.gov/api/views/nrth-mfg3/rows.json?accessType=DOWNLOAD") names(spending) meta=spending$meta hospital_spending=data.frame(spending$data) colnames(hospital_spending)=make.names(meta$view$columns$name) hospital_spending=select(hospital_spending,-c(sid:meta)) #dplyr包,Get a glimpse of your data glimpse(hospital_spending) cols = 6:11; # 需要改变数据类型的列 hospital_spending[,cols] <- lapply(hospital_spending[,cols],as.character) hospital_spending[,cols] <- lapply(hospital_spending[,cols],as.numeric) cols = 12:13; # 需要纠正的两列 hospital_spending[,cols] <- lapply(hospital_spending[,cols],as.POSIXct) #检查下数据列是否是我们想要的数据类型 sapply(hospital_spending, class) #使用data.table函数创建data.table类型数据 hospital_spending_DT = data.table(hospital_spending) class(hospital_spending_DT) #选取一个变量 from_dplyr = select(hospital

anaconda 安装

1、下载anaconda(https://www.continuum.io/downloads) 2、 bash Anaconda2-4.0.0-Linux-x86_64.sh 3、  pip install 包名,或者conda install 包名,查看 pip list 或者conda list

GPU Deep Learn

一、安装驱动 sudo apt-get install nvidia-352 nvidia-settings GPU支持 (https://developer.nvidia.com/cuda-gpus) 二、安装CUDA和Digits CUDA_REPO_PKG=cuda-repo-ubuntu1404_7.5-18_amd64.deb && wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1404/x86_64/$CUDA_REPO_PKG && sudo dpkg -i $CUDA_REPO_PKG ML_REPO_PKG=nvidia-machine-learning-repo_4.0-2_amd64.deb && wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1404/x86_64/$ML_REPO_PKG && sudo dpkg -i $ML_REPO_PKG apt-get update apt-get install digits 三、打开您的浏览器并访问http://localhost

ubuntu install maltego

sudo add-apt-repository ppa:darklordpaunik8880/darkminttrustytahr sudo apt-get update sudo apt-get install maltego

编译OpenWrt shadowsocks

1、sudo apt-get install  gcc g ++ binutils patch bzip2 flex bison make autoconf gettext texinfo unzip sharutils subversion libncurses5 - dev ncurses - term zlib1g - dev gawk git libssl - dev ccache 2、sudo vim /etc/profile #将sdk下staging_dir/host/bin和toolchain/bin目录添加  export PATH=${PATH}:/home/xuefliang/Downloads/OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin:/home/xuefliang/Downloads/OpenWrt-SDK-15.05.1-ar71xx-generic_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/host/bin source /etc/profile make menuconfig 在Network里面选中shadowsocks-libev,选择编译成模块就可以了,也就是前面一个M,空格键选择。 然后直接推出保存设置。 开始编译。 3、make package/openwrt-shadowsocks/compile V=s

Spark安装

1 jps 2 sudo apt-get install scala 3 下载spark 4 tar xvf 解压

SparkR 安装

install.packages("rJava") install.packages("devtools") library(devtools) install_github("amplab-extras/SparkR-pkg",subdir = "pkg")

jupyter安装

安装 1、sudo pip install pyzmq 2、sudo pip install tornado 3、sudo pip install jinja2 4、sudo pip install jsonschema 5、sudo pip install jupyte or sudo pip install "ipython[notebook]" 运行:jupyter  notebook 出现jupyter,在其右侧,选择“new”,选择“Python2”

windows 命令行下 查看端口占用情况的方法

图片
netstat -aon | findstr "1080" tasklist | findstr "9132"

ubuntu 配置 dante-server

1、sudo apt-get install dante-server 2、sudo vi /etc/danted.conf # $Id: sockd.conf,v 1.43 2005/12/26 16:35:26 michaels Exp $ # # A sample danted.conf # # # The configfile is divided into three parts; #    1) serversettings #    2) rules #    3) routes # # The recommended order is: #   Serversettings: #               logoutput #               internal #               external #               method #               clientmethod #               users #               compatibility #               extension #               connecttimeout #               iotimeout # srchost # #  Rules: # client block/pass # from to # libwrap # log # #     block/pass # from to # method # command # libwrap # log # protocol # proxyprotocol # #  Routes: # the server will log both via syslog, to stdout and to /var/log/lotsoflogs #logoutput: syslog stdout /var/log/lotsoflogs logoutput: stderr # The server will bind to the address 10.1.1.1, port

Ubuntu IP地址配置

sudo vi /etc/network/interfaces auto eth0 iface eth0 inet dhcp auto eth0 iface eth0 inet static address 10.112.6.208 gateway 10.112.6.254 netmask 255.255.255.0

R 二类疫苗统计

library(dplyr) df <- read.csv("C:\\Users\\xuefliang\\Desktop\\统计\\乙肝汉逊.csv") df$year<- as.character(df$year) df$diqu<- as.character(df$diqu) df$pihao <- as.character(df$pihao) df$goujin<- as.numeric(as.character(df$goujin)) df$shiyong<- as.numeric(as.character(df$shiyong)) #sum(df$goujin,na.rm=T) #sum(df$shiyong,na.rm=T) df$year[is.na(df$year)] <- "" for(i in 1:nrow(df)){   if (nchar(df$year)==0){     df$year[i] <- df$year[i-1]   } } for(i in 1:nrow(df)){   if (df$year[i]==""){     df$year[i] <- df$year[i-1]   } } df$diqu[is.na(df$diqu)] <- "" for(i in 1:nrow(df)){   if (nchar(df$diqu)==0){     df$diqu[i] <- df$diqu[i-1]   } } for(i in 1:nrow(df)){   if (df$diqu[i]==""){     df$diqu[i] <- df$diqu[i-1]   } } #按-拆分字符串 for(i in 1:nrow(df)){   df$pihao[i] <- unlist(strsplit(df$pihao[i], "-"))[1] } result <- group_by(df,diqu,year,pihao)%>%   su

R 删除空行

library(xlsx) library(dplyr) workbook <- "C:\\Users\\Administrator\\Desktop\\合格\\兰州市汇总2010-2016年15种生物制品使用情况信息表().xlsx" #表1 mydataframe <- read.xlsx2(workbook,1,startRow=3) mydataframe$X..6 <- as.character(mydataframe$X..6) mydataframe$X. <- as.character(mydataframe$X.) mydataframe$X..5 <- as.character(mydataframe$X..5) mydataframe$购进数量..支. <- as.numeric(as.character(mydataframe$购进数量..支.)) mydataframe$该批次生物制品使用数量..支. <- as.numeric(as.character(mydataframe$该批次生物制品使用数量..支.)) #删除空白行 num=c() for(i in 1:nrow(mydataframe)){   if (nchar(mydataframe$X..5[i])==0){     num[i] <- i   } } mydataframe <- mydataframe[-num[!is.na(num)],] for(i in 1:nrow(mydataframe)){   if (nchar(mydataframe$X.[i])==0){     mydataframe$X.[i] <- mydataframe$X.[i-1]   } } #按-拆分字符串 for(i in 1:nrow(mydataframe)){   mydataframe$X..6[i] <- unlist(strsplit(mydataframe$X..6[i], "-"))[1] } result <- select(mydataframe,year=X.,pihao=X..6,gouji

gufw epub chm

sudo apt-get install fbreader gufw kchmviewer