Showing posts with label R. Show all posts
Showing posts with label R. Show all posts

Banking Domain Case Study in Hadoop and R

In this blog and the next few ones that will follow, we will analyze a banking domain dataset, which contains several files with details of its customers. This database was prepared by Petr Berka and Marta Sochorova.
The Berka dataset is a collection of financial information from a Czech bank. The dataset deals with over 5,300 bank clients with approximately 1,000,000 transactions. Additionally, the bank represented in the dataset has extended close to 700 loans and issued nearly 900 credit cards, all of which are represented in the data.
By the time you finish reading this blog,  you would have learned :
  • How to analyze a bank’s data to predict a customer’s quality
  • Using this analysis we can categorize a customer into three categories:
  1. Excellent: Customers whose record is good with the bank
  2. Good: Customers who have average earning with a good record till now
  3. Risky: Customers who are under debt of bank or who has not paid the loan on time
  • How to write PIG UDF
  • How to connect Hadoop with R
  • How to load data from Hadoop to R
How to analyze a bank’s data to predict the customer’s quality
Prerequisite
Software Technology
  • Java installed Hadoop concepts
  • Hadoop installed Java concepts
  • Pig installed Pig concepts
  • R-base
  • Rstudio
  • Ubuntu OS


View the detail case study here.

Installing R in Ubuntu Trusty

Step 1 :- Add the latest trusty link from cran to apt. [click here for reference]
sudo gedit /etc/apt/sources.list

deb http://cran.r-project.org/bin/linux/ubuntu/ trusty/

Step 2 :- Add secure key to check the new added link [click here for more info]

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9





Step 3 :- Check the apt by the following command

sudo apt-get update


Step 4 :- Now run the below command to install R
sudo apt-get install r-base
sudo apt-get install r-base-dev



Step 5 :- Now type R in the shell to get into R command prompt

R


Installing R studio [click here and get started for more info]

apt-get install libjpeg62
$ sudo apt-get install gdebi-core
$ sudo apt-get install libapparmor1 # Required only for Ubuntu, not Debian
$ wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb
$ sudo gdebi rstudio-server-0.98.1103-amd64.deb



http://localhost:8787

Installing R in Hadoop Cluster

There are multiple ways to install R & R studio in your unix system here I have described the simplest of them all by which I have been able to install R successfully in my system.

Installing R :-
Step1:- Download the latest R package from Cran.

Step2:- Choose a directory to install the R tree (R is not just a binary, but has additional data sets, help files, font metrics etc). Let us call this place R_HOME. Untar the source code. This should create directories src, doc, and several more under a top-level directory: change to that top-level directory.
Issue the following commands:
./configure
make

Step3:- Then check the built system works correctly by
make check
or
make check-devel
or
make check-all
 
Step4:- Then type
make install
This will install to the following directories:
prefix/bin or bindir
the front-end shell script and other scripts and executables
prefix/man/man1 or mandir/man1
the man page
prefix/LIBnn/R or libdir/R
all the rest (libraries, on-line help system, …). Here LIBnn is usually ‘lib’, but may be ‘lib64’ on some 64-bit Linux systems. This is known as the R home directory.
where prefix is determined during configuration (typically /usr/local) and can be set by running configure with the option --prefix, as in
./configure --prefix=/where/you/want/R/to/go
This causes make install to install the R script to /where/you/want/R/to/go/bin, and so on. The prefix of the installation directories can be seen in the status message that is displayed at the end of configure. The installation may need to be done by the owner of prefix, often a root account.
You can install into another directory tree by using
make prefix=/path/to/here install
 
Well that's it. This will complete the installation of R and now you can type R on your command prompt to get into R.

Installing R Studio[Cent OS] :-

32bit

$ sudo yum install openssl098e # Required only for RedHat/CentOS 6 and 7
$ wget http://download2.rstudio.org/rstudio-server-0.98.1091-i686.rpm
$ sudo yum install --nogpgcheck rstudio-server-0.98.1091-i686.rpm
64bit

$ sudo yum install openssl098e # Required only for RedHat/CentOS 6 and 7
$ wget http://download2.rstudio.org/rstudio-server-0.98.1091-x86_64.rpm
$ sudo yum install --nogpgcheck rstudio-server-0.98.1091-x86_64.rpm


Installing R Hadoop Packages :-

To install required packages for R Hadoop please follow the link here.