code:
from __future__ import with_statement
#COUNT FOR HEALTHY PATIENTS
goodCnt=0;
att1=0
att2=0
att3=0
att4=0
att5=0
att6=0
#COUNT FOR ILL PATIENTS
badCount=0;
attA=0
attB=0
attC=0
attD=0
attE=0
attF=0
attG=0
#READING TRAINING DATA SET
filen=raw_input("enter the name of the training set file:")
with open(filen,'rb') as f:
for temp in f:
st=temp.split(",")
#HEALTHY PATIENTS
if float(st[6])==0:
att1+=(float(st[0]))
att2+=(float(st[1]))
att3+=(float(st[2]))
att4+=(float(st[3]))
att5+=(float(st[4]))
att6+=(float(st[5]))
goodCnt+=1
#ILL PATIENTS
else:
attA+=(float(st[0]))
attB+=(float(st[1]))
attC+=(float(st[2]))
attD+=(float(st[3]))
attE+=(float(st[4]))
attF+=(float(st[5]))
badCount+=1
#HEALTHY PATIENTS AVERAGE
Hatt1=att1/goodCnt
Hatt2=att2/goodCnt
Hatt3=att3/goodCnt
Hatt4=att4/goodCnt
Hatt5=att5/goodCnt
Hatt6=att6/goodCnt
#ILL PATIENTS AVERAGE
HattA=attA/badCount
HattB=attB/badCount
HattC=attC/badCount
HattD=attD/badCount
HattE=attE/badCount
HattF=attF/badCount
#PRINT HEALTHY AND ILL PATIENTS AVERAGE
print "healthy patients' averages:"
print Hatt1,Hatt2,Hatt3,Hatt4,Hatt5,Hatt6
print "Ill patients' averages:"
print HattA,HattB,HattC,HattD,HattE,HattF
#FIND SEPARATOR VALUES
satt1=(Hatt1+HattA)/2
satt2=(Hatt2+HattB)/2
satt3=(Hatt3+HattC)/2
satt4=(Hatt4+HattD)/2
satt5=(Hatt5+HattE)/2
satt6=(Hatt6+HattF)/2
#DISPLAY SEPARATOR VALUES
print "Separator values:"
print satt1,satt2,satt3,satt4,satt5,satt6
#FINDING ACCURACY
ng=0;
nt=0
with open(filen,'rb') as f:
for temp in f:
st=temp.split(",")
if float(st[6])==0:
ng+=1
nt=nt+1
else:
nt+=1
Accuracy=(ng/goodCnt)
print "Accuracy:"
print Accuracy
#DIAGNOSING TEST DATA SET
infilename=raw_input("enter the name of the test set file:")
outfile=raw_input("Enter the name of the output file:")
ot=open(outfile,'wb')
with open(infilename,'rb') as f:
for temp in f:
st=temp.split(",")
att1=(int(st[0]))
att2=(float(st[1]))
att3=(float(st[2]))
att4=(float(st[3]))
att5=(float(st[4]))
att6=(float(st[5]))
att7=(float(st[6]))
if((att2>satt1) or (att3>satt2) or (att4>satt3) or
(att5>satt4) or (att6>satt5) or (att7>satt6)):
st=str(att1)+",Ill"
else:
st=str(att1)+",Healthy"
ot.write(st) #WRITING TO FILE
ot.write(" ")
ot.close()#CLOSE OUTPUT FILE
print "Done"
Note: Due to time constraint i am not able to prepare the flowchart
Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a...
Write a program that will take input from a file of numbers of type double and output the average of the numbers in the file to the screen. Output the file name and average. Allow the user to process multiple files in one run. Part A use an array to hold the values read from the file modify your average function so that it receives an array as input parameter, averages values in an array and returns the average Part...
In this assignment, you will write a program in C++ which uses files and nested loops to create a file from the quiz grades entered by the user, then reads the grades from the file and calculates each student’s average grade and the average quiz grade for the class. Each student takes 6 quizzes (unknown number of students). Use a nested loop to write each student’s quiz grades to a file. Then read the data from the file in order...
Any little bit of information will be helpful. Thank you. Problem Statement You are to develop a program to read MotoGP rider information from an input file. You will need a MotoGpRider class whose instances will be used to store the statistics for a MotoGP motorcycle racer. The Rider class will have attributes for last name, first name, racing number, nation, motorcycle make, world championship points, world championship position, and an array that stores the number of top finishes (number...
Problem: You will write a program to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for 1901, the...
PLEASE DO THIS IN C#.Design and implement a program (name it ProcessGrades) that reads from the user four integer values between 0 and 100, representing grades. The program then, on separate lines, prints out the entered grades followed by the highest grade, lowest grade, and averages of all four grades. Format the outputs following the sample runs below. Sample run 1: You entered: 95, 80, 100, 70 Highest grade: 100 Lowest grade: 70 Average grade: 86.25
I need this in JAVA please: Design and implement a program (name it MinMaxAvg) that defines three methods as follows: Method max (int x, int y, int z) returns the maximum value of three integer values. Method min (int X, int y, int z) returns the minimum value of three integer values. Method average (int x, int y, int z) returns the average of three integer values. In the main method, test all three methods with different input value read...
HELP NEEDED in C++ (preferred) or any other language Write a simple program where you create an array of single byte characters. Make the array 100 bytes long. In C this would be an array of char. Use pointers and casting to put INTEGER (4 byte) and CHARACTER (1 byte) data into the array and pull it out. Make sure you can access both character and integer data at any location in the array. Read data from a text file....
Topics: list, file input/output (Python) You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing student...
In this assignment, you are to write a C++ program (using Visual C++ 2015) that reads training data in WEKA arff format and generates ID3 decision tree in a format similar to that of the tree generated by Weka ID3. Please note the following: Your algorithm will use the entire data set to generate the tree. You may assume that the attributes (a) are of nominal type (i.e., no numeric data), and (b) have no missing values. In general, the...
Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...