Linux programming and data mining lab manual(1), Essays (university) of Abnormal Psychology

sdsdsd - sdsdsd

Typology: Essays (university)

2015/2016

Uploaded on 09/19/2016

.21351
.21351 🇬🇧

4

(1)

5 documents

1 / 97

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LINUX PROGRAMMING AND DATA MINING
LAB MANUAL
JNTU World
www.alljntuworld.in
JNTU World
Downloaded From JNTU World (http://www.alljntuworld.in)
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61

Partial preview of the text

Download Linux programming and data mining lab manual(1) and more Essays (university) Abnormal Psychology in PDF only on Docsity!

LINUX PROGRAMMING AND DATA MINING

LAB MANUAL

JNTU World

COMPUTER SCIENCE AND ENGINEERING

Program Outcomes PO1 Engineering knowledge : Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems. PO2 Problem analysis : Identify, formulate, review research literature, and analyze complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences. PO3 Design/development of solutions : Design solutions for complex engineering problems and design system components or processes that meet the specified needs with appropriate consideration for the public health and safety, and the cultural, societal, and environmental considerations. PO4 Conduct investigations of complex problems : Use research-based knowledge and research methods including design of experiments, analysis and interpretation of data, and synthesis of the information to provide valid conclusions. PO5 Modern tool usage : Create, select, and apply appropriate techniques, resources, and modern engineering and IT tools including prediction and modeling to complex engineering activities with an understanding of the limitations. PO6 The engineer and society : Apply reasoning informed by the contextual knowledge to assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant to the professional engineering practice. PO7 Environment and sustainability : Understand the impact of the professional engineering solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for sustainable development. PO8 Ethics : Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice. PO9 Individual and team work : Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings. PO10 Communication : Communicate effectively on complex engineering activities with the engineering community and with society at large, such as, being able to comprehend and write effective reports and design documentation, make effective presentations, and give and receive clear instructions. PO11 Project management and finance : Demonstrate knowledge and understanding of the engineering and management principles and apply these to one’s own work, as a member and leader in a team, to manage projects and in multidisciplinary environments. PO12 Life-long learning : Recognize the need for, and have the preparation and ability to engage in independent and life-long learning in the broadest context of technological change. Program Specific Outcomes PSO1 Professional Skills: The ability to research, understand and implement computer programs in the areas related to algorithms, system software, multimedia, web design, big data analytics, and networking for efficient analysis and design of computer-based systems of varying complexity. PSO2 Problem-Solving Skills: The ability to apply standard practices and strategies in software project development using open-ended programming environments to deliver a quality product for business success. PSO3 Successful Career and Entrepreneurship: The ability to employ modern computer languages, environments, and platforms in creating innovative career paths, to be an entrepreneur, and a zest for higher studies.

JNTU World

S. No. List of Experiments Page No.

16 Write a C program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen.

17 Write a C program to create a Zombie process. 28 18 Write a C program that illustrates how an orphan is created. 29 19 Write a C program that illustrates how to execute two commands concurrently with a command pipe. Ex: - ls – l | sort

20 Write C programs that illustrate communication between two unrelated processes using named pipe.

21 Write a C program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers.

22 Write a C program that receives the messages (from the above message queue as specified in (21)) and displays them.

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.

24 Write a C program that illustrates suspending and resuming processes using signals 39 25 Write a C program that implements a producer-consumer system with two processes.

26 Write client and server programs (using c) for interaction between server and client processes using Unix Domain sockets. (Using Semaphores).

27 Write client and server programs (using c) for interaction between server and client processes using Internet Domain sockets.

28 Write a C program that illustrates two processes communicating using shared memory.

DATA MINING

1 List all the categorical (or nominal) attributes and the real-valued attributes separately.

2 What attributes do you think might be crucial in making the credit assessment? Come up with some simple rules in plain English using your selected attributes.

3 ***** What attributes do you think might be crucial in making the bank assessment? 56 4 One type of model that you can create is a Decision Tree - train a Decision Tree using the complete dataset as the training data. Report the model obtained after training.

5 Suppose you use your above model trained on the complete dataset, and classify credit good/bad for each of the examples in the dataset. What % of examples can you classify correctly? (This is also called testing on the training set) Why do you think you cannot get 100 % training accuracy?

6 ***** Find out the correctly classified instances, root mean squared error, kappa statistics, and mean absolute error for weather data set?

7 Is testing on the training set as you did above a good idea? Why or Why not? 68 8 One approach for solving the problem encountered in the previous question is using cross-validation? Describe what is cross - validation briefly. Train a Decision Tree again using cross - validation and report your results. Does your accuracy increase/decrease? Why?

JNTU World

S. No. List of Experiments Page No.

9 Check to see if the data shows a bias against "foreign workers" (attribute 20), or "personal

  • status" (attribute 9). One way to do this (perhaps rather simple minded) is to remove these attributes from the dataset and see if the decision tree created in those cases is significantly different from the full dataset case which you have already done. To remove an attribute you can use the preprocess tab in Weka's GUI Explorer. Did removing these attributes have any significant effect? Discuss.

10 ***** Load the „weather.arff‟ dataset in Weka and run the ID3 classification algorithm. What problem do you have and what is the solution?

11 Another question might be, do you really need to input so many attributes to get good results? Maybe only a few would do. For example, you could try just having attributes 2, 3, 5, 7, 10, 17 (and 21, the class attribute (naturally)). Try out some combinations. (You had removed two attributes in problem 7. Remember to reload the arff data file to get all the attributes initially before you start selecting the ones you want.)

12 Sometimes, the cost of rejecting an applicant who actually has a good credit (case

  1. might be higher than accepting an applicant who has bad credit (case 2). Instead of counting the misclassifications equally in both cases, give a higher cost to the first case (say cost 5) and lower cost to the second case. You can do this by using a cost matrix in Weka. Train your Decision Tree again and report the Decision Tree and cross - validation results. Are they significantly different from results obtained in problem 6 (using equal cost)?

13 Do you think it is a good idea to prefer simple decision trees instead of having long complex decision trees? How does the complexity of a Decision Tree relate to the bias of the model?

14 ***** Run the J48 and 1Bk classifiers using-the cross-validation strategy with various fold levels. Compare the accuracy results. Holdout strategy with three percentage levels. Compare the accuracy results.

15 You can make your Decision Trees simpler by pruning the nodes. one approach is to use Reduced Error Pruning - Explain this idea briefly. Try reduced error pruning for training your Decision Trees using cross - validation (you can do this in Weka) and report the Decision Tree you obtain? Also, report your accuracy using the pruned model. Does your accuracy increase?

16 (Extra Credit): How can you convert a Decision Trees into "if – then - else rules". Make up your own small Decision Tree consisting of 2 - 3 levels and convert it into a set of rules. There also exist different classifiers that output the model in the form of rules - one such classifier in Weka is rules. PART, train this model and report the set of rules obtained. Sometimes just one attribute can be good enough in making the decision, yes, just one! Can you predict what attribute that might be in this dataset? OneR classifier uses a single attribute to make decisions (it chooses the attribute based on minimum error). Report the rule obtained by training a one R classifier. Rank the performance of j48, PART and oneR.

17 ***** Run J48 and Naïve Bayes classifiers on the following datasets and determine the accuracy: 1.vehicle.arff 2.kr-vs-kp.arff 3.glass.arff 4.wave-form-5000.arff On which datasets does the Naïve Bayes perform better?

***** Content beyond the university prescribed syllabi

JNTU World

Exp. No. Experiment

Program Outcomes Attained

Program Specific Outcomes Attained 11 Implement in C the following UNIX commands using System calls a) cat b) ls c) mv PO1, PO2^ PSO 12 Write a program that takes one or more file/directory names as command line input and reports the following information on the file. a) File type b) Number of links c) Time of last access d) Read Write and Execute permissions

