hw05b_blank
.pdf
keyboard_arrow_up
School
Santa Barbara City College *
*We aren’t endorsed by this school
Course
W54
Subject
Computer Science
Date
Oct 30, 2023
Type
Pages
14
Uploaded by sarkarved
Data 100, Fall 2023
Homework #5B
Total Points: 24
Submission Instructions
You must submit this assignment to Gradescope by the on-time deadline,
Thursday, Oc-
tober 5th at 11:59 PM Pacific
. Please read the syllabus for
the grace period policy
.
No late submissions beyond the grace period will be accepted. While course sta
ff
is happy
to help you if you encounter di
ffi
culties with submission, we may not be able to respond to
last-minute requests for assistance (TAs need to sleep, after all!).
We strongly encourage
you to plan to submit your work to Gradescope several hours before the stated
deadline.
This way, you will have ample time to reach out to sta
ff
for submission support.
There are two parts to this assignment listed on Gradescope:
•
Homework 05 Coding
: Submit your Jupyter notebook zip file for Homework 5A,
which can be generated and downloaded from DataHub by using the
grader.export()
cell provided.
•
Homework 05 Written
: Submit a single PDF to Gradescope that contains both
(1) your answers to all manually graded questions from the Homework 5A Jupyter
Notebook and (2) your answers to all questions in this Homework 5B document.
To receive credit on this assignment,
you must submit both your coding and written
portions to their respective Gradescope portals
. Your written submission (a single
PDF) can be generated as follows:
1. Access your answers to manually graded Homework 5A questions in one of three ways:
•
Automatically create PDF (recommended)
: We have provided a cell to generate
your written response in the Homework 5A notebook for you. Run the cell and
click to download the generated PDF. This function will extract your response
to the manually-graded questions and put them on separate pages. This process
may fail if your answer is not properly formatted; if this is the case, check out
common errors and solutions described on Ed or follow either of the two ways
described below.
1
Homework #5B
2
•
Manually download PDF
: If there are issues with automatically generating the
PDF, on DataHub, you can try downloading the PDF by clicking on
File->
SaveandExportNotebookAs...->PDF
. If you choose to go this route, you must
take special care to ensure all appropriate pages are chosen for each question on
Gradescope.
•
Take screenshots
: If that doesn’t work either, you can take screenshots of your
answers (and your code if present) to manually-graded questions and include them
as images in a PDF. The manually-graded questions are listed at the top of the
Homework 5A notebook.
2. Answer the below Homework 5B written questions in one of many ways:
•
You can type your answers.
We recommend LaTeX, the math typesetting lan-
guage. Overleaf is a great tool to type in LaTeX.
•
Download this PDF, print it out, and write directly on these pages. If you have
a tablet, you may save this PDF and write directly on it.
•
Write your answers on a blank sheet of physical or digital paper.
•
Note: If you write your answers on physical paper, use a scanning application
(e.g., CamScanner, Apple Notes) to generate a PDF.
3. Combine these two sets of answers together into one PDF document and submit
it to the appropriate Gradescope written portal.
You can use PDF merging tools,
e.g., Adobe Reader, Smallpdf (
https://smallpdf.com/merge-pdf
) or Apple Preview
(
https://support.apple.com/en-us/HT202945
).
4.
Important
: When submitting on Gradescope, you
must tag pages to each ques-
tion correctly
(it prompts you to do this after submitting your work). This signifi-
cantly streamlines the grading process for our readers. Failure to do this may result in
a score of 0 for untagged questions.
You are responsible for ensuring your submission follows our requirements. We will not be
granting regrade requests nor extensions to submissions that don’t follow instructions.
If you
encounter any di
ffi
culties with submission, please don’t hesitate to reach out to sta
ff
prior
to the deadline.
Collaborators
Data science is a collaborative activity. While you may talk with others about the homework,
we ask that you write your solutions individually. If you do discuss the assignments with
others, please include their names at the top of your submission.
Homework #5B
3
Properties of Linear Regression Residuals
1. (10 points) In the lecture, we spent a great deal of time talking about Simple Linear
Regression (SLR), which you also saw in Data 8. To briefly summarize, the simple linear
regression model assumes that given a single observation
x
, our predicted response for
this observation is
ˆ
y
=
✓
0
+
✓
1
x
.
In Lecture 10, we saw that the
✓
0
=
ˆ
✓
0
and
✓
1
=
ˆ
✓
1
that minimize the average
L
2
loss
(or Mean Squared Error - MSE) for the simple linear regression model are:
ˆ
✓
0
= ¯
y
-
ˆ
✓
1
¯
x
ˆ
✓
1
=
r
σ
y
σ
x
Or, rearranging terms, our predictions
ˆ
y
are:
ˆ
y
= ¯
y
+
r
σ
y
x
-
¯
x
σ
x
(a) (3 points) As we saw in the lecture, a residual
e
i
, for data point
i
2
{
1
, . . . , n
}
, is
defined to be the di
ff
erence between a true response
y
i
and predicted response
ˆ
y
i
.
Specifically,
e
i
=
y
i
-
ˆ
y
i
. Note that there are
n
data points, and each data point is
denoted by
(
x
i
, y
i
)
.
Prove, using the equation for
ˆ
y
above, that
P
n
i
=1
e
i
= 0.
(b) (2 points) Prove that
¯
y
=
¯
ˆ
y
. You may use your result from part (a).
(c) (2 points) Show that
(¯
x,
¯
y
)
is on the simple linear regression line.
e
is
Yi
g
t r
y
EE
es
si
mi
no
Ein
EI
g
i
ng
ng
ng
o
g
i
s
g
tr
EE
ai
z
g
s
g
tag
Ii
É
I
get
EE
o
g
d
a
n
n
s
z
E
E
of
a
g
s
g
d
a
toss
y
s
y
Homework #5B
4
(d) (3 points) Show that the residuals are uncorrelated with the predictor variable,
that is
1
n
n
X
i
=1
✓
e
i
-
¯
e
σ
e
◆ ✓
x
i
-
¯
x
σ
x
◆
= 0
,
where
¯
e
=
1
n
P
n
i
=1
e
i
,
σ
2
e
=
1
n
P
n
i
=1
(
e
i
-
¯
e
)
2
, and
σ
2
x
=
1
n
P
n
i
=1
(
x
i
-
¯
x
)
2
. You may
assume that
σ
e
,
σ
x
, and at least one residual are not exactly zero. Use the properties
of estimating equations derived in the lecture.
É
e
i
o
é
o
e
I
a
i
residuals
are
uncorrelated
with
the
meditor
variable
Homework #5B
5
Properties of a Linear Model With No Constant Term
2. (4 points) Suppose that we don’t include an intercept term in our model. That is, our
model is now
ˆ
y
=
✓
x,
where
✓
is the single parameter for our model that we need to optimize. (In this equation,
x
is a scalar, corresponding to a single observation.)
As usual, we are looking to find the value
ˆ
✓
that minimizes the average
L
2
loss (MSE)
across our observed data
{
(
x
i
, y
i
)
}
, for i
2
{
1
, . . . , n
}
:
R
(
✓
) =
1
n
n
X
i
=1
(
y
i
-
✓
x
i
)
2
The estimating equations derived in the lecture no longer hold. In this problem, we’ll
derive a solution to this simpler model. We’ll see that the least squares estimate of the
slope in this model di
ff
ers from the simple linear regression model, and we’ll also explore
whether or not our properties from the previous problem still hold.
Use calculus to find the minimizing
ˆ
✓
.
That is, you may prove that:
ˆ
✓
=
P
x
i
y
i
P
x
2
i
Hint: You may start by following the format of SLR in lecture 10 and replace the SLR
model with the model defined above.
dy
s
nt
Es
2
ni
ly
on
Es
mi
y
0
a
i
G
E
ni
g
É
Mi
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Need help with this. Instuctions are in photo
arrow_forward
Task2 : Updating Order Status
Create a procedure named STATUS_SHIP_SP that allows an employee in the Shipping.
Department to update an order status to add shipping information. The BB_BASKETSTATUS
table lists events for each order so that a shopper can see the current status, date, and
comments as each stage of the order process are finished.
The IDSTAGE column of the BB_BASKETSTATUS table identifies each stage; the value 3 in this column indicates that an
order has been shipped.
The procedure should allow adding a row with an IDSTAGE of 3, date shipped, tracking
number, and shipper. The BB_STATUS_SEQ sequence is used to provide a value for the primary
key column.
HINT: In your Procedure main part (BEGIN _END)
BEGIN
INSERT INTO bb_basketstatus (idstatus, idbasket, idstage, dtstage,
shipper, shippingnum)
VALUES (bb_status_seq.NEXTVAL, p_basketid, 3, p_date, p_shipper,
p_shipnum);
COMMIT;
END;
bb_status_seq.NEXTVAL is auto…
arrow_forward
Based on the ERD below, for each project calculate the difference between the project value and the project balance. Display the result in a new column name “Remaining Balance”. Include the project number and project name in the result output.
arrow_forward
Task 7:
The StayWell marketing team considers sending small gifts to all residents and owners. To decrease the postal costs, they will send gifts to owners in batches to their corresponding offices. Similarly, the marketing team will send the gifts in groups to the residents living in the same property. Therefore, you will need to provide them the number of gifts for each StayWell office and number of gifts for each property. The column headers for the first table should be OFFICE_NUM and GIFTS, the column headers for the second table should be PROPERTY_ID and GIFTS.
arrow_forward
Task 7:
The StayWell marketing team considers sending small gifts to all residents and owners. To decrease the postal costs, they will send gifts to owners in batches to their corresponding offices. Similarly, the marketing team will send the gifts in groups to the residents living in the same property. Therefore, you will need to provide them the number of gifts for each StayWell office and number of gifts for each property. The column headers for the first table should be OFFICE_NUM and GIFTS, the column headers for the second table should be PROPERTY_ID and GIFTS.
Provide the StayWell team the number of gifts for each office.
Provide the StayWell team the number of gifts for each residence.
arrow_forward
The International Conference on Mathematical Sciences and Technology, Math Tech, is a biennial
conference organised by the School of Mathematical Sciences, USM. This event is open to all
national and international experts, practitioners, researchers, and academics to gather and
share their knowledge.
The details of fees for participation in the conference are shown in the following table.
Category
Local (RM)
International (USD)
Presenter
990
260
Observer
600
150
Note: 1 USD = RM4.20
Assignment Requirement
Part 1: Create Invoice
Construct a C++ program to do the following tasks:
a. Enter the participant's name, category, nationality, accommodation (Yes/No).
b. If the answer for the question on accommodation is Yes, the program will ask for the
number of days. Then the program will call function calcAccommodation() to calculate
the accommodation charges.
calcAccommodation() receives accommodation (Yes/No), number of days and participation
type (local/international) as parameters and…
arrow_forward
The International Conference on Mathematical Sciences and Technology, MathTech, is a biennial
conference organised by the School of Mathematical Sciences, USM. This event is open to all
national and international experts, practitioners, researchers, and academics to gather and
share their knowledge.
The details of fees for participation in the conference are shown in the following table.
Category
Local (RM)
International (USD)
Presenter
990
260
Observer
150
Note: 1 USD = RM4.20
Assignment Requirement
Part 1: Create Invoice
Construct a C++ program to do the following tasks:
a. Enter the participant's name, category, nationality, accommodation (Yes/No).
b. If the answer for the question on accommodation is Yes, the program will ask for the
number of days. Then the program will call function calcAccommodation () to calculate
the accommodation charges.
calcAccommodation() receives accommodation (Yes/No), number of days and participation
type (local/international) as parameters and return…
arrow_forward
Task 7 - Task 10
Task 7: List the square footage, owner number, owner last name, and owner first name for each property managed by the StayWell-Columbia City office.
Task 8: Repeat Task 7, but this time include only those properties with three bedrooms.
Task 9: List the office number, address, and monthly rent for properties whose owners live in Washington State or own two-bedroom properties.
Task 10: List the office number, address, and monthly rent for properties whose owners live in Washington State and own a two-bedroom property.
arrow_forward
Task 1:The StayWell Property Management team wants a list of all property addresses combined with the name of the owners. You will need to return three columns: the first name as FIRST_NAME, the last name as LAST_NAME, and the property address as ADDRESS of the owners.
Task 4:The StayWell maintenance team wants to minimize the number of planned visits to properties. The team wants to learn all the properties that have different planned service dates. You need to return all available data in the SERVICE_REQUEST table, where requests are made for the same property with a different NEXT_SERVICE_DATE.
Task 5:The marketing team wants to celebrate the success of StayWell with a party. The team wants a table with the names of all residents and owners combined into single column named PARTICIPANT. You need to combine this information from the tables and send it back to the team.
You do not need to create a new table in the database schema.
Task 6:The StayWell marketing team wants to send mail…
arrow_forward
Task 2: For each invoice placed on November 15, 2021, list the invoice number along with the ID, first name, and last name of the customer for which the invoice was created.
arrow_forward
Write a row-level trigger that executes
before updating a project's location in the
project table. The trigger changes the
department number of the project to 4 if
the location is in 'Stafford'.
TOS
arrow_forward
WEEK 9 ASSIGNMENT#3
Part I:
Complete the following exercise:
Create the following table with the correct columns. Call your new table: student_course (see below). Populate this table with four rows. Make sure the student id column contains values that are also in the student id column of your student table.
student id
course id
semester
year
Join the student and student_course table where the student id values are the same.
Join the student and student_course table where the student id values are the same and year is equal to 2020.
Create a select statement that will return the length of the last name column by joining the student and student_course table where the student id values are the same and enroll month is June.
Once you have completed your assignment, copy and paste the script into a Word document.
Part II:
Complete the following exercise:
Using a subquery, select student first name where the student is in the student course table.
Using a subquery, select the…
arrow_forward
Submission guidelines: The assignment must be submitted by the deadline (earlier submissions are
encouraged) in PDF format through Blackboard using the following file name format:
LastName_FirstName_Assignment_1.pdf. The assignment must be typewritten.
All the assignments in this course are individual work; any overlap between assignment reports will be
penalized.
A bank requires for their customers to access their online banking accounts to provide as
User Id (or user name) the last 8 digits of their bank card number, and a password with a
length between 8 and 12 ASCII characters, including the following restrictions (posted on
their website):
Passwords must have at least 8 characters long and at most 12 characters long, and must include at least
one character from each of the following four character types:
Upper case letters ABC DEF
Lower case letters ghijkl
Numbers 1 2 345 67890
Special characters ! @ # $ % ^ & * (+) = -
The remaining characters of the password must be selected…
arrow_forward
Q2:Write a row-level trigger that executes before updating a project's location in the project table. The trigger
changes the department number of the project to 4 if the location is in 'Stafford'.
COL
arrow_forward
WEEK 9 ASSIGNMENT#6
Part II:
Complete the following exercise:
Using a subquery, select student first name where the student is in the student course table.
Using a subquery, select the course id where the average GPA is 2.
Using a subquery, select the course id where the average GPA is greater than 2.
Using a subquery, select student first name where the student is not in the student course t
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Related Questions
- Need help with this. Instuctions are in photoarrow_forwardTask2 : Updating Order Status Create a procedure named STATUS_SHIP_SP that allows an employee in the Shipping. Department to update an order status to add shipping information. The BB_BASKETSTATUS table lists events for each order so that a shopper can see the current status, date, and comments as each stage of the order process are finished. The IDSTAGE column of the BB_BASKETSTATUS table identifies each stage; the value 3 in this column indicates that an order has been shipped. The procedure should allow adding a row with an IDSTAGE of 3, date shipped, tracking number, and shipper. The BB_STATUS_SEQ sequence is used to provide a value for the primary key column. HINT: In your Procedure main part (BEGIN _END) BEGIN INSERT INTO bb_basketstatus (idstatus, idbasket, idstage, dtstage, shipper, shippingnum) VALUES (bb_status_seq.NEXTVAL, p_basketid, 3, p_date, p_shipper, p_shipnum); COMMIT; END; bb_status_seq.NEXTVAL is auto…arrow_forwardBased on the ERD below, for each project calculate the difference between the project value and the project balance. Display the result in a new column name “Remaining Balance”. Include the project number and project name in the result output.arrow_forward
- Task 7: The StayWell marketing team considers sending small gifts to all residents and owners. To decrease the postal costs, they will send gifts to owners in batches to their corresponding offices. Similarly, the marketing team will send the gifts in groups to the residents living in the same property. Therefore, you will need to provide them the number of gifts for each StayWell office and number of gifts for each property. The column headers for the first table should be OFFICE_NUM and GIFTS, the column headers for the second table should be PROPERTY_ID and GIFTS.arrow_forwardTask 7: The StayWell marketing team considers sending small gifts to all residents and owners. To decrease the postal costs, they will send gifts to owners in batches to their corresponding offices. Similarly, the marketing team will send the gifts in groups to the residents living in the same property. Therefore, you will need to provide them the number of gifts for each StayWell office and number of gifts for each property. The column headers for the first table should be OFFICE_NUM and GIFTS, the column headers for the second table should be PROPERTY_ID and GIFTS. Provide the StayWell team the number of gifts for each office. Provide the StayWell team the number of gifts for each residence.arrow_forwardThe International Conference on Mathematical Sciences and Technology, Math Tech, is a biennial conference organised by the School of Mathematical Sciences, USM. This event is open to all national and international experts, practitioners, researchers, and academics to gather and share their knowledge. The details of fees for participation in the conference are shown in the following table. Category Local (RM) International (USD) Presenter 990 260 Observer 600 150 Note: 1 USD = RM4.20 Assignment Requirement Part 1: Create Invoice Construct a C++ program to do the following tasks: a. Enter the participant's name, category, nationality, accommodation (Yes/No). b. If the answer for the question on accommodation is Yes, the program will ask for the number of days. Then the program will call function calcAccommodation() to calculate the accommodation charges. calcAccommodation() receives accommodation (Yes/No), number of days and participation type (local/international) as parameters and…arrow_forward
- The International Conference on Mathematical Sciences and Technology, MathTech, is a biennial conference organised by the School of Mathematical Sciences, USM. This event is open to all national and international experts, practitioners, researchers, and academics to gather and share their knowledge. The details of fees for participation in the conference are shown in the following table. Category Local (RM) International (USD) Presenter 990 260 Observer 150 Note: 1 USD = RM4.20 Assignment Requirement Part 1: Create Invoice Construct a C++ program to do the following tasks: a. Enter the participant's name, category, nationality, accommodation (Yes/No). b. If the answer for the question on accommodation is Yes, the program will ask for the number of days. Then the program will call function calcAccommodation () to calculate the accommodation charges. calcAccommodation() receives accommodation (Yes/No), number of days and participation type (local/international) as parameters and return…arrow_forwardTask 7 - Task 10 Task 7: List the square footage, owner number, owner last name, and owner first name for each property managed by the StayWell-Columbia City office. Task 8: Repeat Task 7, but this time include only those properties with three bedrooms. Task 9: List the office number, address, and monthly rent for properties whose owners live in Washington State or own two-bedroom properties. Task 10: List the office number, address, and monthly rent for properties whose owners live in Washington State and own a two-bedroom property.arrow_forwardTask 1:The StayWell Property Management team wants a list of all property addresses combined with the name of the owners. You will need to return three columns: the first name as FIRST_NAME, the last name as LAST_NAME, and the property address as ADDRESS of the owners. Task 4:The StayWell maintenance team wants to minimize the number of planned visits to properties. The team wants to learn all the properties that have different planned service dates. You need to return all available data in the SERVICE_REQUEST table, where requests are made for the same property with a different NEXT_SERVICE_DATE. Task 5:The marketing team wants to celebrate the success of StayWell with a party. The team wants a table with the names of all residents and owners combined into single column named PARTICIPANT. You need to combine this information from the tables and send it back to the team. You do not need to create a new table in the database schema. Task 6:The StayWell marketing team wants to send mail…arrow_forward
- Task 2: For each invoice placed on November 15, 2021, list the invoice number along with the ID, first name, and last name of the customer for which the invoice was created.arrow_forwardWrite a row-level trigger that executes before updating a project's location in the project table. The trigger changes the department number of the project to 4 if the location is in 'Stafford'. TOSarrow_forwardWEEK 9 ASSIGNMENT#3 Part I: Complete the following exercise: Create the following table with the correct columns. Call your new table: student_course (see below). Populate this table with four rows. Make sure the student id column contains values that are also in the student id column of your student table. student id course id semester year Join the student and student_course table where the student id values are the same. Join the student and student_course table where the student id values are the same and year is equal to 2020. Create a select statement that will return the length of the last name column by joining the student and student_course table where the student id values are the same and enroll month is June. Once you have completed your assignment, copy and paste the script into a Word document. Part II: Complete the following exercise: Using a subquery, select student first name where the student is in the student course table. Using a subquery, select the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Np Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:CengageCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE LA Guide to SQLComputer ScienceISBN:9781111527273Author:Philip J. PrattPublisher:Course Technology Ptr
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:9781337508841
Author:Carey
Publisher:Cengage
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
A Guide to SQL
Computer Science
ISBN:9781111527273
Author:Philip J. Pratt
Publisher:Course Technology Ptr
Browse Popular Homework Q&A
Q: Find all solutions of the equation √3+5 cos8=3 cose. Express the answer in radian measure.
Q: A uniform beam of length 20 m and mass 100 kg is supported by pylons on either
end. A 200-kg box is…
Q: 7.
f(x)
<-5
g(x)
a. Find the value of
Use
the
-2
(-/-) (-2)
graphs
of
8
7
6
2
Y
f
and 9
c. Identify…
Q: I1
-27
0+2
12
-5
2 + 3
-12
-4
Q: As a person moves about in a dry environment, electric charge accumulates on the person’s body.…
Q: 47
32°
101
Classify the triangle by its sides and angles.
O A) Right scalene triangle
B) Obtuse…
Q: Let f(x) =
The slope of the tangent line to the graph of f(x) at
33
-
the point (8, 5) is
The…
Q: Show that the square of an average is less than or equal to the average
of the squares. More…
Q: Consider the reaction, HQ = H+(aq) + Q¯(aq). At 350.0 K, the AS°rxn =
-81.0 J/mol K and the AH°rxn =…
Q: $350 billion. Under the Miller model,
what is Cruz's value if the federal-plus-
state corporate tax…
Q: If f(x) = 23x + 27, find f'(5).
Q: 5.
The linear function P(x) = 8.7z+0.6 models the number of participants in a fund-raising event for…
Q: Calculate the pH when 60.0 mL of 0.200 M HBr is mixed with 30.0 mL of 0.400 M CH₃NH₂ (Kb = 4.4 ×…
Q: Analysis of daily output of a factory during a 8-hour shift shows that the hourly number of units y…
Q: Which of the following statements regarding unsystematic risk is accurate
Q: How is validity realized in qualitative research?
Q: a bond that does not pay coupons
use semi-annual periods to be consistent / compare to others
par =…
Q: I tried to run this program and it came up with this error do you know why?
Q: a description of the set D={3,6,9,12,15,18,...}
Q: A function f: R → R has a third order continuous derivative. Show that
f(a) f'(a). f"(a). f"" (a) ≥…
Q: What are the vertices of the following equation? Approximate your answer to the nearest hundredth if…
Q: 4. An important question to consider when thinking about global warming is, "If the ice sheets near…
Q: The specific heat of copper is 0.093 cal/(g.°C) and the specific heat of gold is 0.031 cal/(g.°C).…
Q: O
Find the equation of an ellipse in standard form with the following conditions: Major axis…
Q: What are five goals of infectious disease control?