Question: Implement in C + + 1 1 a Naive Bayes Classifier that classifies individuals as Democrats or Republicans, using the 1 6 attributes and two
Implement in C a Naive Bayes Classifier that classifies individuals as Democrats or Republicans, using the attributes and two classes from the Congressional Voting Records dataset
Some of the features contain the value which typically represents a missing value. In this case, the data explicitly states that this symbol means neither "yes" nor noIt represents a third value, "abstained." Solve the task in two ways: first, by treating the value as the third option abstainedand second, by filling the missing values with an approach of your choice, and justify why you selected that approach. Analyze the results.
For the Naive Bayes classifier, zero probabilities may occur, leading to inaccurate classification. To address this issue, apply the appropriate solutions: "Laplace Smoothing" and logarithms. When applying Laplace smoothing, test with different values of the parameter which indicates the degree of smoothing. Analyze the results.
To test the algorithm, split the data into training and testing sets in an :ratio ensuring the data is shuffled first. The split should be stratified to preserve the class distribution DemocratsRepublicansin the resulting training and test sets.
The input should accept two possible values: and :
means to process the data by treating the symbols as a third value, "abstained."
means to fill the missing values marked with using an approach of your choice.
The output should display the accuracy of the model on the training set trained and tested on itthe accuracy and standard deviation of the model during fold crossvalidation on the training set, and the accuracy of the model on the test set.
Example input:
Example output:
Train Set Accuracy:
Accuracy:
Fold CrossValidation Results:
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Accuracy Fold :
Average Accuracy:
Standard Deviation:
Test Set Accuracy:
Accuracy:
For solving the task, you are allowed to use data structures such as DataFrame.
It is required to implement the algorithm from scratch! The use of external libraries is not allowed, except for standard libraries and those specifically related to data structures needed for implementing the algorithm. Please ensure that your solution reflects your understanding of the algorithm and does not rely on preexisting implementations.
Congressional Voting Records dataset is a zipped folder that contains:
housevotesdata file, with the following information format:
republican,nynyyynnnyyyyny
republican,nynyyynnnynyyyn
housevotesnames file, with the following information format:
Title: United States Congressional Voting Records Database
Source Information:
a Source: Congressional Quarterly Almanac, th Congress,
nd session Volume XL: Congressional Quarterly Inc.
Washington, DC
b Donor: Jeff Schlimmer JeffreySchlimmer@agpcscmu.edu
c Date: April
Past Usage
Publications
Schlimmer, J C Concept acquisition through
representational adjustment. Doctoral dissertation, Department of
Information and Computer Science, University of California, Irvine, CA
Results: about accuracy appears to be STAGGER's asymptote
Predicted attribute: party affiliation classes
Relevant Information:
This data set includes votes for each of the US House of
Representatives Congressmen on the key votes identified by the
CQA. The CQA lists nine different types of votes: voted for, paired
for, and announced for these three simplified to yea voted
against, paired against, and announced against these three
simplified to nay voted present, voted present to avoid conflict
of interest, and did not vote or otherwise make a position known
these three simplified to an unknown disposition
Number of Instances: democrats, republicans
Number of Attributes: class name all Boolean valued
Attribute Information:
Class Name: democrat republican
handicappedinfants: yn
waterprojectcostsharing: yn
adoptionofthebudgetresolution: yn
physicianfeefreeze: yn
elsalvadoraid: yn
religiousgroupsinschools: yn
antisatellitetestban: yn
aidtonicaraguancontras: yn
mxmissile: yn
index file:
Index of votingrecords
Dec Index
Jun housevotesnames
May housevotesdata
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
