1. What Linear Regression training algorithm can you use if you have a training set with millions of features? 

수많은 feature를 가지고 있다면 어떤 Linear Regression 알고리즘을 사용할 것인가?


If you have a training set with millions of features you can use Stochastic Gradient Descent or Mini-batch Gradient Descent, and perhaps Batch Gradient Descent if the training set fits in memory. But you cannot use the Normal Equation because the computational complexity grows quickly (more than quadratically) with the number of features.

당신이 수많은 feature를 가졌다면 스토캐스틱 그라디언트 하강 또는 미니 배치 그라디언트 하강을 사용할 수 있으며, 트레이닝 세트가 메모리에 맞으면(감당할 수 있으면) Batch 그라데이션 디센트를 사용할 수 있습니다. 그러나 일반 방정식을 사용할 수는 없으므로 계산 복잡도가 피쳐의 수와 함께 빠르게 증가합니다 (2 차 이상). 



2. Suppose the features in your training set have very different scales. What algorithms might suffer from this, and how? What can you do about it?

훈련 세트의 기능이 매우 다른 척도를 가지고 있다고 가정합니다. 어떤 알고리즘이 이것으로 어려움을 겪으며 있으며, 어떻게 되는가? 해결책은?

If the features in your training set have very different scales, the cost function will have the shape of an elongated bowl, so the Gradient Descent algorithms will take a long time to converge. To solve this you should scale the data before training the model. Note that the Normal Equation will work just fine without scaling.


트레이닝 세트의 피쳐의 스케일이 매우 다른 경우 cost function 긴 보울 모양이므로 Gradient Descent 알고리즘에 수렴하는 데 시간이 오래 걸릴 수 있습니다. 이 문제를 해결하려면 모델을 교육하기 전에 데이터의 scale을 조정해야 합니다. Normal Equation은 크기 조정 없이 정상적으로 작동합니다. = 경사하강법은 정규화가 필요하다

 


3. Can Gradient Descent get stuck in a local minimum when training a Logistic Regression model?

Logistic Regression 모델을 훈련 할 때 Gradient Descent가 로컬 미니멈에 가둬질수있나?

 

Gradient Descent cannot get stuck in a local minimum when training a Logistic Regression model because the cost function is convex.1

Gradient Descent는 로컬 미니멈에 갖칠수 없다. 왜냐하면 Logistic Regression 모델 학습시 비용 함수는 covex 모형이기 때문이다.

// covex à If you draw a straight line between any two points on the curve, the line never crosses the curve.

 

 

4. Do all Gradient Descent algorithms lead to the same model provided you let them run long enough? 

만약 충분히 오래 실행된다면 모든 Gradient Descent algo는 같은 모델이 될 것인가?


If the optimization problem is convex (such as Linear Regression or Logistic Regression), and assuming the learning rate is not too high, then all Gradient Descent algorithms will approach the global optimum and end up producing fairly similar models. However, unless you gradually reduce the learning rate, Stochastic GD and Mini-batch GD will never truly converge; instead, they will keep jumping back and forth around the global optimum. This means that even if you let them run for a very long time, these Gradient Descent algorithms will produce slightly different models. 

최적화 문제가 볼록 Covex ( : 선형 회귀 또는 로지스틱 회귀) 인 경우 learning rate가 너무 높지 않다고 가정하면 모든 그래디언트 하강 알고리즘이 전체 최적 값에 도달하여 상당히 유사한 모델을 생성하게 됩니다. 그러나 learning rate를 점진적으로 낮추지 않으면 Stochastic GD Mini-batch GD는 절대로 수렴하지 않습니다. 대신, 그들은 전 지구 적 최적으로 앞뒤로 계속 뛰어 오를 것입니다. , 매우 오랜 시간 동안 작동 시키더라도 이러한 Gradient Descent 알고리즘은 약간 다른 모델을 생성합니다.

 

 

5. Suppose you use Batch Gradient Descent and you plot the validation error at every epoch. If you notice that the validation error consistently goes up, what is likely going on? How can you fix this?

당산이 Batch Gradient Descent를 사용하고 당신이 모든 에포크마다 validation error를 그래프로 표시한다고 가정하자. 만약 당신이 벨리데이션 에러가 지속적으로 올라간다는 것을 알았으면, 이게 왜 올라가는 것인가? 어떻게 해결할 것인가?

 

If the validation error consistently goes up after every epoch, then one possibility is that the learning rate is too high and the algorithm is diverging. If the training error also goes up, then this is clearly the problem and you should reduce the learning rate. However, if the training error is not going up, then your model is overfitting the training set and you should stop training.

만약 모든 모든 에포크 이후에 validation error가 올라가면, learning rate가 너무 높거나, 알고리즘이 지나치게 다양해졌을 가능성이 있다. 만약 training error역시 올라간다면, 이는 당신이 learning rate를 감소시켜야 한다는 것을 뜻한다. 만약 training error가 올라가지 않는다면, 당신의 모델은 오버피팅 된 것이고 당신은 학습을 중단해야 한다.

 

 

6. Is it a good idea to stop Mini-batch Gradient Descent immediately when the validation error goes up?

만약 Validation error가 올라가면 Mini-batch Gradient 를 즉각 중지하는 것이 맞는가?

Due to their random nature, neither Stochastic Gradient Descent nor Mini-batch Gradient Descent is guaranteed to make progress at every single training iteration. So if you immediately stop training when the validation error goes up, you may stop much too early, before the optimum is reached. A better option is to save the model at regular intervals, and when it has not improved for a long time (meaning it will probably never beat the record), you can revert to the best saved model.

 

무작위적인 특성으로 인해 스토캐스틱 그라디언트 하강 또는 미니 배치 그라디언트 하강은 매 반복 교육마다 진전을 보장하지 않습니다. 따라서 검증 오류가 발생했을 때 즉시 교육을 중단하면 최적에 도달하기 전에 너무 일찍 중지 할 수 있습니다. 더 나은 옵션은 일정한 간격으로 모델을 저장하는 것입니다. 그리고 오랜 시간 동안 개선되지 않은 경우, 가장 저장된 모델로 되돌릴 수 있습니다.

 

 

7. Which Gradient Descent algorithm (among those we discussed) will reach the vicinity of the optimal solution the fastest? Which will actually converge? How can you make the others converge as well?
어떤 그라디언트 디센트 알고리즘이 최적의 솔루션 근처에 가장 빨리 도달 할 것입니까? 실제로 수렴 할 것인가? 어떻게 수렴시킬것인가?

 

Stochastic Gradient Descent has the fastest training iteration since it considers only one training instance at a time, so it is generally the first to reach the vicinity of the global optimum (or Mini-batch GD with a very small mini-batch size). However, only Batch Gradient Descent will actually converge, given enough training time. As mentioned, Stochastic GD and Mini-batch GD will bounce around the optimum, unless you gradually reduce the learning rate.
Stochastic Gradient Descent 번에 하나의 교육 인스턴스만을 고려하기 때문에 가장 빠른 교육 반복을 수행하므로 일반적으로 전역 최적 (또는 미니 배치 크기가 매우 작은 Mini-batch GD) 부근에 처음으로 도달합니다. 러나 충분한 Training 시간이 주어지면 Batch Gradient Descent 실제로 수렴됩니다. 언급 바와 같이, 점차적으로 학습 속도=learning rate을 줄이지 않으면 Stochastic GD Mini-batch GD optimum 근처에서 튀어다니는 것을 반복합니다.

 

 

8. Suppose you are using Polynomial Regression. You plot the learning curves and you notice that there is a large gap between the training error and the validation error. What is happening? What are three ways to solve this?

다항 회귀 (Polynomial Regression)를 사용한다고 가정하십시오. 학습 곡선을 플롯하면 training error validation error 사이에 큰 차이가 있다는 것을 알게됩니다. 무슨 일 이니? 이것을 해결할 수있는 세 가지 방법은 무엇입니까?

 

If the validation error is much higher than the training error, this is likely because your model is overfitting the training set. One way to try to fix this is to reduce the polynomial degree: a model with fewer degrees of freedom is less likely to overfit. Another thing you can try is to regularize the model for example, by adding an 2 penalty (Ridge) or an 1 penalty (Lasso) to the cost function. This will also reduce the degrees of freedom of the model. Lastly, you can try to increase the size of the training set.

