mirror of
https://github.com/jlengrand/MachineLearningCoursera.git
synced 2026-03-10 08:31:20 +00:00
First question
This commit is contained in:
@@ -35,7 +35,7 @@ load('ex6data1.mat');
|
||||
plotData(X, y);
|
||||
|
||||
fprintf('Program paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
%% ==================== Part 2: Training Linear SVM ====================
|
||||
% The following code will train a linear SVM on the dataset and plot the
|
||||
@@ -55,7 +55,7 @@ model = svmTrain(X, y, C, @linearKernel, 1e-3, 20);
|
||||
visualizeBoundaryLinear(X, y, model);
|
||||
|
||||
fprintf('Program paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
%% =============== Part 3: Implementing Gaussian Kernel ===============
|
||||
% You will now implement the Gaussian kernel to use
|
||||
@@ -70,7 +70,7 @@ fprintf(['Gaussian Kernel between x1 = [1; 2; 1], x2 = [0; 4; -1], sigma = 0.5 :
|
||||
'\n\t%f\n(this value should be about 0.324652)\n'], sim);
|
||||
|
||||
fprintf('Program paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
%% =============== Part 4: Visualizing Dataset 2 ================
|
||||
% The following code will load the next dataset into your environment and
|
||||
@@ -87,7 +87,7 @@ load('ex6data2.mat');
|
||||
plotData(X, y);
|
||||
|
||||
fprintf('Program paused. Press enter to continue.\n');
|
||||
pause;
|
||||
% pause;
|
||||
|
||||
%% ========== Part 5: Training SVM with RBF Kernel (Dataset 2) ==========
|
||||
% After you have implemented the kernel, we can now use it to train the
|
||||
|
||||
@@ -16,10 +16,12 @@ sim = 0;
|
||||
%
|
||||
%
|
||||
|
||||
xt = (x1 - x2).^2;
|
||||
|
||||
top = sum(xt);
|
||||
bottom = 2 * (sigma^2);
|
||||
|
||||
|
||||
|
||||
sim = exp(-top/bottom);
|
||||
|
||||
% =============================================================
|
||||
|
||||
|
||||
BIN
machine-learning-ex6/ex6/token.mat
Normal file
BIN
machine-learning-ex6/ex6/token.mat
Normal file
Binary file not shown.
Reference in New Issue
Block a user