Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to pass lesson check #21

Merged
merged 3 commits into from
Jul 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Synchronize with https://pages.github.com/versions
ruby '>=2.7.1'

gem 'github-pages', group: :jekyll_plugins

if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.0.0')
gem 'webrick', '>= 1.6.1'
end
117 changes: 79 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,67 @@

# Settings
MAKEFILES=Makefile $(wildcard *.mk)
JEKYLL=jekyll
JEKYLL_VERSION=3.7.3
JEKYLL=bundle config --local set path .vendor/bundle && bundle install && bundle update && bundle exec jekyll
PARSER=bin/markdown_ast.rb
DST=_site

# Check Python 3 is installed and determine if it's called via python3 or python
# (https://stackoverflow.com/a/4933395)
PYTHON3_EXE := $(shell which python3 2>/dev/null)
ifneq (, $(PYTHON3_EXE))
ifeq (,$(findstring Microsoft/WindowsApps/python3,$(subst \,/,$(PYTHON3_EXE))))
PYTHON := python3
endif
endif

ifeq (,$(PYTHON))
PYTHON_EXE := $(shell which python 2>/dev/null)
ifneq (, $(PYTHON_EXE))
PYTHON_VERSION_FULL := $(wordlist 2,4,$(subst ., ,$(shell python --version 2>&1)))
PYTHON_VERSION_MAJOR := $(word 1,${PYTHON_VERSION_FULL})
ifneq (3, ${PYTHON_VERSION_MAJOR})
$(error "Your system does not appear to have Python 3 installed.")
endif
PYTHON := python
else
$(error "Your system does not appear to have any Python installed.")
endif
endif


# Controls
.PHONY : commands clean files
.NOTPARALLEL:
all : commands

## commands : show all commands.
commands :
@grep -h -E '^##' ${MAKEFILES} | sed -e 's/## //g'
# Default target
.DEFAULT_GOAL := commands

## docker-serve : use docker to build the site
docker-serve :
docker run --rm -it -v ${PWD}:/srv/jekyll -p 127.0.0.1:4000:4000 jekyll/jekyll:${JEKYLL_VERSION} make serve
## I. Commands for both workshop and lesson websites
## =================================================

## serve : run a local server.
## * serve : render website and run a local server
serve : lesson-md
${JEKYLL} serve

## site : build files but do not run a server.
## * site : build website but do not run a server
site : lesson-md
${JEKYLL} build

# repo-check : check repository settings.
## * docker-serve : use Docker to serve the site
docker-serve :
docker pull carpentries/lesson-docker:latest
docker run --rm -it \
-v $${PWD}:/home/rstudio \
-p 4000:4000 \
-p 8787:8787 \
-e USERID=$$(id -u) \
-e GROUPID=$$(id -g) \
carpentries/lesson-docker:latest

## * repo-check : check repository settings
repo-check :
@bin/repo_check.py -s .
@${PYTHON} bin/repo_check.py -s .

## clean : clean up junk files.
## * clean : clean up junk files
clean :
@rm -rf ${DST}
@rm -rf .sass-cache
Expand All @@ -42,24 +72,28 @@ clean :
@find . -name '*~' -exec rm {} \;
@find . -name '*.pyc' -exec rm {} \;

## clean-rmd : clean intermediate R files (that need to be committed to the repo).
## * clean-rmd : clean intermediate R files (that need to be committed to the repo)
clean-rmd :
@rm -rf ${RMD_DST}
@rm -rf fig/rmd-*

## ----------------------------------------
## Commands specific to workshop websites.

##
## II. Commands specific to workshop websites
## =================================================

.PHONY : workshop-check

## workshop-check : check workshop homepage.
## * workshop-check : check workshop homepage
workshop-check :
@bin/workshop_check.py .
@${PYTHON} bin/workshop_check.py .


## ----------------------------------------
## Commands specific to lesson websites.
##
## III. Commands specific to lesson websites
## =================================================

.PHONY : lesson-check lesson-md lesson-files lesson-fixme
.PHONY : lesson-check lesson-md lesson-files lesson-fixme install-rmd-deps

# RMarkdown files
RMD_SRC = $(wildcard _episodes_rmd/??-*.Rmd)
Expand All @@ -85,37 +119,44 @@ HTML_DST = \
$(patsubst _extras/%.md,${DST}/%/index.html,$(sort $(wildcard _extras/*.md))) \
${DST}/license/index.html

## lesson-md : convert Rmarkdown files to markdown
## * install-rmd-deps : Install R packages dependencies to build the RMarkdown lesson
install-rmd-deps:
@${SHELL} bin/install_r_deps.sh

## * lesson-md : convert Rmarkdown files to markdown
lesson-md : ${RMD_DST}

_episodes/%.md: _episodes_rmd/%.Rmd
_episodes/%.md: _episodes_rmd/%.Rmd install-rmd-deps
@mkdir -p _episodes
@bin/knit_lessons.sh $< $@

## lesson-check : validate lesson Markdown.
## * lesson-check : validate lesson Markdown
lesson-check : lesson-fixme
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md

## lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace.
## * lesson-check-all : validate lesson Markdown, checking line lengths and trailing whitespace
lesson-check-all :
@bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive
@${PYTHON} bin/lesson_check.py -s . -p ${PARSER} -r _includes/links.md -l -w --permissive

## unittest : run unit tests on checking tools.
## * unittest : run unit tests on checking tools
unittest :
@bin/test_lesson_check.py
@${PYTHON} bin/test_lesson_check.py

## lesson-files : show expected names of generated files for debugging.
## * lesson-files : show expected names of generated files for debugging
lesson-files :
@echo 'RMD_SRC:' ${RMD_SRC}
@echo 'RMD_DST:' ${RMD_DST}
@echo 'MARKDOWN_SRC:' ${MARKDOWN_SRC}
@echo 'HTML_DST:' ${HTML_DST}

## lesson-fixme : show FIXME markers embedded in source files.
## * lesson-fixme : show FIXME markers embedded in source files
lesson-fixme :
@fgrep -i -n FIXME ${MARKDOWN_SRC} || true
@grep --fixed-strings --word-regexp --line-number --no-messages FIXME ${MARKDOWN_SRC} || true

#-------------------------------------------------------------------------------
# Include extra commands if available.
#-------------------------------------------------------------------------------
##
## IV. Auxililary (plumbing) commands
## =================================================

-include commands.mk
## * commands : show all commands.
commands :
@sed -n -e '/^##/s|^##[[:space:]]*||p' $(MAKEFILE_LIST)
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We'd like to ask you to familiarize yourself with our [Contribution Guide](CONTR
the [more detailed guidelines][lesson-example] on proper formatting, ways to render the lesson locally, and even
how to write new episodes.

Please see the current list of [issues][FIXME] for ideas for contributing to this
Please see the current list of [issues](https://github.com/carpentries-incubator/machine-learning-novice-sklearn/issues) for ideas for contributing to this
repository. For making your contribution, we use the GitHub flow, which is
nicely explained in the chapter [Contributing to a Project](http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project) in Pro Git
by Scott Chacon.
Expand All @@ -40,12 +40,11 @@ As determined by the attendees of CarpentryConnect Manchester 2019, the proposed

### Supervised Learning

All models, objectives:

- What it is;
- when to use it and on what type of data;
- how to evaluate the fit, over/underfitting;
- computational complexity
All models, objectives:
- What it is;
- when to use it and on what type of data;
- how to evaluate the fit, over/underfitting;
- computational complexity


#### I. Regression
Expand Down
1 change: 1 addition & 0 deletions _episodes/01-introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,4 @@ Many machine learning techniques will give us an answer given some input data ev
> Write your answers into the etherpad.
{: .challenge}

{% include links.md %}
3 changes: 3 additions & 0 deletions _episodes/02-regression.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Results of linear regression:
x_sum= 26 y_sum= 41 x_sq_sum= 168 xy_sum= 263
m= 1.5182926829268293 c= 0.30487804878048763
~~~
{: .output}

### Testing the accuracy of a linear regression model

Expand Down Expand Up @@ -483,3 +484,5 @@ The process_data function gave us a choice of plotting either the logarithmic or
> Do you think its a good idea to remove these outliers from your model?
> How might you do this automatically?
{: .challenge}

{% include links.md %}
4 changes: 4 additions & 0 deletions _episodes/03-introducing-sklearn.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Now lets replace
~~~
error = measure_error(life_expectancy, linear_data)
~~~
{: .language-python}


with

Expand Down Expand Up @@ -281,3 +283,5 @@ To measure the error lets calculate the RMS error on both the linear and polynom
> > ![China 2001-2016 predictions](../fig/polynomial_china_overprediction.png)
> {: .solution}
{: .challenge}

{% include links.md %}
6 changes: 1 addition & 5 deletions _episodes/04-clustering.md
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,4 @@ plt.show()
> {: .solution}
{: .challenge}






{% include links.md %}
6 changes: 6 additions & 0 deletions _episodes/05-dimensionality-reduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ keypoints:
- "PCA is a dimensionality reduction technique"
- "TSNE is another dimensionality reduction technique"
---

# Placeholder text

This will hopefully pass lesson-check

{% include links.md %}
Original file line number Diff line number Diff line change
Expand Up @@ -322,17 +322,17 @@ Now inside the loop we can select the data by doing `data_train = data[train]` a

data_test = data[test]
labels_test = labels[test]
~~~
{: .language-python}
~~~
{: .language-python}


Finally we need to train the classifier with the selected training data and then score it against the test data. The scores for each set of test data should be similar.
Finally we need to train the classifier with the selected training data and then score it against the test data. The scores for each set of test data should be similar.

~~~
~~~
mlp.fit(data_train,labels_train)
print("Testing set score", mlp.score(data_test, labels_test))
~~~
{: .language-python}
~~~
{: .language-python}

Once we've established that cross validation was ok we can go ahead and train using the entire dataset by doing `mlp.fit(data,labels)`.

Expand Down Expand Up @@ -383,5 +383,4 @@ Google, Microsoft, Amazon and many others now have Cloud based Application Progr
> Does it do any better/worse than Google?
{: .challenge}



{% include links.md %}
3 changes: 1 addition & 2 deletions _episodes/06-ethics.md → _episodes/07-ethics.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,4 @@ Some questions you might want to ask yourself (and which an ethics committee mig
> Write down your group's answers in the etherpad.
{: .challenge}



{% include links.md %}
1 change: 1 addition & 0 deletions _episodes/07-learn-more.md → _episodes/08-learn-more.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ introduction to the key concepts in machine learning from Amazon.

* [Azure AI](https://azure.microsoft.com/en-gb/overview/ai-platform/) - Microsoft's Cloud based AI platform.

{% include links.md %}
2 changes: 1 addition & 1 deletion _extras/discuss.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Discussion
---
FIXME


{% include links.md %}
40 changes: 8 additions & 32 deletions aio.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,13 @@
---
permalink: /aio/index.html
---

{% include base_path.html %}

<script>
window.onload = function() {
var lesson_episodes = [
{% for episode in site.episodes %}
"{{ episode.url}}"{% unless forloop.last %},{% endunless %}
{% endfor %}
];
var xmlHttp = []; /* Required since we are going to query every episode. */
for (i=0; i < lesson_episodes.length; i++) {
xmlHttp[i] = new XMLHttpRequest();
xmlHttp[i].episode = lesson_episodes[i]; /* To enable use this later. */
xmlHttp[i].onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var article_here = document.getElementById(this.episode);
var parser = new DOMParser();
var htmlDoc = parser.parseFromString(this.responseText,"text/html");
var htmlDocArticle = htmlDoc.getElementsByTagName("article")[0];
article_here.innerHTML = htmlDocArticle.innerHTML;
}
}
var episode_url = "{{ relative_root_path }}" + lesson_episodes[i];
xmlHttp[i].open("GET", episode_url);
xmlHttp[i].send(null);
}
}
</script>
{% comment %}
Create an anchor for every episode.
As a maintainer, you don't need to edit this file.
If you notice that something doesn't work, please
open an issue: https://github.com/carpentries/styles/issues/new
{% endcomment %}
{% for episode in site.episodes %}
<article id="{{ episode.url }}"></article>
{% endfor %}

{% include base_path.html %}

{% include aio-script.md %}
Loading