Validation error Training error보다 훨씬 높으면 모델이 Training set overfitting 되었을 수 있습니다. 이 문제를 해결하기 위한 한 가지 방법은 다항식 차수를 줄이는 것입니다. 차수가 낮으면 그만큼 overfit할 가능성이 줄어듭니다. 시도 할 수있는 또 다른 방법은 비용 함수에 ℓ2 패널티 (릿지) 또는 ℓ1 페널티 (라소)를 추가하는 등 모델을 정규화하는 것입니다. 이는 또한 모델의 자유도를 감소시킵니다. 마지막으로 Training 세트의 크기를 늘리려고 할 수 있습니다.

 

 

9. Suppose you are using Ridge Regression and you notice that the training error and the validation error are almost equal and fairly high. Would you say that the model suffers from high bias or high variance? Should you increase the regularization hyperparameter α or reduce it?

Ridge Regression을 사용한다고 가정하고 Training error validation error가 거의 동일하고 상당히 높다는 것을 알게됩니다. 이 모델이 높은 바이어스(편차가 큰지) 또는 높은 분산을 겪고 있다고 말할 수 있습니까? 정규화 하이퍼 파라미터 α를 높이거나 줄여야합니까?

 

If both the training error and the validation error are almost equal and fairly high, the model is likely underfitting the training set, which means it has a high bias. You should try reducing the regularization hyperparameter α.

학습 오차와 검증 오차가 거의 같고 상당히 높다면 모델은 Training set underfit 가능성이 높다. 정규화 하이퍼 파라미터인 α를 줄여야합니다.

 

 

10. Why would you want to use: Ridge Regression instead of Linear Regression? Lasso instead of Ridge Regression? Elastic Net instead of Lasso? /// Linear Reg 대신 Ridge Reg 사용 이유? Rig 대신 Lasso Reg 사용이유? Lasso 대신 Elastic Net 사용이유?


Lets see:

A model with some regularization typically performs better than a model without any regularization, so you should generally prefer Ridge Regression over plain Linear Regression.

일부 정규화 모델은 일반적으로 정규화가없는 모델보다 성능이 우수하므로 일반적으로 일반 선형 회귀보다 릿지 회귀를 선호해야합니다.

 

 

Lasso Regression uses an 1 penalty, which tends to push the weights down to exactly zero. This leads to sparse models, where all weights are zero except for the most important weights. This is a way to perform feature selection automatically, which is good if you suspect that only a few features actually matter. When you are not sure, you should prefer Ridge Regression.

Lasso Regression은 ℓ1 패널티를 사용합니다.이 패널티는 가중치를 정확히 제로로 낮추는 경향이 있습니다. 이로 인해 가장 중요한 가중치를 제외하고 모든 가중치가 0 인 희소 모델이 생성됩니다. 이것은 자동으로 기능 선택을 수행하는 방법입니다. 실제로 몇 가지 기능 만 중요하다고 생각되면 좋습니다. 확실하지 않으면 릿지 회귀를 선호해야합니다.

 

 

Elastic Net is generally preferred over Lasso since Lasso may behave erratically in some cases (when several features are strongly correlated or when there are more features than training instances). However, it does add an extra hyperparameter to tune. If you just want Lasso without the erratic behavior, you can just use lastic Net with an l1_ratio close to 1.

Lasso는 일부 경우 (여러 기능이 강하게 상관되거나 교육 인스턴스보다 많은 기능이있는 경우)에 비정상적으로 동작 할 수 있기 때문에 Lasso보다 일반적으로 선호됩니다. 그러나 튜닝을 위해 추가 하이퍼 매개 변수를 추가합니다. 이상한 행동을하지 않고 올가미를 원한다면 lastic_ratio 1에 가까운 lastic net을 사용할 수 있습니다.

 


 

11. Suppose you want to classify pictures as outdoor/indoor and daytime/nighttime. Should you implement two Logistic Regression classifiers or one Softmax Regression classifier?

야외 / 실내 및 주간 / 야간으로 사진을 분류하려고한다고 가정합니다. 당신은 두 가지 로지스틱 회귀 분류기 또는 Softmax 회귀 분류기를 구현해야합니까?

 

If you want to classify pictures as outdoor/indoor and daytime/nighttime, since these are not exclusive classes (i.e., all four combinations are possible) you should train two Logistic Regression classifiers.

실외 / 실내 및 주간 / 야간으로 사진을 분류하려면 독점적인 클래스가 아니므로 ( 4 가지 조합 모두 가능) 두 개의 로지스틱 회귀 분류기를 교육해야합니다.




+ Recent posts