HADOOP SETUP CODE
HDFS-SITE.XML
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
<description>Default block replication.
The actual number of replications can be specified when the file is created.
The default is used if replication is not specified in create time.
</description>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop_store/hdfs/namenode</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop_store/hdfs/datanode</value>
</property>
</configuration>
CORE_SITE.XML
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/app/hadoop/tmp</value>
<description>A base for other temporary directories.</description>
</property>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:54310</value>
<description>The name of the default file system.</description>
</property>
</configuration>
MAPRED-SITE.XML
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:54311</value>
<description>The host and port that the MapReduce job tracker runs
at.
</description>
</property>
</configuration>
IMPORTING DATA FROM HDFS
reder=hdfs.line.reader("/data/diabetes")
dibaetes = reder$read()
typeof(dibaetes)
diabetes
DECESION TREE USING R
names(diabetes) <- gsub("\\.","",names(diabetes))
str(diabetes)
attributes(diabetes)
library(rpart)
set.seed(564)
flags = sample(2,nrow(diabetes), replace = TRUE, prob =c(0.7,0.3))
trainset = diabetes[which(flags==1),]
testset = diabetes[which(flags==2),]
str(trainset)
str(testset)
index = sample(1:nrow(diabetes), nrow(diabetes)*0.7, replace=FALSE)
trainset = diabetes[index,]
testset = diabetes[-index,]
str(trainset)
str(testset)
?rpart
dtree = rpart(Classvariable ~ Number_of_times_pregnant
+Plasma_glucose_concentration
+Diastolic_blood_pressure
+Triceps_skin_fold_thickness
+Hour_serum_insulin
+Body_mass_index
+Diabetes_pedigree_function
+Ageyears ,
data=trainset,
control=rpart.control(minsplit = 10))
str(dtree)
dtree
plot(dtree)
text(dtree)
attributes(dtree)
dtree$variable.importance
name = read.csv("new.csv",header=1)
predict(dtree, New, type=c("class"))
predictedDT = predict(dtree, testset, type=c("class"))
predictedDT
table(predictedDT, testset$Classvariable)
mean(predictedDT!=testset$Classvariable)
name = read.csv("read.csv",header=1)
predict(dtree, name, type=c("class"))
TESTING
package com.selenium.one;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.LogStatus;
public class Examples {
@Test
public void verifyTitle(){
ExtentReports extent = ExtentReports.get(Examples.class);
extent.init("/home/akhil/check.html",true);
extent.startTest("verify page");
/**
* @param args
*/
// TODO Auto-generated method stub
WebDriver driver =new FirefoxDriver();
driver.get("http://localhost/registration/input.html");
driver.manage().window().maximize();
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[1]/p/input")).sendKeys("lokesh@gmail.com");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[1]/input")).sendKeys("lokesh");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[2]/input")).sendKeys("kuncham");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[3]/input")).sendKeys("rvr");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[4]/input")).sendKeys("21");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[5]/input")).sendKeys("amarvathi");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[6]/input")).sendKeys("guntur");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[7]/input")).sendKeys("andhra pradesh");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[8]/input")).sendKeys("522007");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[9]/input")).sendKeys("87654");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[2]/p[10]/input")).sendKeys("12345");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[1]/input")).sendKeys("22");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[2]/input")).sendKeys("24");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[3]/input")).sendKeys("54");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[4]/input")).sendKeys("44");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[5]/input")).sendKeys("66");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[6]/input")).sendKeys("89");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/p[7]/input")).sendKeys("56");
extent.log(LogStatus.INFO,"browser is running");
driver.findElement(By.xpath("html/body/form/fieldset[3]/input")).click();
extent.log(LogStatus.PASS, "submitted sucessfully");
driver.navigate().back();
}
}
No comments:
Post a Comment