Archive for May, 2015

May
24

matrix calculation in R and Python

  • Useful packages:
    • R: library(matrixcalc)
    • Python: numpy
  • Matrix generation:
    • R: matrix(1:6, 2, 3)
    • Python: np.arange(1,7).reshape(2,3)
  • construct a diagnal matrix:
    • R: advanced-R
      • diag(vector, nrow, ncol) #construct a matrix which diagonal elements is equal to the vector
      • diag(matrix) # a vector which elements is the diagonal elements of the matrix
    • Python: np.diag(vector)
      • np.diag(vector, k) # like the diag(vector) in R, k means the shift of the diagnoal
      • np.diag(matrix) #return a vector which values are the diagonal elements of the matrix
  • singular value decomposition:
    • R:
      • svd(matrix)
    • Python:
      • np.linalg.svd(matrix, full_matrices=True) #if full_matrices=False, the result will be the same as with R
  • resolve Ax=b
    • R: solve(A,b)
    • Python: np.linalg.solve(A,b)
May
12

How to install R-extention in RapidMiner for Ubuntu?

I found the easiest way to install R extention for Ubuntun

  • RapidMiner -> Marketplace -> R Extention
  • RStudio -> Tools -> Install Packages… -> Input in the field “Packages”: rJava, JavaGD
    Or input in R Console: install.packages(c(“rJava”,”JavaGD”))
  • Restart RapidMiner
  • you get a popup -> choose the jri file, the path is here:
    “/home/xxx/R/x86_64-pc-linux-gnu-library/3.0/rJava/jri/libjri.so”
  • Restart RapidMiner

This article is more detailed.

May
10

Start with R

Useful web sites for R:

About Package

  • install.packages(“ggplot2”), you can also install with RStudio menu: Tools -> Install Packages…
  • library(ggplot2)
May
02

JAVA_HOME Problem during Hadoop installation on windows

If you install the hadoop in windows, after the installation, you will confront this problem: you can not set the evironment valuable.

This file won’t work: c:\deploy\etc\hadoop\hadoop-env.cmd

If you do this step: “%HADOOP_PREFIX%\sbin\start-dfs.cmd”

Then you will see a error message about JAVA_HOME not found. This is very strange for you, because you are sure, you have already done the JAVA_HOME Setting.

The reason for that is a very old problem from microsoft in the time win95, they can not deal with the folder with lang names, so if you want to tell the system about the your JAVA_HOME path with a blank, you have to do: “c:\Progra~1\Java\…” instead of “c:\Program Files\Java\….”. This is windows 8.3 Pathname

So the solution is:

open file: c:\deploy\etc\hadoop\hadoop-env.cmd

change JAVA_HOME=%JAVA_HOME% to JAVA_HOME=”C:\Progra~1\Java\jdk1.8.0_45″

Hadoop installation on windows