% 1. Title: 1984 United States Congressional Voting Records Database % % 2. Source Information: % (a) Source: Congressional Quarterly Almanac, 98th Congress, % XXXXXXXXXX2nd session 1984, Volume XL:...

1 answer below ยป
Need help with this assignment is short


% 1. Title: 1984 United States Congressional Voting Records Database % % 2. Source Information: % (a) Source: Congressional Quarterly Almanac, 98th Congress, % 2nd session 1984, Volume XL: Congressional Quarterly Inc. % Washington, D.C., 1985. % (b) Donor: Jeff Schlimmer ([email protected]) % (c) Date: 27 April 1987 % % 3. Past Usage % - Publications % 1. Schlimmer, J. C. (1987). Concept acquisition through % representational adjustment. Doctoral dissertation, Department of % Information and Computer Science, University of California, Irvine, CA. % -- Results: about 90%-95% accuracy appears to be STAGGER's asymptote % - Predicted attribute: party affiliation (2 classes) % % 4. Relevant Information: % This data set includes votes for each of the U.S. House of % Representatives Congressmen on the 16 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). % % 5. Number of Instances: 435 (267 democrats, 168 republicans) % % 6. Number of Attributes: 16 + class name = 17 (all Boolean valued) % % 7. Attribute Information: % 1. Class Name: 2 (democrat, republican) % 2. handicapped-infants: 2 (y,n) % 3. water-project-cost-sharing: 2 (y,n) % 4. adoption-of-the-budget-resolution: 2 (y,n) % 5. physician-fee-freeze: 2 (y,n) % 6. el-salvador-aid: 2 (y,n) % 7. religious-groups-in-schools: 2 (y,n) % 8. anti-satellite-test-ban: 2 (y,n) % 9. aid-to-nicaraguan-contras: 2 (y,n) % 10. mx-missile: 2 (y,n) % 11. immigration: 2 (y,n) % 12. synfuels-corporation-cutback: 2 (y,n) % 13. education-spending: 2 (y,n) % 14. superfund-right-to-sue: 2 (y,n) % 15. crime: 2 (y,n) % 16. duty-free-exports: 2 (y,n) % 17. export-administration-act-south-africa: 2 (y,n) % % 8. Missing Attribute Values: Denoted by "?" % % NOTE: It is important to recognize that "?" in this database does % not mean that the value of the attribute is unknown. It % means simply, that the value is not "yea" or "nay" (see % "Relevant Information" section above). % % Attribute: #Missing Values: % 1: 0 % 2: 0 % 3: 12 % 4: 48 % 5: 11 % 6: 11 % 7: 15 % 8: 11 % 9: 14 % 10: 15 % 11: 22 % 12: 7 % 13: 21 % 14: 31 % 15: 25 % 16: 17 % 17: 28 % % 9. Class Distribution: (2 classes) % 1. 45.2 percent are democrat % 2. 54.8 percent are republican % % Class predictiveness and predictability: Pr(C|A=V) and Pr(A=V|C) % Attribute 1: (A = handicapped-infants) % 0.91; 1.21 (C=democrat; V=y) % 0.09; 0.10 (C=republican; V=y) % 0.43; 0.38 (C=democrat; V=n) % 0.57; 0.41 (C=republican; V=n) % 0.75; 0.03 (C=democrat; V=?) % 0.25; 0.01 (C=republican; V=?) % Attribute 2: (A = water-project-cost-sharing) % 0.62; 0.45 (C=democrat; V=y) % 0.38; 0.23 (C=republican; V=y) % 0.62; 0.45 (C=democrat; V=n) % 0.38; 0.23 (C=republican; V=n) % 0.58; 0.10 (C=democrat; V=?) % 0.42; 0.06 (C=republican; V=?) % Attribute 3: (A = adoption-of-the-budget-resolution) % 0.91; 0.87 (C=democrat; V=y) % 0.09; 0.07 (C=republican; V=y) % 0.17; 0.11 (C=democrat; V=n) % 0.83; 0.44 (C=republican; V=n) % 0.64; 0.03 (C=democrat; V=?) % 0.36; 0.01 (C=republican; V=?) % Attribute 4: (A = physician-fee-freeze) % 0.08; 0.05 (C=democrat; V=y) % 0.92; 0.50 (C=republican; V=y) % 0.99; 0.92 (C=democrat; V=n) % 0.01; 0.01 (C=republican; V=n) % 0.73; 0.03 (C=democrat; V=?) % 0.27; 0.01 (C=republican; V=?) % Attribute 5: (A = el-salvador-aid) % 0.26; 0.21 (C=democrat; V=y) % 0.74; 0.48 (C=republican; V=y) % 0.96; 0.75 (C=democrat; V=n) % 0.04; 0.02 (C=republican; V=n) % 0.80; 0.04 (C=democrat; V=?) % 0.20; 0.01 (C=republican; V=?) % Attribute 6: (A = religious-groups-in-schools) % 0.45; 0.46 (C=democrat; V=y) % 0.55; 0.46 (C=republican; V=y) % 0.89; 0.51 (C=democrat; V=n) % 0.11; 0.05 (C=republican; V=n) % 0.82; 0.03 (C=democrat; V=?) % 0.18; 0.01 (C=republican; V=?) % Attribute 7: (A = anti-satellite-test-ban) % 0.84; 0.75 (C=democrat; V=y) % 0.16; 0.12 (C=republican; V=y) % 0.32; 0.22 (C=democrat; V=n) % 0.68; 0.38 (C=republican; V=n) % 0.57; 0.03 (C=democrat; V=?) % 0.43; 0.02 (C=republican; V=?) % Attribute 8: (A = aid-to-nicaraguan-contras) % 0.90; 0.82 (C=democrat; V=y) % 0.10; 0.07 (C=republican; V=y) % 0.25; 0.17 (C=democrat; V=n) % 0.75; 0.41 (C=republican; V=n) % 0.27; 0.01 (C=democrat; V=?) % 0.73; 0.03 (C=republican; V=?) % Attribute 9: (A = mx-missile) % 0.91; 0.70 (C=democrat; V=y) % 0.09; 0.06 (C=republican; V=y) % 0.29; 0.22 (C=democrat; V=n) % 0.71; 0.45 (C=republican; V=n) % 0.86; 0.07 (C=democrat; V=?) % 0.14; 0.01 (C=republican; V=?) % Attribute 10: (A = immigration) % 0.57; 0.46 (C=democrat; V=y) % 0.43; 0.28 (C=republican; V=y) % 0.66; 0.52 (C=democrat; V=n) % 0.34; 0.23 (C=republican; V=n) % 0.57; 0.01 (C=democrat; V=?) % 0.43; 0.01 (C=republican; V=?) % Attribute 11: (A = synfuels-corporation-cutback) % 0.86; 0.48 (C=democrat; V=y) % 0.14; 0.06 (C=republican; V=y) % 0.48; 0.47 (C=democrat; V=n) % 0.52; 0.43 (C=republican; V=n) % 0.57; 0.04 (C=democrat; V=?) % 0.43; 0.03 (C=republican; V=?) % Attribute 12: (A = education-spending) % 0.21; 0.13 (C=democrat; V=y) % 0.79; 0.42 (C=republican; V=y) % 0.91; 0.80 (C=democrat; V=n) % 0.09; 0.06 (C=republican; V=n) % 0.58; 0.07 (C=democrat; V=?) % 0.42; 0.04 (C=republican; V=?) % Attribute 13: (A = superfund-right-to-sue) % 0.35; 0.27 (C=democrat; V=y) % 0.65; 0.42 (C=republican; V=y) % 0.89; 0.67 (C=democrat; V=n) % 0.11; 0.07 (C=republican; V=n) % 0.60; 0.06 (C=democrat; V=?) % 0.40; 0.03 (C=republican; V=?) % Attribute 14: (A = crime) % 0.36; 0.34 (C=democrat; V=y) % 0.64; 0.49 (C=republican; V=y) % 0.98; 0.63 (C=democrat; V=n) % 0.02; 0.01 (C=republican; V=n) % 0.59; 0.04 (C=democrat; V=?) % 0.41; 0.02 (C=republican; V=?) % Attribute 15: (A = duty-free-exports)
Answered Same DayNov 15, 2021

Answer To: % 1. Title: 1984 United States Congressional Voting Records Database % % 2. Source Information: %...

Apoorv answered on Nov 22 2021
162 Votes
FBLSolution/IONOshphere_dataset.ipynb
{
"cells": [
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"from scipy.io import arff\n",
"import pandas as pd\n",
"\n",
"\n",
"from sklearn import model_selection \n",
"from sklearn.ensemble import BaggingClassifier \n",
"from sklearn.tree import DecisionTreeClassifier \n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.preprocessing import MultiLabelBinarizer\n",
"from sklearn.preprocessing import LabelEncoder \n",
"\n",
"import matplotlib.pyplot as plt \n",
"\n",
"\n",
"\n",
"from scipy.io import arff\n",
"import pandas as pd\n",
"\n",
"\n",
"from sklearn import model_selection \n",
"from sklearn.ensemble import BaggingClassifier \n",
"from sklearn.tree import DecisionTreeClassifier \n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.preprocessing import MultiLabelBinarizer\n",
"\n",
"\n",
"\n",
"from sklearn.metrics import accuracy_score\n",
"\n",
"import matplotlib.pyplot as plt \n",
"from sklearn import svm, datasets \n",
"import warnings\n",
"warnings.filterwarnings(\"ignore\")"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"data = arff.loadarff('C:/Users/avira/Downloads/ionosphere-qocpqvmv.arff')\n",
"df = pd.DataFrame(data[0])"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"X = df.drop(\"class\",axis=1)\n",
"y = df[\"class\"]"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"y = pd.get_dummies(df['class'],drop_first=True)"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"def model_definitions_tree_depth(depth):\n",
" # initialize the base classifier\n",
" base_cls = DecisionTreeClassifier(max_depth=depth) \n",
" # no. of base classifier \n",
" # bagging classifier \n",
" model = BaggingClassifier(base_estimator = base_cls)\n",
" \n",
" model.fit(X_train,y_train)\n",
" y_pred = model.predict(X_train)\n",
" training_accuracy = accuracy_score(y_pred,y_train)\n",
" y_pred_test = model.predict(X_test)\n",
" testing_accuracy = accuracy_score(y_pred_test,y_test)\n",
" \n",
" return training_accuracy,testing_accuracy\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"def calculate_depth
_wise(tree_depth): \n",
" training = []\n",
" testing = [] \n",
" for depth in tree_depth:\n",
" tr,te = model_definitions_tree_depth(depth)\n",
" training.append(tr)\n",
" testing.append(te)\n",
" plt.plot(tree_depth, training)\n",
" plt.plot(tree_depth, testing)"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRw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EuCLQKVz7nQgFbjJ36rG3MPAVUOWfQVY5ZyrAFaFX58yBf0Ics41OOfeCj8/hPeHXOJvVf4xs1LgWuBBv2vxm5nlABcBPwFwznU75w76W5Xv0oAJZpYGZAL1PtczppxzrwDNQxbfADwSfv4I8OGR+LcU9KPEzMqBxcAb/lbiq+8B/wCE/C4kDswCGoH/F+7KetDMsvwuyi/OuT3Ad4HdQAPQ4pz7vb9VxYUpzrkG8BqOwOSReFMF/Sgws4nAM8CdzrlWv+vxg5ldB+xzzq33u5Y4kQYsAe51zi0G2hihr+WJKNz3fAMwE5gGZJnZx/ytKrgU9CPMzNLxQv5x59wv/K7HR+cD15vZLuBJ4DIz+6m/JfmqDqhzzvV/w3saL/iT1Qpgp3Ou0TnXA/wCOM/nmuLBB2Y2FSD8c99IvKmCfgSZmeH1wb7rnPsPv+vxk3Puq865UudcOd5Jthedc0nbYnPO7QVqzWxeeNHlwFYfS/LbbuBcM8sM/91cThKfnI7wLHBL+PktwK9G4k3TRuJNZMD5wMeBTWb2dnjZ15xzz/lYk8SPLwCPm1kGsAP4pM/1+MY594aZPQ28hTdabQNJdjkEM3sCuAQoNLM64BvAd4CnzOxWvIPhR0fk39IlEEREgk1dNyIiAaegFxEJOAW9iEjAKehFRAJOQS8iEnAKehGRgFPQi4gE3P8HbO+XtSpwhAsAAAAASUVORK5CYII=\n",
"text/plain": [
"
"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"tree_depth = [1,2,3,5,10]\n",
"calculate_depth_wise(tree_depth)"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"Here,at depth 2 we are getting most consistent accuracy about 90% of testing and training data but at depth 5 testing accuracy is highest around 95% and training accuracy around 97% ,After this model starts overfitting"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"def model_definitions_no_of_trees(number_t):\n",
" # initialize the base classifier\n",
" base_cls = DecisionTreeClassifier() \n",
" # no. of base classifier \n",
" # bagging classifier \n",
" model = BaggingClassifier(base_estimator = base_cls, \n",
" n_estimators = number_t,\n",
" )\n",
" model.fit(X_train,y_train)\n",
" y_pred = model.predict(X_train)\n",
" training_accuracy = accuracy_score(y_pred,y_train)\n",
" y_pred_test = model.predict(X_test)\n",
" testing_accuracy = accuracy_score(y_pred_test,y_test)\n",
" \n",
" return training_accuracy,testing_accuracy\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"def calculate_number_tree_wise(num_trees):\n",
" training = []\n",
" testing = [] \n",
" for trees in num_trees:\n",
" tr,te = model_definitions_no_of_trees(trees)\n",
" training.append(tr)\n",
" testing.append(te)\n",
" plt.plot(num_trees, training)\n",
" plt.plot(num_trees, testing)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAgAElEQVR4nO3deXxU5dn/8c9FwiIQVCACEtaKC+42gju4VbAWirgA7suDXeziU9uf1j61Uq1t1da22lZqEXFDRLRordRScNcSiiLIIqJIQCSI7LIkuX5/3CdkDIEMZJKTnPm+X695kTnnzMw1w8k3Z+5zn/s2d0dERJKrSdwFiIhI3VLQi4gknIJeRCThFPQiIgmnoBcRSbjcuAuoqn379t69e/e4yxARaVRmzpy5yt3zq1vX4IK+e/fuFBUVxV2GiEijYmZLdrZOTTciIgmnoBcRSTgFvYhIwinoRUQSTkEvIpJwNQa9mY0xs5VmNmcn683Mfm9mi8xstpkdk7LuMjN7L7pdlsnCRUQkPekc0Y8FBuxi/UCgV3QbCfwJwMzaAjcDfYE+wM1mtm9tihURkd1XYz96d3/JzLrvYpPBwDgP4x2/YWb7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Wa9gRuAqe7eC5ga3c8W3wPmpdz/FfDb6LP4DLgqlqri8TvgeXc/GDiS8Llk5b5hZp2B7wKF7n4YkAMMI7v2j7HAgCrLdrY/DAR6RbeRwJ/2+FXdXbcM3oC/AWcCC4BO0bJOwIK4a6un918Q7aynAc8CRrjSLzdafzwwJe466+mzaAN8QNTpIWV5tu4bnYGlQFvCNKbPAmdl2/4BdAfm1LQ/APcBw6vbbndvOqLPIDPrDhwNvAl0cPePAaJ/94uvsnp1N/AjoDy63w5Y4+6l0f1iwi98NugJlAAPRE1Z95tZK7J033D3ZcCdwEfAx8BaYCbZu39U2Nn+UPGHscIefzYK+gwxs9bAk8D33X1d3PXEwczOAVa6+8zUxdVsmi19enOBY4A/ufvRwEaypJmmOlHb82CgB7A/0IrQPFFVtuwfNcnY746CPgPMrCkh5B9x90nR4k/MrFO0vhOwMq766tGJwCAz+xAYT2i+uRvYx8xyo20KgOXxlFfvioFid38zuj+REPzZuG8AnAF84O4l7r4NmAScQPbuHxV2tj8UA11Sttvjz0ZBX0tmZsBfgXnu/puUVZOBy6KfLyO03Seau9/o7gXu3p1wku3f7n4RMA04L9osKz4LAHdfASw1s4OiRacD75KF+0bkI+A4M2sZ/d5UfB5ZuX+k2Nn+MBm4NOp9cxywtqKJZ3fpythaMrOTgJeBd6hsl/4xoZ1+AtCVsIOf7+6rYykyBmbWH7je3c8xs56EI/y2wCzgYnffEmd99cXMjgLuB5oBi4ErCAdYWblvmNktwIWE3mqzgKsJ7c5ZsX+Y2WNAf8JwxJ8ANwNPU83+EP0xvIfQS2cTcIW7F7yYJnkAAAA1SURBVO3R6yroRUSSTU03IiIJp6AXEUk4Bb2ISMIp6EVEEk5BLyKScAp6EZGEU9CLiCTc/weZ9ACn4BmI8gAAAABJRU5ErkJggg==\n",
"text/plain": [
"
"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"num_trees = [10,20,40,60,80,100]\n",
"calculate_number_tree_wise(num_trees)"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": [
"Here,when the number of trees are 20-40 the testing accuracy is most of 92% and lowest at 60 number of tress i.e. 88% and the training accuracy is around 1 always."
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"def svm_definition_linear(c):\n",
" model = svm.SVC(kernel ='linear', C = c).fit(X_train,y_train)\n",
" y_pred = model.predict(X_train)\n",
" training_accuracy = accuracy_score(y_pred,y_train)\n",
" y_pred_test = model.predict(X_test)\n",
" testing_accuracy = accuracy_score(y_pred_test,y_test)\n",
" \n",
" return training_accuracy,testing_accuracy"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"def calculate_SVM_C_linear(C):\n",
" training = []\n",
" testing = [] \n",
" for c in C:\n",
" tr,te = svm_definition_linear(c)\n",
" training.append(tr)\n",
" testing.append(te)\n",
" plt.plot(C, training)\n",
" plt.plot(C, testing)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"image/png":...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here