PO1, PO2 PSO

13 Write a C program to emulate the UNIX ls – l command. (^) PO1 PSO 14 Write a C program to list for every file in a directory, its inode number and file name. PO1^ PSO 15 Write a C program that demonstrates redirection of standard output to a file.Ex: ls > f1. PO1^ PSO 16 Write a C program to create a child process and allow the parent to display “parent” and the child to display “child” on the screen. PO1^ PSO 17 Write a C program to create a Zombie process. (^) PO1 PSO 18 Write a C program that illustrates how an orphan is created. (^) PO1 PSO 19 Write a C program that illustrates how to execute two commands concurrently with a command pipe. Ex: - ls – l | sort PO1^ PSO 20 Write C programs that illustrate communication between two unrelated processes using named pipe. PO1^ PSO 21 Write a C program to create a message queue with read and write permissions to write 3 messages to it with different priority numbers. PO1^ PSO 22 Write a C program that receives the messages (from the above message queue as specified in (21)) and displays them. PO1^ PSO 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.

PO1, PO2 PSO

24 Write a C program that illustrates suspending and resuming processes using signals PO1, PO2^ PSO 25 Write a C program that implements a producer-consumer system with two processes.

PO1, PO2,
PO
PSO1,
PSO

26 Write client and server programs (using c) for interaction between server and client processes using Unix Domain sockets. (Using Semaphores).

