Using Python, Create a k-fold cross validation code with the number of folds being 10. The raw data needs to be split into training and testing. The number of folds is the number of times you should go through a for loop. Inside of the for loop, index into your raw data to pull out training and testing data based on the fold (think about how the folds are organized and how much data is in each fold, which is based on the total number of folds) Do normal linear regression model fitting Keep track of the R^2 scores of the folds Print the average and standard deviation of the R^2 value for the different folds
Using Python, Create a k-fold cross validation code with the number of folds being 10. The raw data needs to be split into training and testing. The number of folds is the number of times you should go through a for loop. Inside of the for loop, index into your raw data to pull out training and testing data based on the fold (think about how the folds are organized and how much data is in each fold, which is based on the total number of folds) Do normal linear regression model fitting Keep track of the R^2 scores of the folds Print the average and standard deviation of the R^2 value for the different folds
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Using Python,
Create a k-fold cross validation code with the number of folds being 10.
- The raw data needs to be split into training and testing.
- The number of folds is the number of times you should go through a for loop.
- Inside of the for loop, index into your raw data to pull out training and testing data based on the fold (think about how the folds are organized and how much data is in each fold, which is based on the total number of folds)
- Do normal linear regression model fitting
- Keep track of the R^2 scores of the folds
- Print the average and standard deviation of the R^2 value for the different folds
![Our libraries that we are importing:
# 1a. Importing all the libraries necessary for this assignment
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
[7] # 1b. Loading the data
data = sns.load_dataset('geyser')
Let's check out this dataset.
[9] print('
data
1
duration waiting kind
3.600
79
long
1
1.800
54 short
2
3.333
74
long
3
2.283
62 short
4
4.533
85
long
267
4.117
81
long
268
2.150
46 short
269
4.417
90
long
270
1.817
46 short
271
4.467
74
long
272 rows x 3 columns
Imagine working at Yellowstone National Park as a scientist researching Old Faithful Geyser. The boss wants us to evaluate the predictiveness
of the relationship between duration of an eruption in minutes ("duration") and the duration in minutes until the next eruption ("waiting"). We
collected the data, but the internet in Yellowstone is not very good, so we cannot access the crossvalidation library in python](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F7c9fe6be-99fb-4863-a04f-7bda979173e6%2F8224c764-6eda-4fff-b719-d20b5a73993e%2Fbejud5m_processed.png&w=3840&q=75)
Transcribed Image Text:Our libraries that we are importing:
# 1a. Importing all the libraries necessary for this assignment
import seaborn as sns
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
[7] # 1b. Loading the data
data = sns.load_dataset('geyser')
Let's check out this dataset.
[9] print('
data
1
duration waiting kind
3.600
79
long
1
1.800
54 short
2
3.333
74
long
3
2.283
62 short
4
4.533
85
long
267
4.117
81
long
268
2.150
46 short
269
4.417
90
long
270
1.817
46 short
271
4.467
74
long
272 rows x 3 columns
Imagine working at Yellowstone National Park as a scientist researching Old Faithful Geyser. The boss wants us to evaluate the predictiveness
of the relationship between duration of an eruption in minutes ("duration") and the duration in minutes until the next eruption ("waiting"). We
collected the data, but the internet in Yellowstone is not very good, so we cannot access the crossvalidation library in python
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images

Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY