机器学习_吴恩达 练习题记录

Linear Regression with Multiple Variables

You’d like to use polynomial regression to predict a student’s final exam score from their midterm exam score. Concretely, suppose you want to fit a model of the form
h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 h θ ( x ) = θ 0 + θ 1 x 1 + θ 2 x 2 h_\theta(x) = \theta_0 + \theta_1 x_1 + \theta_2 x_2hθ​(x)=θ_0​+θ_1​x_1​+θ_2​x_2
​, where x 1 x_1 ,​ is the midterm score and x_2x2​ is (midterm score)^22. Further, you plan to use both feature scaling (dividing by the “max-min”, or range, of a feature) and mean normalization. hat is the normalized feature ( x 2 ) ( 2 ) (x_2)^{(2)}​ (Hint: midterm = 72, final = 74 is training example 2.) Please round off your answer to two decimal places and enter in the text box below.

注意看这题的提示是,max-min,所以在编程题中,有featureNormalize的.m文件
本身的.m是
x n = x n μ n S n {x_n} = \frac{{{x_n} - {\mu _n}}}{{{S_n}}}
然后如下分母改成range的就可以得到正确答案了

function [X_norm, mu, sigma] = featureNormalize(X)
%FEATURENORMALIZE Normalizes the features in X 
%   FEATURENORMALIZE(X) returns a normalized version of X where
%   the mean value of each feature is 0 and the standard deviation
%   is 1. This is often a good preprocessing step to do when
%   working with learning algorithms.
% You need to set these values correctly
X_norm = X;
mu = mean(X_norm);
sigma = std(X_norm);
% Instructions: First, for each feature dimension, compute the mean
% Hint: You might find the 'mean' and 'std' functions useful.
%
X_norm=(X-mu)./(max(X)-min(X));
% ============================================================end

关于第5题:
Which of the following are reasons for using feature scaling?
It speeds up gradient descent by making it require fewer iterations to get to a good solution.
It is necessary to prevent the normal equation from getting stuck in local optima.
It speeds up gradient descent by making each iteration of gradient descent less expensive to compute.
It prevents the matrix XTX (used in the normal equation) from being non-invertable (singular/degenerate).

解释:它对梯度下降法的帮助是:减少迭代次数,从而加速程序。正如视频中所说,正规方程不需要特征缩放,因此有关正规方程的两个选项都不选。
来源:逍遥游

Support Vector Machines

!即是正确的选项,X是错误的。
2.Suppose a massive dataset is available for training a learning algorithm. Training on a lot of data is likely to give good performance when two of the following conditions hold true.Which are the two?
!We trian a learning algorithm with a large number of parameters(that is able to learn/represent fairly complex functions).
!The features x contain sufficient information to predict y accurately.
!A human expert on the …
!Our learning algorithm is able to present fairly complex functions
X When we are willing to include high order polynomial

3.Suppose you have trained a logistic regression classifier (x)≥threshold, and predict 0 if hθ(x)<threshold, where currently the threshold is set to 0.5.Suppose you decrease the threshold to 0.3. Which of the following are true? Check all that apply.
if 0.5->0.1
!High recall
!Low precision
X is likely to have unchanged precision and recall, but lower accuracy

if 0.5->0.7 /0.9
!Low recall
!High precision
X is likely to have unchanged precision and recall, but higher accuracy
X same F1 score
X is likely to have unchanged precision and recall, but lower accuracy

4.Suppose you are working on a spam classifier, where spam emails are positive examples (y=1y=1) and non-spam emails are negative examples (y=0y=0). You have a training set of emails in which 99% of the emails are non-spam and the other 1% is spam. Which of the following statements are true? Check all that apply.
!non-spam 99% accuracy
!spam 100% recall and 1% precision
!non-spam 0% recall
!non-spam perform similarly on the cross validation set.
X spam recall 0% and 99% precision
X non-spam overfit

5.Which of the following statements are true? Check all that apply.
!Using a very large training set makes it unlikely for model to overfit the training data.
!“The error analysis”
!On skewed datasets accuracy is not a good measure of performance and…
X It’s a good idea to spend
X After training a logistic
X If your model is underfitting the training set, obtaining more data is likely to help

发布了11 篇原创文章 · 获赞 11 · 访问量 3744

猜你喜欢

转载自blog.csdn.net/qq_39537898/article/details/103981841