function submitWithConfiguration(conf)
addpath('./lib/jsonlab');
parts = parts(conf);
fprintf('== Submitting solutions | %s...\n', conf.itemName);
tokenFile = 'token.mat';
if exist(tokenFile, 'file')
load(tokenFile);
[email token] = promptToken(email, token, tokenFile);
else
[email token] = promptToken('', '', tokenFile);
end
if isempty(token)
fprintf('!! Submission Cancelled\n');
return
end
try
response = submitParts(conf, email, token, parts);
catch
e = lasterror();
fprintf( ...
'!! Submission failed: unexpected error: %s\n', ...
e.message);
fprintf('!! Please try again later.\n');
return
end
if isfield(response, 'errorMessage')
fprintf('!! Submission failed: %s\n', response.errorMessage);
else
showFeedback(parts, response);
save(tokenFile, 'email', 'token');
end
end
function [email token] = promptToken(email, existingToken, tokenFile)
if (~isempty(email) && ~isempty(existingToken))
prompt = sprintf( ...
'Use token from last successful submission (%s)? (Y/n): ', ...
email);
reenter = input(prompt, 's');
if (isempty(reenter) || reenter(1) == 'Y' || reenter(1) == 'y')
token = existingToken;
return;
else
delete(tokenFile);
end
end
email = input('Login (email address): ', 's');
token = input('Token: ', 's');
end
function isValid = isValidPartOptionIndex(partOptions, i)
isValid = (~isempty(i)) && (1 <= i) && (i <= numel(partOptions));
end
function response = submitParts(conf, email, token, parts)
body = makePostBody(conf, email, token, parts);
submissionUrl = submissionUrl();
params = {'jsonBody', body};
[code, responseBody] = system(sprintf('echo jsonBody=%s | curl -k -X POST -d @- %s', body, submissionUrl));
response = loadjson(responseBody);
end
function body = makePostBody(conf, email, token, parts)
bodyStruct.assignmentSlug = conf.assignmentSlug;
bodyStruct.submitterEmail = email;
bodyStruct.secret = token;
bodyStruct.parts = makePartsStruct(conf, parts);
opt.Compact = 1;
body = savejson('', bodyStruct, opt);
end
function partsStruct = makePartsStruct(conf, parts)
for part = parts
partId = part{:}.id;
fieldName = makeValidFieldName(partId);
outputStruct.output = conf.output(partId);
partsStruct.(fieldName) = outputStruct;
end
end
function [parts] = parts(conf)
parts = {};
for partArray = conf.partArrays
part.id = partArray{:}{1};
part.sourceFiles = partArray{:}{2};
part.name = partArray{:}{3};
parts{end + 1} = part;
end
end
function showFeedback(parts, response)
fprintf('== \n');
fprintf('== %43s | %9s | %-s\n', 'Part Name', 'Score', 'Feedback');
fprintf('== %43s | %9s | %-s\n', '---------', '-----', '--------');
for part = parts
score = '';
partFeedback = '';
partFeedback = response.partFeedbacks.(makeValidFieldName(part{:}.id));
partEvaluation = response.partEvaluations.(makeValidFieldName(part{:}.id));
score = sprintf('%d / %3d', partEvaluation.score, partEvaluation.maxScore);
fprintf('== %43s | %9s | %-s\n', part{:}.name, score, partFeedback);
end
evaluation = response.evaluation;
totalScore = sprintf('%d / %d', evaluation.score, evaluation.maxScore);
fprintf('== --------------------------------\n');
fprintf('== %43s | %9s | %-s\n', '', totalScore, '');
fprintf('== \n');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Service configuration
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function submissionUrl = submissionUrl()
submissionUrl = 'https://www-origin.coursera.org/api/onDemandProgrammingImmediateFormSubmissions.v1';
end
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本次机器学习11课程主要涉及到模型评估与调参的内容。在机器学习领域中,模型评估和调参是非常重要的环节,可以帮助我们更好地理解模型的性能和提升模型的准确性。在这节课中,我们学习了如何使用交叉验证来评估模型的性能,以及如何通过调参来优化模型的表现。首先,我们学习了交叉验证的概念和原理。交叉验证是一种评估模型性能的方法,它通过将数据集划分为多个子集,然后多次训练模型并在不同的子集上进行评估,从而得到更准确的模型性能评估结果。我们学习了常见的交叉验证方法,如K折交叉验证和留一交叉验证,并了解了它们各自的优缺点。接着,我们深入研究了模型调参的技巧。调参是指通过调整模型的超参数来提升模型的性能。我们学习了常见的调参方法,包括网格搜索和随机搜索。网格搜索是一种通过穷举搜索超参数空间中的所有组合来找到最佳超参数的方法,而随机搜索则是通过在超参数空间中随机采样来找到最佳超参数。我们还学习了如何使用交叉验证结合调参来选择最佳的超参数组合,以达到最优的模型性能。在课程的实践环节中,我们通过使用Python的Scikit-learn库来实现模型评估和调参的过程。我们使用常见机器学习算法,并通过交叉验证优化算法
资源推荐
资源详情
资源评论
收起资源包目录
机器学习11课课程资料学习笔记.zip (69个子文件)
机器学习11课课程资料学习笔记
Notes-ML-AndrewNg-master
_sidebar.md 201B
week11.md 247B
week2.md 11KB
.nojekyll 0B
week8.md 557B
docsify-review.bat 161B
week7.md 209B
week3.md 22KB
week1.md 22KB
week4.md 11KB
week6.md 601B
index.html 3KB
week9.md 645B
images
20180106_091307.png 71KB
20180106_090904.png 159KB
20141213201613758.jpg 79KB
20180108_103357.png 23KB
20181115103549.png 35KB
20180105_201639.png 88KB
20180116_235545.png 53KB
20180115_101441.png 507KB
20180107_234509.png 13KB
20180106_203726.png 69KB
20180106_101659.png 46KB
20180117_010904.png 200KB
20180108_104701.png 24KB
20180125_162704.png 30KB
20180123_122124.png 91KB
db48c81304317847870d486ba5bb2015.jpg 61KB
20180106_191023.png 16KB
20180111_080514.png 9KB
20180108_100751.png 81KB
20180111_000814.png 28KB
20180111_080614.png 51KB
20180117_000612.png 34KB
24e9420f16fdd758ccb7097788f879e7.png 33KB
20180112_091654.png 38KB
20180116_001543.png 126KB
20180106_191956.png 50KB
20180115_084326.png 125KB
20180106_092119.png 89KB
20180120_105744.png 72KB
20180125_195029.png 294KB
0f38a99c8ceb8aa5b90a5f12136fdf43.png 94KB
20180115_101442.png 347KB
20180105_212048.png 21KB
20180117_011331.png 12KB
20180121_110111.png 74KB
20180106_190944.png 12KB
20180112_001720.png 61KB
20180112_085630.png 179KB
20180108_113132.png 36KB
20180111_080314.png 9KB
20180105_194712.png 74KB
20180105_194839.png 72KB
20180106_184926.png 45KB
2413fbec8ff9fa1f19aaf78265b8a33b_Logistic_function.png 15KB
20180109_144040.png 53KB
20180106_085915.png 294KB
20180117_000349.png 34KB
20180105_224648.png 55KB
20180114_090054.png 27KB
20180112_092027.png 97KB
20180111_000653.png 26KB
20180116_105545.png 81KB
20180117_004820.png 47KB
assignments
submitWithConfiguration.m 4KB
week5.md 17KB
week10.md 260B
共 69 条
- 1
资源评论
传奇开心果编程
- 粉丝: 1w+
- 资源: 454
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功