Question

scribed previously. on time on time very late on time on time very late summer day season wind rain class weekday spring none
Self-Assessment Exercise 1 for Chapter 3 (page37); Entering the data: 1. Enter the data from Figure 3.1 in the text into R. E
2. If you do not have the naivebayes package in your R installation, install it. Then load using: library(naivebayes). Buildi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Reading the data file

> train=read.csv(file = "Data.csv")
> attach(train)

2. Loading the naive bayes package
> library(naivebayes)
naivebayes 0.9.7 loaded
Warning message:
package ‘naivebayes’ was built under R version 3.6.3

3. Building the model
> nbModelSum2020 <- naive_bayes(class~., train,laplace = 1)

4. Creating test dataset
> test<- train[,c(1,2,3,4)]

5. Adding new rows
> testNB1 <- rbind(test,c("weekday","winter","high","heavy"),
+ c("weekday","summer","high","heavy"),
+ c("Sunday","summer","normal","slight"))

6. Predicting from the model

> New_Column=predict(nbModelSum2020,testNB1,type = "class")

7. Values of Class

> Final_Data= testNB1
> Final_Data[5]=New_Column

> names(Final_Data)[names(Final_Data) == "V5"] <- "Predicted Class"
> Final_Data

Day Season Wind rain Predicted Class
1 weekday spring none none on time
2 weekday winter none slight on time
3 weekday winter none slight on time
4 weekday winter high heavy very late
5 Saturday summer normal none on time
6 weekday autumn normal none on time
7 holiday summer high slight on time
8 Sunday summer normal none on time
9 weekday winter high heavy very late
10 weekday summer none slight on time
11 Saturday spring high heavy cancelled
12 weekday summer high slight on time
13 Saturday winter normal none late
14 weekday summer high none on time
15 weekday winter normal heavy very late
16 Saturday autumn high slight on time
17 weekday autumn none heavy on time
18 holiday spring normal slight on time
19 weekday spring normal none on time
20 weekday spring normal slight on time
21 weekday winter high heavy very late
22 weekday summer high heavy on time
23 Sunday summer normal slight on time

Add a comment
Know the answer?
Add Answer to:
scribed previously. on time on time very late on time on time very late summer day...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • class on time on time on time none late none day season wind rain weekday spring...

    class on time on time on time none late none day season wind rain weekday spring none none weekday winter none slight weekday winter slight weekday winter heavy saturday summer normal none weekday autumn normal none holiday summer high slight sunday summer normal weekday winter high heavy weekday summer none slight saturday spring high heavy weekday summer high slight saturday winter normal weekday summer high none weekday winter normal heavy saturday autumn high slight weekday autumn none heavy holiday spring...

  • BUSINESS ANALYTICS Late in the summer, before the start of the school year, you decide to...

    BUSINESS ANALYTICS Late in the summer, before the start of the school year, you decide to make a quick phone call to your old college roommate Jeremy Hertz, who now lives in Aspen, Co where he runs a ski-equipment shop. “I love living in a ski town”, says Jeremy. It’s great here all year round! Why don’t you come for Labor Day weekend? It’ll be beautiful, we can do some hiking and eat in all the good restaurants before they...

  • BUSINESS ANALYTICS Late in the summer, before the start of the school year, you decide to...

    BUSINESS ANALYTICS Late in the summer, before the start of the school year, you decide to make a quick phone call to your old college roommate Jeremy Hertz, who now lives in Aspen, Co where he runs a ski-equipment shop. “I love living in a ski town”, says Jeremy. It’s great here all year round! Why don’t you come for Labor Day weekend? It’ll be beautiful, we can do some hiking and eat in all the good restaurants before they...

  • Babies born in the summer are much more likely to suffer from mood swings when they...

    Babies born in the summer are much more likely to suffer from mood swings when they grow up while those born in the winter are less likely to become irritable adults, scientists claim. Researchers studied 400 people and matched their personality type to when in the year they were born. They claim that people born at certain times of the year have a far greater chance of developing certain types of temperaments, which can lead to mood disorders. The scientists,...

  • C++ Project Modify the Date Class: Standards Your program must start with comments giving your name...

    C++ Project Modify the Date Class: Standards Your program must start with comments giving your name and the name of the assignment. Your program must use good variable names. All input must have a good prompt so that the user knows what to enter. All output must clearly describe what is output. Using the date class, make the following modifications: Make the thanksgiving function you wrote for project 1 into a method of the Date class. It receive the current...

  • What does the five number tell us about the time spent on email (Hint, interpret the...

    What does the five number tell us about the time spent on email (Hint, interpret the five number summary in plain English) and what does the Boxplot and the normality test show? Explain. Use the 1.5xIQR rule to identify possible outliers. List the cutoff points for outliers, Show your workings. Explain what you found out. (Hint: Are there any excessive time spent on email for Male(1) or Female(2) or both). GET DATA /TYPE-XLS /FILE='C: \Users\rmanda 1 \ Desktop\homework! . xls'...

  • In this assignment you will be implementing a weather forecaster. It involves writing 3 different classes...

    In this assignment you will be implementing a weather forecaster. It involves writing 3 different classes plus a driver program. It is recommended that you write one class at a time and then write a driver (tester) program to ensure that it works before putting everything together. Alternately, you can use the Interactions tab of JGRASP to test some of the early classes. This is discussed in the next few pages. The Season Class The first, shortest, and easiest class...

  • Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are...

    Description Create a polynomial class with linked lists and implement some basic functions. Specifications Polynomials are stored in a linked list of Term objects (two classes: Polynomial and Term). Term objects have two data fields: coefficient and exponent, both positive integers. Polynomial will have some methods that create linked list functionality, but not all list operations are needed; include only those used by this program. Do not use a separate linked list class. The list will be non-circular. Make a...

  • Problem 4 True or False A Bookmark this page Instructions: Be very careful with the multiple choice questions below. Some are "choose all that apply," and many tests your knowledge of when pa...

    Problem 4 True or False A Bookmark this page Instructions: Be very careful with the multiple choice questions below. Some are "choose all that apply," and many tests your knowledge of when particular statements apply As in the rest of this exam, only your last submission will count. 1 point possible (graded, results hidden) The likelihood ratio test is used to obtain a test with non-asymptotic level o True O False Submit You have used 0 of 3 attempts Save...

  • Encoding and Decoding PPM image 3 & 4 are parts of question 2 Code for a09q1:...

    Encoding and Decoding PPM image 3 & 4 are parts of question 2 Code for a09q1: We were unable to transcribe this image3 Encoding an Image in a09q2.py In the next four sections, you will no longer write class methods but rather functions. In each of the next four parts, you should be importing the PPM class from a09q1.py to use with the command from a09q1 import PPM Note that this is similar to how the check module was imported...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT