Data Systems > QUESTIONS & ANSWERS > STAT 361 Data Analysis - Yale University WORKSHEET 3.8: SUPERVISED LEARNING IN PYTHON (All)

STAT 361 Data Analysis - Yale University WORKSHEET 3.8: SUPERVISED LEARNING IN PYTHON

Document Content and Description Below

STAT 361 Data Analysis - Yale University WORKSHEET 3.8: SUPERVISED LEARNING IN PYTHON Import house-votes-84 (edited).csv. Write codes necessary to import and examine this dataset. Which of the follow... ing statements is not true? The target variable in this DataFrame is ‘party’. A. The DataFrame has a total of 232 rows and 17 columns. B. Except for party, all of the columns are of type int64. C. The first row of the DataFrame consists of votes by a Democrat and the second row consists of votes by a Republican. D. There are 17 predictor variables, or features, in this DataFrame. D Output 2 Date: Perform graphical exploratory data analysis on the house votes dataset. Use Seaborn’s countplot to visualize the votes to the satellite testing bill, grouped by party. Include the following line before the show function: plt.xticks([0,1], [‘No’, ‘Yes’]). Do the same for the missile bill. Of the two bills, which one/s do Democrats vote resoundingly in favor of, compared to Republicans? Page 1 of 4 This study source was downloaded by 100000861003072 from CourseHero.com on 04-27-2023 09:03:54 GMT -05:00 https://www.coursehero.com/file/83165998/WS38STAMARIAdocx/Jian Karlo R. Sta. Maria APPLIED DATA SCIENCE WORKSHEET 3.8: SUPERVISED LEARNING IN PYTHON A. Missile bill B. Satellite bill C. Both Missile and Satellite bills D. Neither Missile nor Satellite bill C Output 3 Date: Predict the party affiliation of the House member whose votes have been recorded in the file named x_new.csv. Write the code here to achieve the following output: Party Prediction: [‘democrat’/’republican’] Code import pandas as pd from sklearn.neighbors import KNeighborsClassifier hv84=pd.read_csv('house-votes-84 (edited).csv') x_new=pd.read_csv('x_new.csv') y=hv84['party']. values x=hv84.drop('party', axis=1).values knn=KNeighborsClassifier(n_neighbors=16) # n_neighbors = no. of categories knn.fit(x,y) prediction=knn.predict(x_new) print("Prediction: {}".format(prediction)) Output Prediction: ['democrat'] 4 Date: Use train_test_split from sklearn on your House votes data. Use 70% of the data for training and the rest for testing. Add the following arguments to train_test_split: random_state = 21, stratify = y. Print out the predictions for the test set and the model score. [Show More]

Last updated: 2 years ago

Preview 1 out of 4 pages

Buy Now

Instant download

We Accept:

We Accept
document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Buy Now

Instant download

We Accept:

We Accept

Reviews( 0 )

$9.50

Buy Now

We Accept:

We Accept

Instant download

Can't find what you want? Try our AI powered Search

67
0

Document information


Connected school, study & course


About the document


Uploaded On

Apr 30, 2023

Number of pages

4

Written in

Seller


seller-icon
PAPERS UNLIMITED™

Member since 3 years

509 Documents Sold

Reviews Received
55
20
8
2
8
Additional information

This document has been written for:

Uploaded

Apr 30, 2023

Downloads

 0

Views

 67

Document Keyword Tags

More From PAPERS UNLIMITED™

View all PAPERS UNLIMITED™'s documents »

$9.50
What is Scholarfriends

In Scholarfriends, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Scholarfriends · High quality services·