A1_2023
.pdf
keyboard_arrow_up
School
McMaster University *
*We aren’t endorsed by this school
Course
4SL4
Subject
Electrical Engineering
Date
Jan 9, 2024
Type
Pages
3
Uploaded by BailiffInternet7321
McMaster University
Dept. of Electrical and Computer Engineering
COE 4SL4- Term I (Fall) 2023
Assignment 1 - Trade-off between Overfitting and
Underfitting
Due Date:
September 29, 11:30 pm
Late submission
If you submit the assignment after the deadline, the following penalty is applied:
3
10% penalty if the submission is before October 6, 11:30 pm (if the mark before applying
the penalty is 78 out of 100, after applying the penalty it is 78 - 7.8 = 70.2 out of 100);
3
50% penalty if the submission is after October 6, 11:30 pm and before Dec. 6, 11:30
pm.
Description
:
In this assignment, you are required to perform an experiment similar to the experiment
in Section 1.1 of PRML [1].
Therefore, you have to read that experiment and its
discussion first.
You will have to compare several regression models to illustrate the
trade-off between overfitting and underfitting. You will use data generated synthetically.
The prediction is to be performed based on only one feature, denoted by
x
. The target
t
is a noisy measurement of the function of
f
true
(
x
)
. Thus
t
satisfies the following relation
t
=
sin
(4
πx
+
π/
2)
|
{z
}
f
true
(
x
)
+
,
(1)
where
is random noise with a Gaussian distribution with 0 mean and variance 0
.
0625.
Construct a training set consisting of only 12 examples
{
(
x
(1)
, t
(1)
)
,
· · ·
,
(
x
(10)
, t
(12)
)
}
,
where
x
(1)
,
· · ·
, x
(12)
are uniformly spaced in the interval [0
,
1], with
x
(1)
= 0,
x
(12)
= 1,
and
t
(1)
,
· · ·
, t
(12)
are generated using relation (1), the noise being randomly generated.
Construct a validation set consisting of 120 examples with features uniformly spaced in
the interval [0
,
1], with
x
(1)
= 0,
x
(120)
= 1 and targets generated randomly according
to relation (1).
When generating the random data use a four-digit number
containing the last
4
digits of your student ID (in any order), as seed for the
pseudo number generator.
You have to train twelve least squares regression models of increasing capacity (cor-
responding to
M
from 0 to 11) and record and compare their training and validation
errors. For model
M
, 0
≤
M
≤
11, the prediction function has the form
f
M
(
x
) =
w
0
+
w
1
x
+
w
2
x
2
+
· · ·
+
w
M
x
M
.
Note that, when
M
= 0, the prediction function is just a constant function. For each
M
you have to train the model using least squares and record the training and validation
errors. For each
M
, plot the prediction
f
M
(
x
) function and the curve
f
true
(
x
) versus
x
∈
[0
,
1]. Additionally, include in the figure all the points in the training set and in
1 of 2
McMaster University
Dept. of Electrical and Computer Engineering
COE 4SL4- Term I (Fall) 2023
the validation set with their true target values.
Use different colours for the training
examples, the validation examples, the prediction function and the true function, i.e.,
four colours. In addition, plot the training and validation errors versus
M
. Also include
in this plot the average squared error between the targets and the true function
f
true
(
x
)
for the examples in the validation set (this will be a horizontal line).
What does this
value represent?
Additionally, for
M
= 11 you have to train the model with regularization in order to
control overfitting. Here you have to try several values for
λ
until you find a value
λ
1
that eliminates the overfitting. You also have to find a value
λ
2
for which underfitting
occurs. Then plot the training and validation errors versu
λ
, for all the
λ
values that
you tried. Also include in this plot the average squared error between the targets and
the true function
f
true
(
x
) for the examples in the validation set (this will be a horizontal
line). For each of
λ
1
and
λ
2
plot the prediction function
f
M
(
x
) and the curve
f
true
(
x
)
against
x
, and all the points in the training set and in the validation set with their true
targets.
You have to write a report to present your results and their discussion. Discuss what
you observe in the plots.
Justify your choice for
λ
1
and
λ
2
.
Report the parameter
vectors for
λ
1
and
λ
2
and compare them. Do they fullfill your expectations? The report
should be clear and concise.
Besides the report, you have to submit your numpy code. The code has to be modular
and should use vectorization instead of for loops whenever possible. Write a function
for each of the main tasks. Also, write a function for each task that is executed mul-
tiple times (e.g, to compute the average error).
The code should include instructive
comments.
Code for feature standardization
:
When training a linear model with regularization, the features have to be standardized
first. You may use the code given below for feature standardization.
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
XX
train
= sc.fit
transform(
XX
train
)
XX
valid
= sc.transform(
XX
valid)
Note that the standardization is performed based on the training data. Then the same
transformations are applied to the validation data in order to be able to use the trained
predictor on the validation data. In other words, the value that is subtracted from each
feature and the value used for scaling in the validation data are the same ones that were
used for the training data.
Submission Instructions
:
•
Submit the files in the Assignments Box on Avenue. Specific instructions for the
format of the submitted files is provided on Avenue
2 of 2
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
Please also explain the theory behind your work and explain why we apply, I'll give a thumb up for the answer like this, thank you so much!
Please answer in typing format solution please only
arrow_forward
I need help with this. Tnx
arrow_forward
Draw a class diagram to capture the following situation: “Every student is enrolled in a course. Each student may be enrolled in a set of units. Some units are core units for one or more courses and some units are elective units for one or more courses."
arrow_forward
Question 6: Give the preferred IUPAC name of the compound in Figure 6. [Use
lowercase letters. Do not use spaces if it is not required in the name.]
Your answer
Figure 6
Br
yet
arrow_forward
The answer in the following image are wrong, so provide your
work in. a written format, if you provide in typed format or
provide the same answers as shown in the image your answer
will be downvoted.
A patient takes 250 mg of a drug at the same time every day. Just before each tablet is taken, 5% of the drug remains in
the body.
(a) What quantity (in mg) of the drug is in the body after the third tablet? After the nth tablet?
third tablet 263.125 ✓ mg
nth tablet
263.157(1-0.05¹)
X
mg
(b) What quantity (in mg) of the drug remains in the body in the long run? (Round your answer to three decimal places.)
263.157 X mg
arrow_forward
Printer circuit boards are functionally tested after being filled with semiconductor chips, One group contains 150 cards and 20 are selected for functional testing.
a) If 20 cards are faulty, what is the probability of at least 1 faulty fault in this sample?
b) If 5 cards are faulty, what is the probability of at least 1 faulty in this sample?
note: could you please write the solutions legibly?
arrow_forward
Get the same shape required and Give proper label and title by using OCTAVE and write the program
arrow_forward
Test 2: Modified true or false:Shade letter A if the first statement is True, Shade Letter B if the second
statement is True, Shade C if both statement is true, Shade D if both statements are false.
1. The passing general average rating shall be seventy percent (70%) with no grade below fifty
percent (50%) in any subjects.
Mathematics, such as: algebra, trigonometry, analytic geometry, differential calculus, integral
calculus, differential equations, complex numbers, probability and statistics, advanced
engineering mathematics including matrices, power series, Fourier analysis, Laplace transforms,
and others. The weight is twenty-five percent (25%).
2. All applications for oral examinations for professional electrical engineer and written
examinations for registered electrical engineer and registered master electrician shall be subject
to payment of fees prescribed by the Commission.
The members of the Board shall hold office for a term of three (3) years from the date of
appointment…
arrow_forward
Thank you And please kindly write legibly because I'm having a hard time reading, guessing, and understanding the handwriting of different experts recently. Thanks
Please refer to the photo below.
Activity: Series and Parallel Capacitance
arrow_forward
INFE242 ELECTRONICS
PLEASE i begging you help me in this problem ??
Please make it clear
ALL thank and appreciation ?? ?
arrow_forward
(001) 3- Fixed Bias Circuit. (Course: Electronic Devices and Circuit Theory).
-Use Equation Operators or write it down on paper/digital paper.
-Redraw and Apply.
-You can add //comments for a better understanding.
-Please answer without abbreviation.
-Make it clean and clear typing/writing.
Thank you.
arrow_forward
Find the values.(Need only handwritten solution please otherwise downvote)
arrow_forward
Plz solve this problem within 20 minutes I have to submit it within 25 minutes will definitely voteup thanks ? ? ?
arrow_forward
"Electrical machines/ I need a complete and clear solution for all 7 sub-questions of a single question. Thank you."
arrow_forward
Detailed solution and how to solve such a question
With annotation in the drawing
arrow_forward
Do it on paper with neat hand writing, no gpt otherwise leave a DOWNVOTE
arrow_forward
Please answer fourth question from digital electronics asap
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:A two-anode mercury-arc rectifier delivers a load of 5.98kw at 115volts. If the primary of the transformer is connected to a 4,600-volt source, the tube drop is 15volts, and a rectangular waveshape is assumed for the anode current, calculate:
(d) the kilovolt-ampere rating of the transformer primary;(e) the kilovolt-ampere rating of the transformer secondary.
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:The three transformers that feed & three-phase converter is connected in Δ on the primary side and Y on the secondary side. If the slip-ring current is 471.5amp, calculate:(a) the current in each transformer primary coil if the ratio of transformation is 21.7:1;(b) the line current on the primary side of the transformers.
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:A two-anode mercury-arc rectifier delivers a load of 5.98kw at 115volts. If the primary of the transformer is connected to a 4,600-volt source, the tube drop is 15volts, and a rectangular waveshape is assumed for the anode current, calculate:(a) the anode current;(b) the voltage rating of each of the transformer secondary windings;(c) the primary current, neglecting the exciting current;
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:What is the smallest number of poles that can be used in two synchronous machines if it is desired to convert from 60 to 50 cycles and at what speed will the set operate?
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM: A synchronous converter delivers 500-amp direct current. Aвsuming 100percent efficiency and unity power factor, determine the a-c slip-ring current if the converter has:
(a) 3 rings(b) 6 rings(c) 12 rings.
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM: A 1,000-kw three-phase converter delivers full load at 600volts. If the efficiency is 94percent and the power factor is 0.96, determine:(a) the direct-current output(b) the a-c slip-ring current(c) the kilovolt-ampere load delivered by each transformer.
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:A three-anode mercury-arc rectifier supplies a 250-kw 230-volt load and is energized from a 4,600-volt three-phase source through a three-phase transformer whose primaries are in delta. Assuming an arc drop of 20-volts, calculate:(a) the d-c load current;(b) the voltage and kilovolt-ampere rating of each transformer secondary;(c) the current and kilovolt-ampere rating of the three-phase transformer.
arrow_forward
DEGREE: Electrical Engineering SUBJECT/COURSE: AC CircuitsTOPIC: Converter and Rectifier NOTE: Please solve in this way. 1. Please have a good handwriting, some of the answers are not readable. Thank you!2. GIVEN. (Include symbols and units)3. REQUIRED/FIND/MISSING (with symbol/s)4. ILLUSTRATION (Required).5. Step-by-step SOLUTION with Formulas and Symbols. No Shortcut, No skipping, and detailed as possible6. FINAL ANSWERS must be rounded up to three decimal places
PROBLEM:The three transformers that feed & three-phase converter is connected in Δ on the primary side and Y on the secondary side. If the slip-ring current is 471.5amp, calculate:(NO NEED TO SOLVE THIS-SOLVE THE PROBLEM BELOW) the current in each transformer primary coil if the ratio of transformation is 21.7:1;(NO NEED TO SOLVE THIS-SOLVE THE PROBLEM BELOW) the line current on the primary side of the transformers.
PLEASE SOLVE THIS: If the slip-ring voltage in the problem above is 367 volts, calculate:(a) the d-c…
arrow_forward
Thank you And please kindly write legibly because I'm having a hard time reading, guessing, and understanding the handwriting of different experts recently. Thanks
Please refer to the photo below.
Activity: Capacitor and Capacitance
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:PEARSON
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:9781337900348
Author:Stephen L. Herman
Publisher:Cengage Learning
Programmable Logic Controllers
Electrical Engineering
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:9780078028229
Author:Charles K Alexander, Matthew Sadiku
Publisher:McGraw-Hill Education
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:9780134746968
Author:James W. Nilsson, Susan Riedel
Publisher:PEARSON
Engineering Electromagnetics
Electrical Engineering
ISBN:9780078028151
Author:Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:Mcgraw-hill Education,
Related Questions
- Please also explain the theory behind your work and explain why we apply, I'll give a thumb up for the answer like this, thank you so much! Please answer in typing format solution please onlyarrow_forwardI need help with this. Tnxarrow_forwardDraw a class diagram to capture the following situation: “Every student is enrolled in a course. Each student may be enrolled in a set of units. Some units are core units for one or more courses and some units are elective units for one or more courses."arrow_forward
- Question 6: Give the preferred IUPAC name of the compound in Figure 6. [Use lowercase letters. Do not use spaces if it is not required in the name.] Your answer Figure 6 Br yetarrow_forwardThe answer in the following image are wrong, so provide your work in. a written format, if you provide in typed format or provide the same answers as shown in the image your answer will be downvoted. A patient takes 250 mg of a drug at the same time every day. Just before each tablet is taken, 5% of the drug remains in the body. (a) What quantity (in mg) of the drug is in the body after the third tablet? After the nth tablet? third tablet 263.125 ✓ mg nth tablet 263.157(1-0.05¹) X mg (b) What quantity (in mg) of the drug remains in the body in the long run? (Round your answer to three decimal places.) 263.157 X mgarrow_forwardPrinter circuit boards are functionally tested after being filled with semiconductor chips, One group contains 150 cards and 20 are selected for functional testing. a) If 20 cards are faulty, what is the probability of at least 1 faulty fault in this sample? b) If 5 cards are faulty, what is the probability of at least 1 faulty in this sample? note: could you please write the solutions legibly?arrow_forward
- Get the same shape required and Give proper label and title by using OCTAVE and write the programarrow_forwardTest 2: Modified true or false:Shade letter A if the first statement is True, Shade Letter B if the second statement is True, Shade C if both statement is true, Shade D if both statements are false. 1. The passing general average rating shall be seventy percent (70%) with no grade below fifty percent (50%) in any subjects. Mathematics, such as: algebra, trigonometry, analytic geometry, differential calculus, integral calculus, differential equations, complex numbers, probability and statistics, advanced engineering mathematics including matrices, power series, Fourier analysis, Laplace transforms, and others. The weight is twenty-five percent (25%). 2. All applications for oral examinations for professional electrical engineer and written examinations for registered electrical engineer and registered master electrician shall be subject to payment of fees prescribed by the Commission. The members of the Board shall hold office for a term of three (3) years from the date of appointment…arrow_forwardThank you And please kindly write legibly because I'm having a hard time reading, guessing, and understanding the handwriting of different experts recently. Thanks Please refer to the photo below. Activity: Series and Parallel Capacitancearrow_forward
- INFE242 ELECTRONICS PLEASE i begging you help me in this problem ?? Please make it clear ALL thank and appreciation ?? ?arrow_forward(001) 3- Fixed Bias Circuit. (Course: Electronic Devices and Circuit Theory). -Use Equation Operators or write it down on paper/digital paper. -Redraw and Apply. -You can add //comments for a better understanding. -Please answer without abbreviation. -Make it clean and clear typing/writing. Thank you.arrow_forwardFind the values.(Need only handwritten solution please otherwise downvote)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Introductory Circuit Analysis (13th Edition)Electrical EngineeringISBN:9780133923605Author:Robert L. BoylestadPublisher:PEARSONDelmar's Standard Textbook Of ElectricityElectrical EngineeringISBN:9781337900348Author:Stephen L. HermanPublisher:Cengage LearningProgrammable Logic ControllersElectrical EngineeringISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
- Fundamentals of Electric CircuitsElectrical EngineeringISBN:9780078028229Author:Charles K Alexander, Matthew SadikuPublisher:McGraw-Hill EducationElectric Circuits. (11th Edition)Electrical EngineeringISBN:9780134746968Author:James W. Nilsson, Susan RiedelPublisher:PEARSONEngineering ElectromagneticsElectrical EngineeringISBN:9780078028151Author:Hayt, William H. (william Hart), Jr, BUCK, John A.Publisher:Mcgraw-hill Education,
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:PEARSON
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:9781337900348
Author:Stephen L. Herman
Publisher:Cengage Learning
Programmable Logic Controllers
Electrical Engineering
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:9780078028229
Author:Charles K Alexander, Matthew Sadiku
Publisher:McGraw-Hill Education
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:9780134746968
Author:James W. Nilsson, Susan Riedel
Publisher:PEARSON
Engineering Electromagnetics
Electrical Engineering
ISBN:9780078028151
Author:Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:Mcgraw-hill Education,