PO1, PO2,
PO3, PO
PSO1,
PSO

27 Write client and server programs (using c) for interaction between server and client processes using Internet Domain sockets.

PO1, PO2,
PO3, PO
PSO1,
PSO

28 Write a C program that illustrates two processes communicating using shared memory.

PO1, PO2,
PO3, PO
PSO1,
PSO
DATA MINING

18 List all the categorical (or nominal) attributes and the real-valued attributes separately. PO1, PO2^ PSO 19 What attributes do you think might be crucial in making the credit assessment? Come up with some simple rules in plain English using your selected attributes.

PO1, PO2 PSO1, PSO

JNTU World

Exp. No. Experiment

Program Outcomes Attained

Program Specific Outcomes Attained 20 ***** What attributes do you think might be crucial in making the bank assessment?

PO1, PO2,
PO
PSO1,
PSO

21 One type of model that you can create is a Decision Tree - train a Decision Tree using the complete dataset as the training data. Report the model obtained after training.

PO1, PO2,
PO5 PSO

22 Suppose you use your above model trained on the complete dataset, and classify credit good/bad for each of the examples in the dataset. What % of examples can you classify correctly? (This is also called testing on the training set) Why do you think you cannot get 100 % training accuracy?

PO1, PO2 PSO1, PSO

23 ***** Find out the correctly classified instances, root mean squared error, kappa statistics, and mean absolute error for weather data set?

PO1, PO2,
PO5 PSO

24 Is testing on the training set as you did above a good idea? Why or Why not?

PO1, PO2,
PO5, PO12 PSO

25 One approach for solving the problem encountered in the previous question is using cross-validation? Describe what is cross - validation briefly. Train a Decision Tree again using cross - validation and report your results. Does your accuracy increase/decrease? Why?

PO1, PO2,
PO5 PSO

26 Check to see if the data shows a bias against "foreign workers" (attribute 20), or "personal

  • status" (attribute 9). One way to do this (perhaps rather simple minded) is to remove these attributes from the dataset and see if the decision tree created in those cases is significantly different from the full dataset case which you have already done. To remove an attribute you can use the preprocess tab in Weka's GUI Explorer. Did removing these attributes have any significant effect? Discuss.
PO1, PO2,
PO4, PO5 PSO

27 ***** Load the „weather.arff‟ dataset in Weka and run the ID3 classification algorithm. What problem do you have and what is the solution?

PO1, PO2,
PO
PSO1,
PSO

28 Another question might be, do you really need to input so many attributes to get good results? Maybe only a few would do. For example, you could try just having attributes 2, 3, 5, 7, 10, 17 (and 21, the class attribute (naturally)). Try out some combinations. (You had removed two attributes in problem 7. Remember to reload the arff data file to get all the attributes initially before you start selecting the ones you want.)

PO1, PO2,
PO4, PO12 PSO

29 Sometimes, the cost of rejecting an applicant who actually has a good credit (case 1) might be higher than accepting an applicant who has bad credit (case 2). Instead of counting the misclassifications equally in both cases, give a higher cost to the first case (say cost 5) and lower cost to the second case. You can do this by using a cost matrix in Weka. Train your Decision Tree again and report the Decision Tree and cross - validation results. Are they significantly different from results obtained in problem 6 (using equal cost)?

PO1, PO2,
PO5, PO
PSO1,
PSO

30 Do you think it is a good idea to prefer simple decision trees instead of having long complex decision trees? How does the complexity of a Decision Tree relate to the bias of the model?

PO1, PO2,
PO
PSO1,
PSO

31 ***** Run the J48 and 1Bk classifiers using-the cross-validation strategy with various fold levels. Compare the accuracy results. Holdout strategy with three percentage levels. Compare the accuracy results.

PO1, PO2,
PO4, PO
PSO1,

JNTU World PSO 2

LINUX PROGRAMMING AND DATA MINING LABORATORY

OBJECTIVE:

The Linux programming laboratory course covers major methods of Inter Process Communication (IPC), which is the basis of all client / server applications under Linux, Linux Utilities, working with the Bourne again shell (bash), files, process and signals. There will be extensive programming exercises in shell scripts. It also emphasizes various concepts in multithreaded programming and socket programming.

Data mining tools allow predicting future trends and behaviors, allowing businesses to make proactive, knowledge-driven decisions. The data mining laboratory course is designed to exercise the data mining techniques such as classification, clustering, pattern mining etc with varied datasets and dynamic parameters. Weka data mining tool is used for the purpose of acquainting the students with the basic environment of the data mining tools.

OUTCOMES:

Upon the completion of Linux Programming and Data Mining practical course, the student will be able to:

  1. Understand and implement basic system functionalities of Linux operating system.
  2. Write shell scripts to automate different tasks.
  3. Demonstrate Inter process Communication techniques.
  4. Design and implement advanced features such as threads, IPC, pipes, FIFOs.
  5. Demonstrate client server technology using socket programming.
  6. Understand synchronized programs using shared memory,
  7. Implement and manage client server technology using TCP and UDP.
  8. Learn to build a data warehouse and query it using open source tools.
  9. Learn to execute data mining tasks using a data mining toolkit (such as WEKA) and visualize the results.
  10. Demonstrate the working of algorithms for data mining tasks such association rule mining, classification, clustering and regression.

JNTU World

LINUX PROGRAMMING

JNTU World

echo - e "\033[32m Hello World"

Green color

echo - e "\033[33m Hello World"

See remains on screen

echo - e "\033[34m Hello World" echo - e "\033[35m Hello World" echo - e "\033[36m Hello World" echo - e - n "\033[0m "

print back to normal

echo - e "\033[41m Hello World" echo - e "\033[42m Hello World" echo - e "\033[43m Hello World" echo - e "\033[44m Hello World" echo - e "\033[45m Hello World" echo - e "\033[46m Hello World" echo - e "\033[0m Hello World"

Print back to normal

1.5 PRE-LAB QUESTIONS

  1. Define shell script? What is the difference between shell and kernel.
  2. Name few file handling commands present in unix.

1.6 LAB ASSIGNMENT

  1. Write a shell script to count number of words present in a file without using commands.
  2. Write a menu driven shell script to execute a command as 1.for ls ,2 for grep and 3 for cat.

1.7 POST-LAB QUESTIONS

  1. What is the purpose of case statement?
  2. What the difference between break and exit statement?

JNTU World

EXPERIMENT 2

2.1 OBJECTIVE

a) Write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it.

b) *Illustrate by writing script using for loop to print the following patterns?

2.2 RESOURCE/REQUIREMENTS

Linux operating system ,vi-editor, shell-interpreter

2.3 PROGRAM LOGIC Read file name from command line arguments and display lines inverse of specified word.

2.4.a DESCRIPTION / PROCEDURE if [ $# - ne 0 ] then echo enter the word read word for fname in $* do if [ - f $fname ] then echo the given input filename is:$fname grep - v "$word" $fname else echo its not a file fi done else echo "enter atleast one argument as input" fi

INPUT: sh prog2.sh 3.sh

enter the word

echo

OUTPUT:

The given input filename is : 3.sh It displays all the lines other than pattern matching

2.4.b.i DESCRIPTION / PROCEDURE

do the following for loop

echo "Stars"

outer loop

for (( i=1; i<=5; i++ )) do #inner loop

for (( j=1; j<=i; j++ )) do echo - n " *"

JNTU World

EXPERIMENT 3

3.1 OBJECTIVE

a) 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.

b) Illustrate to redirect the standard input (stdin) and the standard output (stdout) of a process, so that

scanf () reads from the pipe and printf () writes into the pipe?

3.2 RESOURCE/REQUIREMENTS Linux operating system ,vi-editor, shell-interpreter

3.3 PROGRAM LOGIC Read a list of files from current directory and display the file names to output stream whose files has read, write, execute permissions.

3.4.a DESCRIPTION / PROCEDURE

echo "List of Files which have Read, Write and Execute Permissions in Current Directory"

for file in *

do

if [ - r $file - a - w $file - a - x $file ]

then

echo $file

fi

done

INPUT:

sh prog3.sh OUTPUT:

List of Files which have Read, Write and Execute Permissions in Current Directory

pp2.txt

3.4.b DESCRIPTION / PROCEDURE #include #include #include main() { int fd[2];int n=0, i; pipe(fd); if (fork() == 0) { /* create Child process / close(1) ; dup(fd[1]) ; close(fd[0]); / try not read from the pipe in this example.So close fd[0]. / for (i=0; i < 10; i++) {printf("%d\n",n); / Now that stdout has been redirected, printf automatically writes into the pipe. / n++; } } else {/ Parent process /close(0) ; dup(fd[0]) ; / Redirect the stdin of this process to the pipe/ close(fd[1]); / will not write into the pipe.So we close fd[1]. */

for (i=0; i < 10; i++) {scanf("%d",&n); /* Now that stdin has been redirected, scanf automatically reads from the pipe. / printf("n = %d\n",n); / try stdout of this has not changed. So this will be shown in the terminal. */ sleep(1);

JNTU World

3.5 PRE-LAB QUESTIONS
  1. What is the difference between $* and $@.
  2. How to read a variable ,assign ,and access it

3.6 LAB ASSIGNMENT

  1. Read a file name from command line and check it‟s a file or not.
  2. Read a file name from command line and check if it read and write permission or not.

3.7 POST-LAB QUESTIONS

  1. How to check if file is existing, it has read, write and execution permission.

JNTU World

return 1; } if (childpid == 0) { printf("Child 1: I inherited my parent's pid as %d.\n", mypid); mypid = getpid(); printf("Child 1: getppid() tells my parent is %d. My own pid instead is %d.\n", getppid(), mypid); /* forks another child / childpid = fork(); if ( childpid == - 1 ) { perror("Cannot proceed. fork() error"); return 1; } if (childpid == 0) { / this is the child of the first child, thus "Child 2" / printf("Child 2: I hinerited my parent's PID as %d.\n", mypid); mypid = getpid(); printf("Child 2: getppid() tells my parent is %d. My own pid instead is %d.\n", getppid(), mypid); childpid = fork(); if ( childpid == - 1 ) { perror("Cannot proceed. fork() error"); return 1; } if (childpid == 0) { / "Child 3" sleeps 30 seconds then terminates 12, hopefully before its parent "Child 2" / printf("Child 3: I hinerited my parent's PID as %d.\n", mypid); mypid = getpid(); printf("Child 3: getppid() tells my parent is %d. My own pid instead is %d.\n", getppid(), mypid); sleep(30); return 12; } else / the parent "Child 2" suddendly returns 15 / return 15; } else { / this is still "Child 1", which waits for its child to exit */ while ( waitpid(childpid, &status, WNOHANG) == 0 ) sleep(1); if ( WIFEXITED(status) ) printf("Child1: Child 2 exited with exit status %d.\n", WEXITSTATUS(status)); else printf("Child 1: child has not terminated correctly.\n"); }

} else { /* then we're the parent process, "Parent" / printf("Parent: fork() went ok. My child's PID is %d\n", childpid); / wait for the child to terminate and report about that */ wait(&status); if ( WIFEXITED(status) ) printf("Parent: child has exited with status %d.\n", WEXITSTATUS(status)); else printf("Parent: child has not terminated normally.\n"); } return 0; }

4.5 PRE-LAB QUESTIONS

  1. How to write arithmetic multiplication operator in shell.
  2. Write down the syntax for nested if statement.

JNTU World

4.6 LAB ASSIGNMENT
  1. Write a shell script to count number of txt,c and shell programs present in current directory.
  2. Write a shell script to count number of only files present in current directory.

4.7 POST-LAB QUESTIONS

  1. What is means by relation operator , name any three relation operators present in shell.
  2. What is meant by logic operator, and Explain about each operator.

JNTU World