Escolar Documentos
Profissional Documentos
Cultura Documentos
IV-BTECH
VID
Contents
S.No Topic Week1 1. Write a shell script that accepts a file name, starting and ending line numbers as arguments and displays all the lines between the given line numbers. 2. Write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it. 3. Write a shell script that displays a list of all the files in the current directory to which the user has read, write and execute permissions. 4. Write a shell script that receives any number of file names as arguments checks if every argument supplied is a file or a directory and reports accordingly. Whenever the argument is a file, the number of lines on it is also reported. 7 Page no
3.
4.
Week 2 5. Write a shell script that accepts a list of file names as its arguments, counts and reports the occurrence of each word that is present in the first argument file on other argument files 6. Write a shell script to list all of the directory files in a directory. 7. Write a shell script to find factorial of a given integer. Week 3 8. Write an awk script to count the number of lines in a file that do not contain vowels. 9. Write an awk script to find the number of characters, words and lines in a file. 10. Write a c program that makes a copy of a file using standard I/O and system calls 10
5.
13
6.
15
7.
19
8.
9.
22. Write a C program that receives the messages (from the above message queue as specified in (21)) and displays them. Week 8 23. Write a C program to allow cooperating processes to lock a resource for exclusive use, using a) Semaphores b) flock or lockf system calls. 40
10.
41
12.
47
13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24.
Listing of categorical attributes and the real-valued attributes separately. Rules for identifying attributes. Training a decision tree. Test on classification of decision tree. Testing on the training set . Using cross validation for training. Significance of attributes in decision tree. Trying generation of decision tree with various number of decision tree. Find out differences in results using decision tree and cross-validation on a data set. Decision trees. Reduced error pruning for training Decision Trees using cross-validation Convert a Decision Trees into "if-then-else rules".
55 56 59 63 67 68 71 74 76 78 78 81
2. Write a shell script that deletes all lines containing a specified word in one or more files
supplied as arguments to it. Aim: To write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it. Script: clear i=1 while [ $i -le $# ] do grep -v Unix $i > $i done Output: $ sh 1b.sh test1 the contents before deleting test1 hello hello bangalore mysore city enter the word to be deleted
3. Write a shell script that displays a list of all the files in the current directory to which the user has read, write and execute permissions. Aim: To write a shell script that displays a list of all the files in the current directory to which the user has read, write and execute permissions. Script: echo "enter the directory name" read dir if [ -d $dir ] then cd $dir ls > f exec < f while read line do if [ -f $line ] then if [ -r $line -a -w $line -a -x $line ] then echo "$line has all permissions" else echo "files not having all permissions" fi fi done fi
argument supplied is a file or a directory and reports accordingly. Whenever the argument is a file, the number of lines on it is also reported Aim: To write a shell script that receives any number of file names as arguments checks if every argument supplied is a file or a directory Script: for x in $* do if [ -f $x ] then echo " $x is a file " echo " no of lines in the file are " wc -l $x elif [ -d $x ] then echo " $x is a directory " else echo " enter valid filename or directory name " fi done
occurrence of each word that is present in the first argument file on other argument files. Aim : To write a shell script that accepts a list of file names as its arguments, counts and reports the occurrence of each word that is present in the first argument file on other argument files. Script: if [ $# -ne 2 ] then echo "Error : Invalid number of arguments." exit fi str=`cat $1 | tr '\n' ' '` for a in $str do echo "Word = $a, Count = `grep -c "$a" $2`" done Output : $ cat test hello ATRI $ cat test1 hello ATRI hello ATRI hello $ sh 1.sh test test1 Word = hello, Count = 3 Word = ATRI, Count = 2
6. Write a shell script to list all of the directory files in a directory. Script: # !/bin/bash echo"enter directory name" read dir if[ -d $dir] then echo"list of files in the directory" ls $dir else echo"enter proper directory name" fi Output: Enter directory name Atri List of all files in the directoty CSE.txt ECE.txt 7. Write a shell script to find factorial of a given integer. Script: # !/bin/bash echo "enter a number" read num fact=1 while [ $num -ge 1 ] do fact=`expr $fact \* $num` let num-done echo "factorial of $n is $fact" Output: Enter a number 5 Factorial of 5 is 120
/* minimal DIR: no buffering, etc. */ /* file descriptor for the directory */ /* the directory entry */
DIR *opendir(char *dirname); Dirent *readdir(DIR *dfd); void closedir(DIR *dfd); The system call stat takes a filename and returns all of the information in the inode for that file, or -1 if there is an error. That is, char *name; struct stat stbuf;
stat(name, &stbuf); fills the structure stbuf with the inode information for the file name. The structure describing the value returned by stat is in <sys/stat.h>, and typically looks like this: struct stat /* inode information returned by stat */ { dev_t ino_t short short short short dev_t off_t st_dev; st_ino; st_mode; /* device of inode */ /* inode number */ /* mode bits */
st_nlink; /* number of links to file */ st_uid; st_gid; st_rdev; st_size; /* owners user id */ /* owners group id */ /* for special files */ /* file size in characters */
time_t st_atime; /* time last accessed */ time_t st_mtime; /* time last modified */ time_t st_ctime; /* time originally created */ }; Most of these values are explained by the comment fields. The types like dev_t and ino_t are defined in<sys/types.h>, which must be included too. The st_mode entry contains a set of flags describing the file. The flag definitions are also included in<sys/types.h>; we need only the part that deals with file type: #define S_IFMT 0160000 /* type of file: */ #define S_IFDIR 0040000 /* directory */ #define S_IFCHR 0020000 /* character special */ #define S_IFBLK 0060000 /* block special */
#include <sys/types.h> /* typedefs */ #include <sys/stat.h> /* structure returned by stat */ #include "dirent.h"
void fsize(char *)
/* print file name */ main(int argc, char **argv) { if (argc == 1) /* default: current directory */ fsize("."); else while (--argc > 0) fsize(*++argv); return 0;
/* fsize: print the name of file "name" */ void fsize(char *name) { struct stat stbuf;
if (stat(name, &stbuf) == -1) { fprintf(stderr, "fsize: can't access %s\n", name); return; } if ((stbuf.st_mode & S_IFMT) == S_IFDIR) dirwalk(name, fsize); printf("%8ld %s\n", stbuf.st_size, name); } The function dirwalk is a general routine that applies a function to each file in a directory. It opens the directory, loops through the files in it, calling the function on each, then closes the directory and returns. Since fsize calls dirwalk on each directory, the two functions call each other recursively. #define MAX_PATH 1024
if ((dfd = opendir(dir)) == NULL) { fprintf(stderr, "dirwalk: can't open %s\n", dir); return; } while ((dp = readdir(dfd)) != NULL) { if (strcmp(dp->name, ".") == 0 || strcmp(dp->name, "..")) continue; /* skip self and parent */ if (strlen(dir)+strlen(dp->name)+2 > sizeof(name)) fprintf(stderr, "dirwalk: name %s %s too long\n", dir, dp->name); else { sprintf(name, "%s/%s", dir, dp->name); (*fcn)(name); } } closedir(dfd); }
char d_name[DIRSIZ]; /* long name does not have '\0' */ }; Some versions of the system permit much longer names and have a more complicated directory structure. The type ino_t is a typedef that describes the index into the inode list. It happens to be unsigned short on the systems we use regularly, but this is not the sort of information to embed in a program; it might be different on a different system, so the typedef is better. A complete set of ``system'' types is found in <sys/types.h>. opendir opens the directory, verifies that the file is a directory (this time by the system call fstat, which is like stat except that it applies to a file descriptor), allocates a directory structure, and records the information: int fstat(int fd, struct stat *);
/* opendir: open a directory for readdir calls */ DIR *opendir(char *dirname) { int fd; struct stat stbuf;
if ((fd = open(dirname, O_RDONLY, 0)) == -1 || fstat(fd, &stbuf) == -1 || (stbuf.st_mode & S_IFMT) != S_IFDIR || (dp = (DIR *) malloc(sizeof(DIR))) == NULL) return NULL; dp->fd = fd; return dp; } closedir closes the directory file and frees the space: /* closedir: close directory opened by opendir */ void closedir(DIR *dp) { if (dp) { close(dp->fd); free(dp); } } Finally, readdir uses read to read each directory entry. If a directory slot is not currently in use (because a file has been removed), the inode number is zero, and this position is skipped. Otherwise, the inode number and name are placed in a static structure and a pointer to that is returned to the user. Each call overwrites the information from the previous one. #include <sys/dir.h> /* local directory structure */
while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dirbuf)) { if (dirbuf.d_ino == 0) /* slot not in use */ continue; d.ino = dirbuf.d_ino; strncpy(d.name, dirbuf.d_name, DIRSIZ); d.name[DIRSIZ] = '\0'; /* ensure termination */ return &d; } return NULL; } 15. Write a C program that demonstrates redirection of standard output to a file. Ex: ls > f1. Description: An Inode number points to an Inode. An Inode is a data structure that stores the following information about a file :
Size of file Device ID User ID of the file Group ID of the file The file mode information and access privileges for owner, group and others File protection flags The timestamps for file creation, modification etc link counter to determine the number of hard links Pointers to the blocks storing files contents
Size buffer size for storing the input 3) Use read() function to read the data that has been written to the fifo. The syntax is as follows read(int [], char,size); PROGRAM: #define FIFO1 "Fifo1" #define FIFO2 "Fifo2" #include<stdio.h> #include<string.h> #include<sys/types.h> #include<fcntl.h> #include<sys/stat.h> main() { int childpid,wfd,rfd; mknod(FIFO1,0666|S_IFIFO,0); mknod(FIFO2,0666|S_IFIFO,0); if (( childpid=fork())==-1) { printf("cannot fork"); } else if(childpid >0) {
if((mid=msgget(1006,0))<0) { printf(\n Cant create Message Q); exit(1); } while((n=msgrcv(mid,&mesg,MAX,6,IPC_NOWAIT))>0) write(1,mesg.mtext,n); count++; if((n= = -1)&(count= =0)) printf(\n No Message Queue on Queue:%d,mid);
} 22. Write a C program that receives the messages (from the above message queue as specified in (21)) and displays them. Aim: To create a message queue DESCRIPTION: Message passing between processes are part of operating system, which are done through a message queue. Where messages are stored in kernel and are associated with message queue identifier (msqid). Processes read and write messages to an arbitrary queue in a way such that a process writes a message to a queue, exits and other process reads it at later time. ALGORITHM: Before defining a structure ipc_perm structure should be defined which is done by including following file. #include <sys/types.h> #include <sys/ipc.h> A structure of information is maintained by kernel, it should contain following. struct msqid_ds{ struct ipc_perm msg_perm; /*operation permission*/ struct msg *msg_first; /*ptr to first msg on queue*/ struct msg *msg_last; /*ptr to last msg on queue*/
Week 8
23. Write a C program to allow cooperating processes to lock a resource for exclusive use, using a) Semaphores b) flock or lockf system calls. PROGRAM: #include<stdio.h> #include<stdlib.h> #include<error.h> #include<sys/types.h> #include<sys/ipc.h> #include<sys/sem.h> int main(void) { key_t key; int semid; union semun arg; if((key==ftok("sem demo.c","j"))== -1) { perror("ftok");
Week 9
25. Write a C program that implements a producer-consumer system with two processes. (using Semaphores). Algorithm: 1. Start 2. create semaphore using semget( ) system call 3. if successful it returns positive value 4. create two new processes 5. first process will produce
Output: semaphore set created semaphore set id 327690 producer: 0 consumer:0 producer:1 consumer:1 26. Write client and server programs (using c) for interaction between server and client processes using Unix Domain sockets. Server.c #include <stdio.h> #include <sys/socket.h>
27. Write client and server programs (using c) for interaction between server and client processes using Internet Domain sockets. Server.c #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <time.h> int main(int argc, char *argv[]) { int listenfd = 0, connfd = 0; struct sockaddr_in serv_addr; char sendBuff[1025]; time_t ticks; listenfd = socket(AF_INET, SOCK_STREAM, 0); memset(&serv_addr, '0', sizeof(serv_addr)); memset(sendBuff, '0', sizeof(sendBuff)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(5000); bind(listenfd, (struct sockaddr*)&serv_addr, sizeof(serv_addr)); listen(listenfd, 10); while(1) { connfd = accept(listenfd, (struct sockaddr*)NULL, NULL);
key = ... size = ... shmflg) = ... if ((shmid = shmget (key, size, shmflg)) == -1) { perror("shmget: shmget failed"); exit(1); } else { (void) fprintf(stderr, "shmget: shmget returned %d\n", shmid); exit(0); } ... Controlling a Shared Memory Segment shmctl() is used to alter the permissions and other characteristics of a shared memory segment. It is prototyped as follows: int shmctl(int shmid, int cmd, struct shmid_ds *buf); The process must have an effective shmid of owner, creator or superuser to perform this command. The cmd argument is one of following control commands: SHM_LOCK -- Lock the specified shared memory segment in memory. The process must have the effective ID of superuser to perform this command. SHM_UNLOCK -- Unlock the shared memory segment. The process must have the effective ID of superuser to perform this command. IPC_STAT -- Return the status information contained in the control structure and place it in the buffer pointed to by buf. The process must have read permission on the segment to perform this command. IPC_SET -- Set the effective user and group identification and access permissions. The process must have an effective ID of owner, creator or superuser to perform this command. IPC_RMID -- Remove the shared memory segment. The buf is a sructure of type struct shmid_ds which is defined in <sys/shm.h> The following code illustrates shmctl(): #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> ... int cmd; /* command code for shmctl() */ int shmid; /* segment ID */
EXPERIMENT-1 Aim: To list all the categorical(or nominal) attributes and the real valued attributes using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: 1) Open the Weka GUI Chooser. 2) Select EXPLORER present in Applications. 3) Select Preprocess Tab. 4) Go to OPEN file and browse the file that is already stored in the system bank.csv. 5) Clicking on any attribute in the left panel will show the basic statistics on that selected attribute. SampleOutput:
Aim: To identify the rules with some of the important attributes by a) manually and b) Using Weka . Tools/ Apparatus: Weka mining tool.. Theory: Association rule mining is defined as: Let be a set of n binary attributes called items. Let be a set of transactions called the database. Each transaction in D has a unique transaction ID and contains a subset of the items in I. A rule is defined as an implication of the form X=>Y where X,Y C I and X Y= . The sets of items (for short itemsets) X and Y are called antecedent (left hand side or LHS) and consequent (righthandside or RHS) of the rule respectively. To illustrate the concepts, we use a small example from the supermarket domain. The set of items is I = {milk,bread,butter,beer} and a small database containing the items (1 codes presence and 0 absence of an item in a transaction) is shown in the table to the right. An example rule for the supermarket could be meaning that if milk and bread is bought, customers also buy butter. Note: this example is extremely small. In practical applications, a rule needs a support of several hundred transactions before it can be considered statistically significant, and datasets often contain thousands or millions of transactions. To select interesting rules from the set of all possible rules, constraints on various measures of significance and interest can be used. The bestknown constraints are minimum thresholds on support and confidence. The support supp(X) of an itemset X is defined as the proportion of transactions in the data set which contain the itemset. In the example database, the itemset {milk,bread} has a support of 2 / 5 = 0.4 since it occurs in 40% of all transactions (2 out of 5 transactions). The confidence of a rule is defined . For example, the rule has a confidence of 0.2 / 0.4 = 0.5 in the database, which means that for 50% of the transactions containing milk and bread the rule is correct. Confidence can be interpreted as an estimate of the probability P(Y | X), the probability of finding the RHS of the rule in transactions under the condition that these transactions also contain the LHS . ALGORITHM: Association rule mining is to find out association rules that satisfy the predefined minimum support and confidence from a given database. The problem is usually decomposed into two
Apriori Pseudocode Apriori (T,) L<{ Large 1itemsets that appear in more than transactions } K<2 while L(k1) C(k)<Generate( Lk 1) for transactions t T C(t)Subset(Ck,t) for candidates c C(t)
EXPERIMENT-3
Aim: To create a Decision tree by training data set using Weka mining tool. Tools/ Apparatus: Weka mining tool..
EXPERIMENT-4
Aim: To find the percentage of examples that are classified correctly by using the above created decision tree model? ie.. Testing on the training set. Tools/ Apparatus: Weka mining tool.. Theory: Naive Bayes classifier assumes that the presence (or absence) of a particular feature of a class is unrelated to the presence (or absence) of any other feature. For example, a fruit may be considered to be an apple if it is red, round, and about 4" in diameter. Even though these features depend on the existence of the other features, a naive Bayes classifier considers all of these properties to independently contribute to the probability that this fruit is an apple. An advantage of the naive Bayes classifier is that it requires a small amount of training data to estimate the parameters (means and variances of the variables) necessary for classification. Because independent variables are assumed, only the variances of the variables for each class need to be determined and not the entirecovariance matrix The naive Bayes probabilistic model : The probability model for a classifier is a conditional model P(C|F1 .................Fn) over a dependent class variable C with a small number of outcomes or classes, conditional on several feature variables F1 through Fn. The problem is that if the number of features n is large or when a feature can take on a large number of values, then basing such a model on probability tables is infeasible. We therefore reformulate the model to make it more tractable. Using Bayes' theorem, we write P(C|F1...............Fn)=[{p(C)p(F1..................Fn|C)}/p(F1,........Fn)]
In plain English the above equation can be written as Posterior= [(prior *likehood)/evidence] In practice we are only interested in the numerator of that fraction, since the denominator does not depend on C and the values of the features Fi are given, so that the denominator is effectively
Now the "naive" conditional independence assumptions come into play: assume that each feature Fi is conditionally independent of every other feature Fj for ji . This means that p(Fi|C,Fj)=p(Fi|C) and so the joint model can be expressed as p(C,F1,.......Fn)=p(C)p(F1|C)p(F2|C)........... =p(C) p(Fi|C) This means that under the above independence assumptions, the conditional distribution over the class variable C can be expressed like this: p(C|F1..........Fn)= p(C) p(Fi|C) Z where Z is a scaling factor dependent only on F1.........Fn, i.e., a constant if the values of the feature variables are known. Models of this form are much more manageable, since they factor into a so called class prior p(C) and independent probability distributions p(Fi|C). If there are k classes and if a model for eachp(Fi| C=c) can be expressed in terms of r parameters, then the corresponding naive Bayes model has (k 1) + n r k parameters. In practice, often k = 2 (binary classification) and r = 1 (Bernoulli variables as features) are common, and so the total number of parameters of the naive Bayes model is 2n + 1, where n is the number of binary features used for prediction P(h/D)= P(D/h) P(h) P(D) P(h) : Prior probability of hypothesis h P(D) : Prior probability of training data D P(h/D) : Probability of h given D P(D/h) : Probability of D given h Nave Bayes Classifier : Derivation
Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) Go to Classify tab. 7) Choose Classifier Tree 8) Select NBTree i.e., Navie Baysiean tree.
Sample output:
Correctly Classified Instances Incorrectly Classified Instances Kappa statistic Mean absolute error Root mean squared error Relative absolute error Root relative squared error Total Number of Instances
554 46
92.3333 % 7.6667 %
TP Rate FP Rate Precision Recall F-Measure ROC Area Class 0.894 0.948 0.052 0.106 0.935 0.914 0.081 0.894 0.948 0.924 0.914 0.931 0.923 0.936 YES 0.936 NO 0.923 0.936
EXPERIMENT-5
Aim: To Is testing a good idea. Tools/ Apparatus: Weka Mining tool Procedure:
1) In Test options, select the Supplied test set radio button 2) click Set
3) Choose the file which contains records that were not in the training set we used to create the model.
4) click Start(WEKA will run this test data set through the model we already created. )
5) Compare the output results with that of the 4th experiment Sample output:
EXPERIMENT-6
Aim: To create a Decision tree by cross validation training data set using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Theory: Decision tree learning, used in data mining and machine learning, uses a decision tree as a predictive model which maps observations about an item to conclusions about the item's target value In these tree structures, leaves represent classifications and branches represent conjunctions of features that lead to those classifications. In decision analysis, a decision tree can be used to visually and explicitly represent decisions and decision making. In data mining, a decision tree
Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) Go to Classify tab. 7) Choose Classifier Tree 8) Select J48 9) Select Test options Cross-validation. 10) Set Folds Ex:10
539 61
89.8333 % 10.1667 %
0.7942
TP Rate FP Rate Precision Recall F-Measure ROC Area Class 0.861 0.929 0.071 0.139 0.911 0.889 0.108 0.861 0.929 0.899 0.886 0.909 0.898 0.883 YES 0.883 NO 0.898 0.883
Aim: Delete one attribute from GUI Explorer and see the effect using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) In the "Filter" panel, click on the "Choose" button. This will show a popup window with list available filters. 7) Select weka.filters.unsupervised.attribute.Remove 8) Next, click on text box immediately to the right of the "Choose" button 9) In the resulting dialog box enter the index of the attribute to be filtered out (Make sure that the "invertSelection" option is set to false ) 10) Then click "OK" . Now, in the filter box you will see "Remove -R 1" 11) Click the "Apply" button to apply this filter to the data. This will remove the "id" attribute and create a new working relation 12) To save the new working relation as an ARFF file, click on save button in the top panel. 13) Go to OPEN file and browse the file that is newly saved (attribute deleted file) 14) Go to Classify tab. 15) Choose Classifier Tree 16) Select j48 tree 17) Select Test options Use training set 18) if need select attribute. 19) now Start weka.
Sample output:
EXPERIMENT-8
Aim: Select some attributes from GUI Explorer and perform classification and see the effect using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) select some of the attributes from attributes list which are to be removed. With this step only the attributes necessary for classification are left in the attributes panel. 7) The go to Classify tab. 8) Choose Classifier Tree 9) Select j48 10) Select Test options Use training set 11) if need select attribute. 12) now Start weka. 13)now we can see the output details in the Classifier output. 14) right click on the result list and select visualize tree option . 15)Compare the output results with that of the 4th experiment 16) check whether the accuracy increased or decreased? 17)check whether removing these attributes have any significant effect.
EXPERIMENT-9
Aim: To create a Decision tree by cross validation training data set by changing the cost matrix in Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) Go to Classify tab. 7) Choose Classifier Tree 8) Select j48 9) Select Test options Training set. 10)Click on more options. 11)Select cost sensitive evaluation and click on set button 12)Set the matrix values and click on resize. Then close the window. 13)Click Ok 14)Click start. 15) we can see the output details in the Classifier output 16) Select Test options Cross-validation. 17) Set Folds Ex:10 18) if need select attribute.
Sample output:
EXPERIMENT-10
Aim: Is small rule better or long rule check the bias,by training data set using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: This will be based on the attribute set, and the requirement of relationship among attribute we want to study. This can be viewed based on the database and user requirement.
EXPERIMENT-11
Aim: To create a Decision tree by using Prune mode and Reduced error Pruning and show accuracy for cross validation trained data set using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Theory :
Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) select some of the attributes from attributes list 7) Go to Classify tab. 8) Choose Classifier Tree 9) Select NBTree i.e., Navie Baysiean tree. 10) Select Test options Use training set
Sample output:
EXPERIMENT-12
Aim: To compare OneR classifier which uses single attribute and rule with J48 and PART classifiers, by training data set using Weka mining tool. Tools/ Apparatus: Weka mining tool.. Procedure: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) select some of the attributes from attributes list 7) Go to Classify tab.
Procedure for OneR: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) select some of the attributes from attributes list 7) Go to Classify tab. 8) Choose Classifier Rules 9) Select OneR . 10) Select Test options Use training set 11) if need select attribute. 12) now Start weka. 13)now we can see the output details in the Classifier output.
Procedure for PART: 1) Given the Bank database for mining. 2) Use the Weka GUI Chooser. 3) Select EXPLORER present in Applications. 4) Select Preprocess Tab. 5) Go to OPEN file and browse the file that is already stored in the system bank.csv. 6) select some of the attributes from attributes list 7) Go to Classify tab. 8) Choose Classifier Rules 9) Select PART . 10) Select Test options Use training set 11) if need select attribute. 12) now Start weka. 13)now we can see the output details in the Classifier output.
Attribute relevance with respect to the class relevant attribute (science) IF accounting=1 THEN class=A (Error=0, Coverage = 7 instance) IF accounting=0 THEN class=B (Error=4/13, Coverage = 13 instances)
One R
PART