Repository: incubator-predictionio Updated Branches: refs/heads/develop 2dfcb8778 -> 1e0d43580
Added auto generated engine template gallery to docs Project: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/commit/070a97d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/tree/070a97d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-predictionio/diff/070a97d5 Branch: refs/heads/develop Commit: 070a97d5cb80a190f39af4fa827274d8a705f3d8 Parents: c508c79 Author: Marcin ZiemiÅski <ziem...@gmail.com> Authored: Wed Jul 20 08:55:24 2016 -0700 Committer: Marcin ZiemiÅski <ziem...@gmail.com> Committed: Wed Jul 20 08:55:24 2016 -0700 ---------------------------------------------------------------------- .gitignore | 1 + docs/manual/config.rb | 10 ++ docs/manual/data/nav/main.yml | 2 +- docs/manual/source/gallery/gen_gallery_md.py | 156 ++++++++++++++++++++++ docs/manual/source/gallery/templates.yaml | 76 +++++++++++ 5 files changed, 244 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/070a97d5/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 475bf86..28e9464 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ quickstartapp/ .idea/ .templates-cache /vendors +/docs/manual/source/gallery/template-gallery.html.md http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/070a97d5/docs/manual/config.rb ---------------------------------------------------------------------- diff --git a/docs/manual/config.rb b/docs/manual/config.rb index e9cbe75..70757d2 100644 --- a/docs/manual/config.rb +++ b/docs/manual/config.rb @@ -76,6 +76,16 @@ end # Hacks +# Engine Template Gallery generation +current_dir = File.dirname(__FILE__) +gen_cmd = "python3 #{current_dir}/source/gallery/gen_gallery_md.py "\ + "#{current_dir}/source/gallery/templates.yaml "\ + "#{current_dir}/source/gallery/template-gallery.html.md" +system(gen_cmd) +if $? != 0 + raise 'Could not build template-gallery.html.md' +end + # https://github.com/middleman/middleman/issues/612 Slim::Engine.disable_option_validator! http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/070a97d5/docs/manual/data/nav/main.yml ---------------------------------------------------------------------- diff --git a/docs/manual/data/nav/main.yml b/docs/manual/data/nav/main.yml index c9f4485..f088bad 100644 --- a/docs/manual/data/nav/main.yml +++ b/docs/manual/data/nav/main.yml @@ -165,7 +165,7 @@ root: children: - body: 'Browse' - url: 'http://templates.prediction.io' + url: '/gallery/template-gallery/' - body: 'Submit your Engine as a Template' url: '/community/submit-template/' http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/070a97d5/docs/manual/source/gallery/gen_gallery_md.py ---------------------------------------------------------------------- diff --git a/docs/manual/source/gallery/gen_gallery_md.py b/docs/manual/source/gallery/gen_gallery_md.py new file mode 100644 index 0000000..a7bc919 --- /dev/null +++ b/docs/manual/source/gallery/gen_gallery_md.py @@ -0,0 +1,156 @@ +import yaml +import sys +import urllib.parse as urlparse + +INTRO = \ +"""\ +--- +title: Engine Template Gallery +--- +""" + +UNSUPERVISED = \ +""" +<div id='unsupervised-learning'/> + +## Unsupervised Learning +""" +CLASSIFICATION = \ +""" +<div id='classification'/> + +## Classification +""" + +REGRESSION = \ +""" +<div id='regression'/> + +## Regression +""" + +RECOMMENDER_SYSTEMS = \ +""" +<div id='recommenders'/> + +## Recommender Systems +""" + +NLP = \ +""" +<div id='nlp'/> + +## Natural Language Processing +""" + +TEMPLATE_INTRO = \ +"""#### ***[{name}]({repo})*** """ + +STAR_BUTTON = \ +""" +<iframe src="https://ghbtns.com/github-btn.html?user={user}&repo={repo}&\ +type=star&count=true" frameborder="0" align="middle" scrolling="0" width="170px" height="20px"></iframe> + +""" + +TEMPLATE_DETAILS = \ +""" +{description} + +Type | Language | License | Status | PIO min version +:----: | :-----:| :-----: | :----: | :-------------: +{type} | {language} | {license} | {status} | {pio_min_version} + +""" + +SECTION_SEPARATOR = \ +""" +<br/> +""" + +class Template: + + def __init__(self, engine): + for key, val in engine.items(): + setattr(self, key, val) + + self.tags = list(map(lambda s: s.lower(), self.tags)) + self.has_github = True if self.parse_github() else False + + def parse_github(self): + pr = urlparse.urlparse(self.repo) + if pr.netloc == 'github.com': + path = pr.path.split('/') + assert(len(path) >= 3) + self.github_user = path[1] + self.github_repo = path[2] + return True + else: + return False + +def write_template(mdfile, template): + intro = TEMPLATE_INTRO.format( + name=template.name, + repo=template.repo) + if template.has_github: + intro += STAR_BUTTON.format( + user=template.github_user, + repo=template.github_repo) + mdfile.write(intro) + mdfile.write(TEMPLATE_DETAILS.format( + description=template.description, + type=template.type, + language=template.language, + license=template.license, + status=template.status, + pio_min_version=template.pio_min_version, + )) + +def write_templates(mdfile, templates): + for t in templates: + write_template(mdfile, t) + +def write_markdown(mdfile, templates): + classification = [engine for engine in templates if "classification" in engine.tags] + regression = [engine for engine in templates if "regression" in engine.tags] + unsupervised = [engine for engine in templates if "unsupervised" in engine.tags] + recommenders = [engine for engine in templates if "recommender" in engine.tags] + nlps = [engine for engine in templates if "nlp" in engine.tags] + + mdfile.write(INTRO) + + mdfile.write(CLASSIFICATION) + write_templates(mdfile, classification) + + mdfile.write(SECTION_SEPARATOR) + + mdfile.write(REGRESSION) + write_templates(mdfile, regression) + + mdfile.write(SECTION_SEPARATOR) + + mdfile.write(UNSUPERVISED) + write_templates(mdfile, unsupervised) + + mdfile.write(SECTION_SEPARATOR) + + mdfile.write(RECOMMENDER_SYSTEMS) + write_templates(mdfile, recommenders) + + mdfile.write(SECTION_SEPARATOR) + + mdfile.write(NLP) + write_templates(mdfile, nlps) + + +if __name__ == "__main__": + + in_file = sys.argv[1] + out_file = sys.argv[2] + + with open(in_file, 'r') as stream: + templates = yaml.load(stream) + parsed = [Template(position["template"]) for position in templates] + + with open(out_file, 'w') as mdfile: + write_markdown(mdfile, parsed) http://git-wip-us.apache.org/repos/asf/incubator-predictionio/blob/070a97d5/docs/manual/source/gallery/templates.yaml ---------------------------------------------------------------------- diff --git a/docs/manual/source/gallery/templates.yaml b/docs/manual/source/gallery/templates.yaml new file mode 100644 index 0000000..9cdf46e --- /dev/null +++ b/docs/manual/source/gallery/templates.yaml @@ -0,0 +1,76 @@ +- template: + name: E-Commerce Recommendation + repo: "https://github.com/PredictionIO/template-java-parallel-ecommercerecommendation" + description: |- + This engine template provides personalized recommendation for e-commerce applications with the following features by default: + + * Exclude out-of-stock items + * Provide recommendation to new users who sign up after the model is trained + * Recommend unseen items only (configurable) + * Recommend popular items if no information about the user is available + tags: [recommender] + type: Parallel + language: Java + license: "Apache Licence 2.0" + status: alpha + pio_min_version: 0.9.3 + +- template: + name: Similar Product + repo: "https://github.com/PredictionIO/template-scala-parallel-similarproduct" + description: |- + This engine template recommends products that are "similar" to the input product(s). Similarity is not defined by user or item attributes but by users' previous actions. By default, it uses 'view' action such that product A and B are considered similar if most users who view A also view B. The template can be customized to support other action types such as buy, rate, like..etc + tags: [recommender] + type: Parallel + language: Scala + license: "Apache Licence 2.0" + status: stable + pio_min_version: 0.9.2 + +- template: + name: Classification + repo: "https://github.com/PredictionIO/template-scala-parallel-classification" + description: |- + An engine template is an almost-complete implementation of an engine. PredictionIO's Classification Engine Template has integrated Apache Spark MLlib's Naive Bayes algorithm by default. + tags: [classification] + type: Parallel + language: Scala + license: "Apache Licence 2.0" + status: stable + pio_min_version: 0.9.2 + +- template: + name: MLLib-LinearRegression + repo: "https://github.com/RAditi/PredictionIO-MLLib-LinReg-Template" + description: |- + This template uses the linear regression with stochastic gradient descent algorithm from MLLib to make predictions on real-valued data based on features (explanatory variables) + tags: [regression] + type: Parallel + language: Scala + license: "Apache Licence 2.0" + status: alpha + pio_min_version: 0.9.1 + +- template: + name: Text Classification + repo: "https://github.com/PredictionIO/template-scala-parallel-textclassification" + description: |- + Use this engine for general text classification purposes. Uses OpenNLP library for text vectorization, includes t.f.-i.d.f.-based feature transformation and reduction, and uses Spark MLLib's Multinomial Naive Bayes implementation for classification. + tags: [nlp] + type: Parallel + language: Scala + license: "Apache Licence 2.0" + status: alpha + pio_min_version: 0.9.2 + +- template: + name: MLlibKMeansClustering + repo: "https://github.com/sahiliitm/predictionio-MLlibKMeansClusteringTemplate" + description: |- + This is a template which demonstrates the use of K-Means clustering algorithm which can be deployed on a spark-cluster using prediction.io. + tags: [unsupervised] + type: Parallel + language: Scala + license: "Apache Licence 2.0" + status: alpha + pio_min_version: '-'