├── Bible-Verse-Prediction-ML-App ├── app.py ├── data │ ├── kjv_cleandata.csv │ └── kjvmindata.csv ├── models │ └── biblepredictionNV_model.pkl ├── static │ ├── css │ │ ├── custom.css │ │ ├── materialize.css │ │ └── materialize.min.css │ └── js │ │ ├── init.js │ │ ├── materialize.js │ │ └── materialize.min.js └── templates │ └── index.html ├── Bible-Verse-Prediction-Machine-Learning-App ├── app.py ├── data │ ├── kjv_cleandata.csv │ └── kjvmindata.csv ├── models │ └── biblepredictionNV_model.pkl ├── static │ ├── css │ │ ├── custom.css │ │ ├── materialize.css │ │ └── materialize.min.css │ └── js │ │ ├── init.js │ │ ├── materialize.js │ │ └── materialize.min.js └── templates │ └── index.html ├── Build-n-Deploy-Flask-App-with-Waypoint ├── Dockerfile ├── README.md ├── app │ ├── app.py │ └── templates │ │ ├── index.html │ │ ├── preview.html │ │ ├── previewer.html │ │ └── result.html ├── images │ ├── screenshot01.png │ ├── screenshot02.png │ └── screenshot03.png ├── requirements.txt ├── waypoint.hcl └── waypoint_tut_workflow_jcharistech2.png ├── Deploying ML Flask App to GCP ├── README.txt ├── app.yaml ├── main.py ├── requirements.txt └── templates │ ├── index.html │ └── results.html ├── DisplaCify_App-Using-Displacy-in-Flask ├── README.md ├── app.py ├── images │ ├── screenshot01.png │ ├── screenshot02.png │ └── screenshot03.png └── templates │ ├── index.html │ ├── preview.html │ ├── previewer.html │ └── result.html ├── Embedding-Machine-Learning-Into-Express.js App ├── FinalDataset.json ├── app.js ├── data.json ├── package.json └── views │ ├── index.ejs │ └── results.ejs ├── Gender-Classifier-ML-App-with-Flask + Bootstrap ├── app.py ├── data │ ├── Gender Classification of Names With Machine Learning.ipynb │ └── names_dataset.csv ├── models │ ├── decisiontreemodel.pkl │ └── naivebayesgendermodel.pkl ├── static │ └── css │ │ └── styles.css └── templates │ ├── index.html │ └── results.html ├── Gender-Classifier-ML-App-with-Flask + Bootstrap ├── app.py ├── data │ ├── Gender Classification of Names With Machine Learning.ipynb │ ├── gender_vectorizer.pkl │ ├── naivebayesgendermodel.pkl │ └── names_dataset.csv ├── models │ ├── decisiontreemodel.pkl │ └── naivebayesgendermodel.pkl ├── static │ └── css │ │ └── styles.css └── templates │ ├── index.html │ └── results.html ├── Iris-Species-Predictor-ML-Flask-App-With-Materialize.css ├── app.py ├── data │ ├── ML -Supervised Learning with Iris Dataset.ipynb │ ├── dtree_model_iris.pkl │ ├── iris.csv │ ├── knn_model_iris.pkl │ ├── logit_model_iris.pkl │ └── svm_model_iris.pkl ├── static │ └── imgs │ │ ├── iris_setosa.jpg │ │ ├── iris_versicolor.jpg │ │ └── iris_virginica.jpg └── templates │ ├── index.html │ └── preview.html ├── Iris_EDA_Web_App ├── README.md ├── app.py ├── imgs │ ├── iris_setosa.jpg │ ├── iris_versicolor.jpg │ └── iris_virginica.jpg ├── iris.csv ├── iris_app.py ├── iris_setosa.jpg └── screenshots │ ├── home1.png │ ├── home2.png │ ├── home3.png │ ├── iris_eda_app_streamlit_python_JcharisTech.png │ └── iris_eda_desc.png ├── NLP-Based Flask App with TextBlob(Main Points and Sentiment Analysis) ├── app.py └── templates │ └── index.html ├── NLPIffy_NLP_Based_SpaCy_Flask_App&_API ├── __pycache__ │ └── app.cpython-35.pyc ├── app.py ├── static │ ├── css │ │ └── custom.css │ └── images │ │ ├── logo_nlpiffy01.png │ │ ├── logo_nlpiffy02.png │ │ ├── logo_nlpiffy03.png │ │ ├── logo_nlpiffy04.png │ │ ├── nlpiffy.png │ │ └── nlpiffy2.png └── templates │ ├── about.html │ ├── images.html │ ├── index.html │ └── restfulapidocs.html ├── Nationality_n_Gender Predictor_ML-WebApp ├── README.md ├── app.py ├── data │ └── Predicting_Nationality_Ethnicity_with_Names_Using_ML │ │ ├── Names_Dataset.csv │ │ ├── Predicting Nationality of Individuals Using their Names with ML.ipynb │ │ ├── nationality_logit_model.pkl │ │ └── nationality_nv_model.pkl ├── images │ ├── image1.png │ └── image2.png ├── models │ ├── gender_vectorizer.pkl │ ├── naivebayesgendermodel.pkl │ ├── nationality_logit_model.pkl │ ├── nationality_nv_model.pkl │ └── nationality_vectorizer.pkl ├── refactored_app.py └── templates │ ├── gender.html │ └── index.html ├── README.md ├── Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset) ├── Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop │ ├── app.py │ ├── app.pyc │ ├── static │ │ └── uploadsDB │ │ │ ├── filestorage.db │ │ │ ├── iris.csv │ │ │ └── pima-indians-diabetes.csv │ └── templates │ │ ├── details.html │ │ └── index.html └── Start- Semi-Automated-ML │ ├── app.py │ └── templates │ ├── details.html │ └── index.html ├── Serving_ML_Models_as_API_with_FastAPI ├── README.md ├── app.py ├── images │ ├── fastapi_tutorial_jcharistech01.png │ ├── fastapi_tutorial_jcharistech03.png │ ├── fastapi_tutorial_jcharistech04.png │ └── fastapi_tutorial_jcharistech06.png └── models │ ├── __init__.py │ ├── gender_nv_model.pkl │ └── gender_vectorizer.pkl ├── SpamDetector_ML_Package ├── README.md ├── Spam Detection with ML.ipynb ├── data │ └── spamdataset.csv ├── models │ ├── spam_detector_logit_model.pkl │ ├── spam_detector_nb_model.pkl │ ├── spam_detector_rf_model.pkl │ └── spam_vectorizer.pkl └── spamdetector │ ├── README.rst │ ├── poetry.lock │ ├── pyproject.toml │ ├── spamdetector │ ├── __init__.py │ ├── models │ │ ├── spam_detector_logit_model.pkl │ │ ├── spam_detector_nb_model.pkl │ │ ├── spam_detector_rf_model.pkl │ │ └── spam_vectorizer.pkl │ └── spamdetector.py │ └── tests │ ├── __init__.py │ └── test_spamdetector.py ├── Summaryzer_Text_Summarization_App ├── __pycache__ │ └── spacy_summarization.cpython-36.pyc ├── app.py ├── imagesforapp │ ├── Screenshot from 2019-01-02 16-41-28.png │ ├── Screenshot from 2019-01-02 16-42-12.png │ ├── Screenshot from 2019-01-02 16-43-05.png │ ├── Screenshot from 2019-01-02 16-43-22.png │ ├── Screenshot from 2019-01-02 16-44-13.png │ ├── Screenshot from 2019-01-02 16-44-37.png │ └── Screenshot from 2019-01-02 16-46-54.png ├── nltk_summarization.py ├── nltk_summarization.pyc ├── requirements.txt ├── spacy_summarization.py ├── spacy_summarization.pyc ├── spacy_summarizer.py ├── static │ ├── css │ │ ├── custom.css │ │ ├── materialize.css │ │ └── materialize.min.css │ └── js │ │ ├── init.js │ │ ├── materialize.js │ │ └── materialize.min.js └── templates │ ├── compare_summary.html │ └── index.html ├── Youtube-Spam-Detector-ML-Flask-App ├── YoutubeSpamMergedData.csv ├── app.py ├── data │ ├── .ipynb_checkpoints │ │ └── TextClassification-checkpoint.ipynb │ ├── TextClassification.ipynb │ ├── Youtube01-Psy.csv │ ├── Youtube02-KatyPerry.csv │ ├── Youtube03-LMFAO.csv │ ├── Youtube04-Eminem.csv │ ├── Youtube05-Shakira.csv │ ├── YoutubeSpamMergeddata.csv │ └── naivebayes_spam_model.pkl ├── static │ └── css │ │ └── styles.css └── templates │ ├── home.html │ └── result.html └── gender_classifier_mlapp_with_streamlit ├── README.md ├── app.py ├── female.png ├── icon.css ├── images ├── gc_app01.png ├── gc_app02.png └── gc_app04.png ├── male.png └── models ├── gender_vectorizer.pkl └── naivebayesgendermodel.pkl /Bible-Verse-Prediction-ML-App/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,request,url_for 2 | import pandas as pd 3 | import numpy as np 4 | 5 | # ML Packages 6 | from sklearn.feature_extraction.text import CountVectorizer 7 | from sklearn.externals import joblib 8 | 9 | # NLP 10 | from textblob import TextBlob 11 | 12 | app = Flask(__name__) 13 | 14 | 15 | @app.route('/') 16 | def index(): 17 | return render_template('index.html') 18 | 19 | 20 | @app.route('/predict',methods=["GET","POST"]) 21 | def predict(): 22 | df= pd.read_csv("data/kjvmindata.csv") 23 | # Features and Labels 24 | df_X = df.text 25 | df_Y = df.label 26 | 27 | # Vectorization 28 | corpus = df_X 29 | cv = CountVectorizer() 30 | X = cv.fit_transform(corpus) 31 | 32 | naivebayes_model = open("models/biblepredictionNV_model.pkl","rb") 33 | clf = joblib.load(naivebayes_model) 34 | 35 | if request.method == 'POST': 36 | raw_text = request.form['rawtext'] 37 | data = [raw_text] 38 | vect = cv.transform(data).toarray() 39 | my_prediction = clf.predict(vect) 40 | pred_score = clf.predict_proba(vect) 41 | nlp_text = TextBlob(raw_text) 42 | text_sentiment = nlp_text.sentiment.polarity 43 | verse_sentiment = text_sentiment 44 | 45 | return render_template('index.html',prediction=my_prediction,pred_score=pred_score,verse_sentiment=verse_sentiment,raw_text=raw_text) 46 | 47 | 48 | if __name__ == '__main__': 49 | app.run(debug=True) 50 | 51 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-ML-App/models/biblepredictionNV_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Bible-Verse-Prediction-ML-App/models/biblepredictionNV_model.pkl -------------------------------------------------------------------------------- /Bible-Verse-Prediction-ML-App/static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* Custom Stylesheet */ 2 | /** 3 | * Use this file to override Materialize files so you can update 4 | * the core Materialize files in the future 5 | * 6 | * Made By MaterializeCSS.com 7 | */ 8 | 9 | nav ul a, 10 | nav .brand-logo { 11 | color: #444; 12 | } 13 | 14 | p { 15 | line-height: 2rem; 16 | } 17 | 18 | .sidenav-trigger { 19 | color: #26a69a; 20 | } 21 | 22 | .parallax-container { 23 | min-height: 380px; 24 | line-height: 0; 25 | height: auto; 26 | color: rgba(255,255,255,.9); 27 | } 28 | .parallax-container .section { 29 | width: 100%; 30 | } 31 | 32 | @media only screen and (max-width : 992px) { 33 | .parallax-container .section { 34 | position: absolute; 35 | top: 40%; 36 | } 37 | #index-banner .section { 38 | top: 10%; 39 | } 40 | } 41 | 42 | @media only screen and (max-width : 600px) { 43 | #index-banner .section { 44 | top: 0; 45 | } 46 | } 47 | 48 | .icon-block { 49 | padding: 0 15px; 50 | } 51 | .icon-block .material-icons { 52 | font-size: inherit; 53 | } 54 | 55 | footer.page-footer { 56 | margin: 0; 57 | } 58 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-ML-App/static/js/init.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | $(function(){ 3 | 4 | $('.sidenav').sidenav(); 5 | $('.parallax').parallax(); 6 | // TABS INIT 7 | $('.tabs').tabs(); 8 | // CAROUSEL INIT 9 | $('.carousel.carousel-slider').carousel({ fullWidth: true }); 10 | // SLIDER INIT 11 | $('.slider').slider({ 12 | indicators: false, 13 | // we don't want the little dots to show 14 | height: 500, 15 | transition: 500, 16 | interval: 6000 17 | // how long the slide stays for 18 | }); 19 | 20 | 21 | }); // end of document ready 22 | })(jQuery); // end of jQuery name space 23 | 24 | 25 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-ML-App/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | BibleVerse Predictor 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 29 | 33 | 34 |
35 |
36 | 62 |
63 |
64 | 65 | 66 |
67 |
68 | 69 | 70 |
71 |
72 |
73 |

chrome_reader_mode

74 |
75 | 76 | 77 |
78 | 79 | 80 | 81 |
82 |
83 |
84 | 85 |
86 | 87 |
88 |
89 |
90 |

Your Verse was : {{ raw_text }}

91 |
92 | 93 |
94 | 95 |
96 |
97 | 98 | 99 | 100 | 101 |
102 |
103 |
104 |
105 |
106 |
107 | 116 |
117 |
118 |
Result
119 |

Testament of the Bible

120 | {% if prediction == 0 %} 121 | 122 | {% elif prediction == 1 %} 123 | 124 | {%endif%} 125 |

Score:{{ pred_score }}

126 |
127 |
128 |
Sentiment
129 |

Verse Sentiment

130 | 131 | 132 | 133 | 134 |
135 | 136 |
137 |
138 |
139 |
140 |
141 | 142 | 143 | 144 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-Machine-Learning-App/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,request,url_for 2 | import pandas as pd 3 | import numpy as np 4 | 5 | # ML Packages 6 | from sklearn.feature_extraction.text import CountVectorizer 7 | from sklearn.externals import joblib 8 | 9 | # NLP 10 | from textblob import TextBlob 11 | 12 | app = Flask(__name__) 13 | 14 | 15 | @app.route('/') 16 | def index(): 17 | return render_template('index.html') 18 | 19 | 20 | @app.route('/predict',methods=["GET","POST"]) 21 | def predict(): 22 | df= pd.read_csv("data/kjvmindata.csv") 23 | # Features and Labels 24 | df_X = df.text 25 | df_Y = df.label 26 | 27 | # Vectorization 28 | corpus = df_X 29 | cv = CountVectorizer() 30 | X = cv.fit_transform(corpus) 31 | 32 | naivebayes_model = open("models/biblepredictionNV_model.pkl","rb") 33 | clf = joblib.load(naivebayes_model) 34 | 35 | if request.method == 'POST': 36 | raw_text = request.form['rawtext'] 37 | data = [raw_text] 38 | vect = cv.transform(data).toarray() 39 | my_prediction = clf.predict(vect) 40 | pred_score = clf.predict_proba(vect) 41 | nlp_text = TextBlob(raw_text) 42 | text_sentiment = nlp_text.sentiment.polarity 43 | verse_sentiment = text_sentiment 44 | 45 | return render_template('index.html',prediction=my_prediction,pred_score=pred_score,verse_sentiment=verse_sentiment,raw_text=raw_text) 46 | 47 | 48 | if __name__ == '__main__': 49 | app.run(debug=True) 50 | 51 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-Machine-Learning-App/models/biblepredictionNV_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Bible-Verse-Prediction-Machine-Learning-App/models/biblepredictionNV_model.pkl -------------------------------------------------------------------------------- /Bible-Verse-Prediction-Machine-Learning-App/static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* Custom Stylesheet */ 2 | /** 3 | * Use this file to override Materialize files so you can update 4 | * the core Materialize files in the future 5 | * 6 | * Made By MaterializeCSS.com 7 | */ 8 | 9 | nav ul a, 10 | nav .brand-logo { 11 | color: #444; 12 | } 13 | 14 | p { 15 | line-height: 2rem; 16 | } 17 | 18 | .sidenav-trigger { 19 | color: #26a69a; 20 | } 21 | 22 | .parallax-container { 23 | min-height: 380px; 24 | line-height: 0; 25 | height: auto; 26 | color: rgba(255,255,255,.9); 27 | } 28 | .parallax-container .section { 29 | width: 100%; 30 | } 31 | 32 | @media only screen and (max-width : 992px) { 33 | .parallax-container .section { 34 | position: absolute; 35 | top: 40%; 36 | } 37 | #index-banner .section { 38 | top: 10%; 39 | } 40 | } 41 | 42 | @media only screen and (max-width : 600px) { 43 | #index-banner .section { 44 | top: 0; 45 | } 46 | } 47 | 48 | .icon-block { 49 | padding: 0 15px; 50 | } 51 | .icon-block .material-icons { 52 | font-size: inherit; 53 | } 54 | 55 | footer.page-footer { 56 | margin: 0; 57 | } 58 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-Machine-Learning-App/static/js/init.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | $(function(){ 3 | 4 | $('.sidenav').sidenav(); 5 | $('.parallax').parallax(); 6 | // TABS INIT 7 | $('.tabs').tabs(); 8 | // CAROUSEL INIT 9 | $('.carousel.carousel-slider').carousel({ fullWidth: true }); 10 | // SLIDER INIT 11 | $('.slider').slider({ 12 | indicators: false, 13 | // we don't want the little dots to show 14 | height: 500, 15 | transition: 500, 16 | interval: 6000 17 | // how long the slide stays for 18 | }); 19 | 20 | 21 | }); // end of document ready 22 | })(jQuery); // end of jQuery name space 23 | 24 | 25 | -------------------------------------------------------------------------------- /Bible-Verse-Prediction-Machine-Learning-App/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | BibleVerse Predictor 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 29 | 33 | 34 |
35 |
36 | 62 |
63 |
64 | 65 | 66 |
67 |
68 | 69 | 70 |
71 |
72 |
73 |

chrome_reader_mode

74 |
75 | 76 | 77 |
78 | 79 | 80 | 81 |
82 |
83 |
84 | 85 |
86 | 87 |
88 |
89 |
90 |

Your Verse was : {{ raw_text }}

91 |
92 | 93 |
94 | 95 |
96 |
97 | 98 | 99 | 100 | 101 |
102 |
103 |
104 |
105 |
106 |
107 | 116 |
117 |
118 |
Result
119 |

Testament of the Bible

120 | {% if prediction == 0 %} 121 | 122 | {% elif prediction == 1 %} 123 | 124 | {%endif%} 125 |

Score:{{ pred_score }}

126 |
127 |
128 |
Sentiment
129 |

Verse Sentiment

130 | 131 | 132 | 133 | 134 |
135 | 136 |
137 |
138 |
139 |
140 |
141 | 142 | 143 | 144 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.04 2 | 3 | ENV LC_ALL=C.UTF-8 4 | ENV LANG=C.UTF-8 5 | 6 | RUN apt-get update -y && apt-get install python3-pip -y 7 | 8 | ADD requirements.txt /app/ 9 | WORKDIR /app 10 | RUN /bin/bash -c "pip3 install --no-cache-dir -r requirements.txt" 11 | 12 | RUN python3 -m spacy download en_core_web_sm 13 | 14 | ADD /app/ /app/ 15 | 16 | 17 | ENTRYPOINT [ "python3" ] 18 | 19 | CMD [ "app.py" ] 20 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/README.md: -------------------------------------------------------------------------------- 1 | ### DisplaCify App 2 | #### Using Displacy in Flask 3 | 4 | + This is to demonstrate how to render Named Entity Recognition with Displacy in Flask 5 | 6 | #### Requirements 7 | + Flask 8 | + Flask-Markdown 9 | + Spacy 10 | 11 | 12 | #### Images 13 | ![](images/screenshot01.png) 14 | 15 | 16 | ![](images/screenshot02.png) 17 | 18 | 19 | 20 | ![](images/screenshot03.png) 21 | 22 | 23 | #### Build and Deploy with Waypoint 24 | 25 | ![](waypoint_tut_workflow_jcharistech2.png) 26 | 27 | #### Requirements For Deployment 28 | + App 29 | + requirements.txt 30 | + Dockerfile 31 | + waypoint.hcl 32 | 33 | #### Steps 34 | ```bash 35 | docker pull hashicorp/waypoint:latest 36 | ``` 37 | 38 | #### Set up Waypoint Server For Docker 39 | ```bash 40 | waypoint install -platform=docker -accept-tos 41 | ``` 42 | #### Initialize and Build 43 | ```bash 44 | waypoint init 45 | waypoint up 46 | ``` 47 | #### View UI 48 | ```bash 49 | waypoint ui -authenticate 50 | ``` 51 | 52 | #### Access Container 53 | ```bash 54 | waypoint exec bash 55 | ``` 56 | 57 | #### Destroy Deployment 58 | ```bash 59 | waypoint destroy 60 | ``` 61 | 62 | #### By 63 | + Jesse E.Agbe(JCharis) 64 | + Jesus Saves@JCharisTech 65 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/app/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,url_for,render_template,request 2 | import spacy 3 | from spacy import displacy 4 | nlp = spacy.load('en_core_web_sm') 5 | import json 6 | 7 | HTML_WRAPPER = """
{}
""" 8 | 9 | from flaskext.markdown import Markdown 10 | 11 | application = Flask(__name__) 12 | Markdown(application) 13 | 14 | 15 | # def analyze_text(text): 16 | # return nlp(text) 17 | 18 | @application.route('/') 19 | def index(): 20 | # raw_text = "Bill Gates is An American Computer Scientist since 1986" 21 | # docx = nlp(raw_text) 22 | # html = displacy.render(docx,style="ent") 23 | # html = html.replace("\n\n","\n") 24 | # result = HTML_WRAPPER.format(html) 25 | 26 | return render_template('index.html') 27 | 28 | 29 | @application.route('/extract',methods=["GET","POST"]) 30 | def extract(): 31 | if request.method == 'POST': 32 | raw_text = request.form['rawtext'] 33 | docx = nlp(raw_text) 34 | html = displacy.render(docx,style="ent") 35 | html = html.replace("\n\n","\n") 36 | result = HTML_WRAPPER.format(html) 37 | 38 | return render_template('result.html',rawtext=raw_text,result=result) 39 | 40 | 41 | @application.route('/previewer') 42 | def previewer(): 43 | return render_template('previewer.html') 44 | 45 | @application.route('/preview',methods=["GET","POST"]) 46 | def preview(): 47 | if request.method == 'POST': 48 | newtext = request.form['newtext'] 49 | result = newtext 50 | 51 | return render_template('preview.html',newtext=newtext,result=result) 52 | 53 | 54 | if __name__ == '__main__': 55 | application.run(host='0.0.0.0',debug=True) -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/app/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DisplaCify App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 | 65 |
66 |
67 |

Displaying NER in Flask

68 |

Using Spacy's Named Entity Recognition by JCharisTech

69 |

Refresh »

70 |
71 |
72 |
73 |
74 |
75 | 76 |
77 | 79 | 80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/app/templates/preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NLPiffy App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 |
65 |
66 | 67 |
68 |
69 |
70 |
71 |

Original Data

72 |

{{ newtext }}

73 | 74 |
75 |
76 |
77 |
78 |

MarkDown Preview

79 |

{{ result|markdown }}

80 | 81 |
82 |
83 |
84 | 85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/app/templates/previewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NLPiffy App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 63 |
64 |
65 |
66 |
67 |
68 | 69 |
70 | 72 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/app/templates/result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DisplaCify App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 | 65 |
66 |
67 |

Displaying NER in Flask

68 |

Using Spacy's Named Entity Recognition

69 |

Refresh »

70 |
71 |
72 |
73 |
74 | 75 | {% filter markdown %} 76 | #### Named Entity Recog 77 | ============= 78 | {% endfilter %} 79 |
80 | 81 | 82 |
83 |
84 |
85 |
86 |

Original Data

87 |

{{ rawtext }}

88 | 89 |
90 |
91 |
92 |
93 |

Result of Data

94 |

{{ result|markdown }}

95 | 96 |
97 |
98 |
99 | 100 | 101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot01.png -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot02.png -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Build-n-Deploy-Flask-App-with-Waypoint/images/screenshot03.png -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==1.1.2 2 | spacy==2.3.4 3 | Flask_Bcrypt==0.7.1 4 | gunicorn 5 | gevent 6 | Flask-Markdown 7 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/waypoint.hcl: -------------------------------------------------------------------------------- 1 | # The name of your project. A project typically maps 1:1 to a VCS repository. 2 | # This name must be unique for your Waypoint server. If you're running in 3 | # local mode, this must be unique to your machine. 4 | project = "displacify_app" 5 | 6 | # Labels can be specified for organizational purposes. 7 | # labels = { "foo" = "bar" } 8 | 9 | # An application to deploy. 10 | app "displacify_app" { 11 | # Build specifies how an application should be deployed. In this case, 12 | # we'll build using a Dockerfile and keeping it in a local registry. 13 | build { 14 | use "docker" {} 15 | 16 | } 17 | 18 | # Deploy to Docker 19 | deploy { 20 | use "docker" { 21 | service_port = 5000 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Build-n-Deploy-Flask-App-with-Waypoint/waypoint_tut_workflow_jcharistech2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Build-n-Deploy-Flask-App-with-Waypoint/waypoint_tut_workflow_jcharistech2.png -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/README.txt: -------------------------------------------------------------------------------- 1 | To Deploy the app you can run 2 | 3 | 4 | >> gcloud app deploy 5 | 6 | Follow the prompt instructions to set it up 7 | 8 | >> gcloud app browse 9 | 10 | or Paste your url to new tab -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/app.yaml: -------------------------------------------------------------------------------- 1 | entrypoint: "gunicorn -b :$PORT main:app" 2 | env: flex 3 | runtime: python 4 | runtime_config: 5 | python_version: 3 -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/main.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,request,url_for 2 | 3 | #EDA Packages 4 | import pandas as pd 5 | import numpy as np 6 | 7 | # ML Packages 8 | from sklearn.feature_extraction.text import CountVectorizer 9 | from sklearn.naive_bayes import MultinomialNB 10 | 11 | app = Flask(__name__) 12 | 13 | @app.route("/") 14 | def index(): 15 | return render_template("index.html") 16 | 17 | @app.route("/",methods=['POST']) 18 | def predict(): 19 | # Link to dataset from github 20 | url = "https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/master/Youtube-Spam-Detector-ML-Flask-App/YoutubeSpamMergedData.csv" 21 | df= pd.read_csv(url) 22 | df_data = df[["CONTENT","CLASS"]] 23 | # Features and Labels 24 | df_x = df_data['CONTENT'] 25 | df_y = df_data.CLASS 26 | # Extract Feature With CountVectorizer 27 | corpus = df_x 28 | cv = CountVectorizer() 29 | X = cv.fit_transform(corpus) # Fit the Data 30 | from sklearn.model_selection import train_test_split 31 | X_train, X_test, y_train, y_test = train_test_split(X, df_y, test_size=0.33, random_state=42) 32 | #Naive Bayes Classifier 33 | from sklearn.naive_bayes import MultinomialNB 34 | clf = MultinomialNB() 35 | clf.fit(X_train,y_train) 36 | clf.score(X_test,y_test) 37 | #Alternative Usage of Saved Model 38 | # ytb_model = open("naivebayes_spam_model.pkl","rb") 39 | # clf = joblib.load(ytb_model) 40 | 41 | if request.method == 'POST': 42 | comment = request.form['comment'] 43 | data = [comment] 44 | vect = cv.transform(data).toarray() 45 | my_prediction = clf.predict(vect) 46 | return render_template('results.html',prediction = my_prediction,comment = comment) 47 | 48 | 49 | 50 | if __name__ == '__main__': 51 | app.run(host="127.0.0.1",port=8080,debug=True) -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==1.1.0 2 | gunicorn==19.6.0 3 | pandas==0.22.0 4 | numpy==1.11.2 5 | scipy==0.18.1 6 | scikit-learn>=0.18 7 | -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Home 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | ML App 14 |
15 |

Spam Detection For Youtube Comments

16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 |

Enter Your Comment Here

24 | 25 | 26 |
27 | 28 | 29 | 30 |
31 | 32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Deploying ML Flask App to GCP/templates/results.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |
12 | ML App 13 |
14 |

Spam Detection For Youtube Comments

15 | 16 |
17 |
18 |

Results for Comment

19 |
20 | 21 | 22 | 23 | {% if prediction == 1%} 24 |

Spam

25 | {% elif prediction == 0%} 26 |

Not a Spam (It is a Ham)

27 | {% endif %} 28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/README.md: -------------------------------------------------------------------------------- 1 | ### DisplaCify App 2 | #### Using Displacy in Flask 3 | 4 | + This is to demonstrate how to render Named Entity Recognition with Displacy in Flask 5 | 6 | #### Requirements 7 | + Flask 8 | + Flask-Markdown 9 | + Spacy 10 | 11 | 12 | #### Images 13 | ![](images/screenshot01.png) 14 | 15 | 16 | ![](images/screenshot02.png) 17 | 18 | 19 | 20 | ![](images/screenshot03.png) 21 | 22 | 23 | #### By 24 | + Jesse E.Agbe(JCharis) 25 | + Jesus Saves@JCharisTech -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,url_for,render_template,request 2 | import spacy 3 | from spacy import displacy 4 | nlp = spacy.load('en') 5 | import json 6 | 7 | HTML_WRAPPER = """
{}
""" 8 | 9 | from flaskext.markdown import Markdown 10 | 11 | app = Flask(__name__) 12 | Markdown(app) 13 | 14 | 15 | # def analyze_text(text): 16 | # return nlp(text) 17 | 18 | @app.route('/') 19 | def index(): 20 | # raw_text = "Bill Gates is An American Computer Scientist since 1986" 21 | # docx = nlp(raw_text) 22 | # html = displacy.render(docx,style="ent") 23 | # html = html.replace("\n\n","\n") 24 | # result = HTML_WRAPPER.format(html) 25 | 26 | return render_template('index.html') 27 | 28 | 29 | @app.route('/extract',methods=["GET","POST"]) 30 | def extract(): 31 | if request.method == 'POST': 32 | raw_text = request.form['rawtext'] 33 | docx = nlp(raw_text) 34 | html = displacy.render(docx,style="ent") 35 | html = html.replace("\n\n","\n") 36 | result = HTML_WRAPPER.format(html) 37 | 38 | return render_template('result.html',rawtext=raw_text,result=result) 39 | 40 | 41 | @app.route('/previewer') 42 | def previewer(): 43 | return render_template('previewer.html') 44 | 45 | @app.route('/preview',methods=["GET","POST"]) 46 | def preview(): 47 | if request.method == 'POST': 48 | newtext = request.form['newtext'] 49 | result = newtext 50 | 51 | return render_template('preview.html',newtext=newtext,result=result) 52 | 53 | 54 | if __name__ == '__main__': 55 | app.run(debug=True) -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/images/screenshot01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/DisplaCify_App-Using-Displacy-in-Flask/images/screenshot01.png -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/images/screenshot02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/DisplaCify_App-Using-Displacy-in-Flask/images/screenshot02.png -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/images/screenshot03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/DisplaCify_App-Using-Displacy-in-Flask/images/screenshot03.png -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DisplaCify App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 | 65 |
66 |
67 |

Displaying NER in Flask

68 |

Using Spacy's Named Entity Recognition

69 |

Refresh »

70 |
71 |
72 |
73 |
74 |
75 | 76 |
77 | 79 | 80 | 81 |
82 |
83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/templates/preview.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NLPiffy App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 |
65 |
66 | 67 |
68 |
69 |
70 |
71 |

Original Data

72 |

{{ newtext }}

73 | 74 |
75 |
76 |
77 |
78 |

MarkDown Preview

79 |

{{ result|markdown }}

80 | 81 |
82 |
83 |
84 | 85 | 86 |
87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/templates/previewer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | NLPiffy App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 63 |
64 |
65 |
66 |
67 |
68 | 69 |
70 | 72 | 73 | 74 |
75 |
76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /DisplaCify_App-Using-Displacy-in-Flask/templates/result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DisplaCify App 5 | 6 | 7 | 8 | 9 | 10 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 62 |
63 |
64 | 65 |
66 |
67 |

Displaying NER in Flask

68 |

Using Spacy's Named Entity Recognition

69 |

Refresh »

70 |
71 |
72 |
73 |
74 | 75 | {% filter markdown %} 76 | #### Named Entity Recog 77 | ============= 78 | {% endfilter %} 79 |
80 | 81 | 82 |
83 |
84 |
85 |
86 |

Original Data

87 |

{{ rawtext }}

88 | 89 |
90 |
91 |
92 |
93 |

Result of Data

94 |

{{ result|markdown }}

95 | 96 |
97 |
98 |
99 | 100 | 101 |
102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /Embedding-Machine-Learning-Into-Express.js App/app.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var bodyParser = require('body-parser'); 3 | 4 | //ML Aspects with Brainjs 5 | const brain = require('brain.js'); 6 | const data = require('./data.json'); 7 | 8 | const network = new brain.recurrent.LSTM(); 9 | 10 | const trainingData = data.map(item => ({ 11 | input: item.text, 12 | output: item.category 13 | })); 14 | 15 | network.train(trainingData, { 16 | iterations: 2000 17 | }); 18 | 19 | 20 | // Express App Initialized 21 | var app = express(); 22 | var urlencodedParser = bodyParser.urlencoded({ extended: false }) 23 | app.set('view engine','ejs'); 24 | 25 | 26 | app.get('/',function(req,res){ 27 | // res.send('Hello world this is Express'); 28 | res.render('index'); 29 | }); 30 | 31 | 32 | app.get('/predict',function(req,res){ 33 | console.log(req.query); 34 | res.render('index'); 35 | }) 36 | 37 | // Using Body Parser to Parse our data 38 | app.post('/predict',urlencodedParser,function(req,res){ 39 | console.log(req.body); 40 | const output = network.run(req.body.message); 41 | console.log(`Category: ${output}`); 42 | 43 | res.render('results',{mydata:req.body.message,resultdata:output}); 44 | }) 45 | 46 | 47 | 48 | app.listen(4000,function(){ 49 | console.log("Listening on localhost:4000"); 50 | }); -------------------------------------------------------------------------------- /Embedding-Machine-Learning-Into-Express.js App/data.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "text": "my unit test failed", 4 | "category": "software" 5 | }, 6 | { 7 | "text": "tried the program, but it was buggy", 8 | "category": "software" 9 | }, 10 | { 11 | "text": "i need a new power supply", 12 | "category": "hardware" 13 | }, 14 | { 15 | "text": "the drive has a 2TB capacity", 16 | "category": "hardware" 17 | }, 18 | { 19 | "text": "unit-tests", 20 | "category": "software" 21 | }, 22 | { 23 | "text": "program", 24 | "category": "software" 25 | }, 26 | { 27 | "text": "power supply", 28 | "category": "hardware" 29 | }, 30 | { 31 | "text": "drive", 32 | "category": "hardware" 33 | }, 34 | { 35 | "text": "it needs more memory", 36 | "category": "hardware" 37 | }, 38 | { 39 | "text": "code", 40 | "category": "software" 41 | }, 42 | { 43 | "text": "i found some bugs in the code", 44 | "category": "software" 45 | }, 46 | { 47 | "text": "i swapped the memory", 48 | "category": "hardware" 49 | }, 50 | { 51 | "text": "i tested the code", 52 | "category": "software" 53 | } 54 | ] 55 | -------------------------------------------------------------------------------- /Embedding-Machine-Learning-Into-Express.js App/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "expressmlapp", 3 | "version": "1.0.0", 4 | "description": "Embedding ML in Express.js", 5 | "main": "app.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Jesse JCharis", 10 | "license": "ISC", 11 | "dependencies": { 12 | "body-parser": "^1.18.3", 13 | "brain": "^1.0.0", 14 | "brain.js": "^1.2.8", 15 | "brainjs": "^0.7.4", 16 | "express": "^4.16.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Embedding-Machine-Learning-Into-Express.js App/views/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Embedding ML in Express 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |

Machine Learning Web App with Express.js

16 |

ML Web App

17 | Reset 18 |
19 | 20 |
21 |
22 | 23 | 24 | 25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | 33 | 34 | 35 |
36 | 37 | 38 |
39 |
40 |
41 |
42 |
43 |
44 | 45 | 46 | -------------------------------------------------------------------------------- /Embedding-Machine-Learning-Into-Express.js App/views/results.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Express App 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |
15 |

Machine Learning Web App with Express.js

16 |

ML Web App

17 | Reset 18 |
19 | 20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
Results of Prediction
28 | 29 |

Your Message was: <%= mydata %>

30 |
31 |

<%= resultdata %>

32 |
33 |
34 |
35 |
36 | 37 |
38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | from flask_bootstrap import Bootstrap 3 | import pandas as pd 4 | import numpy as np 5 | 6 | # ML Packages 7 | from sklearn.feature_extraction.text import CountVectorizer 8 | from sklearn.externals import joblib 9 | 10 | 11 | app = Flask(__name__) 12 | Bootstrap(app) 13 | 14 | 15 | @app.route('/') 16 | def index(): 17 | return render_template('index.html') 18 | 19 | @app.route('/predict', methods=['POST']) 20 | def predict(): 21 | df= pd.read_csv("data/names_dataset.csv") 22 | # Features and Labels 23 | df_X = df.name 24 | df_Y = df.sex 25 | 26 | # Vectorization 27 | corpus = df_X 28 | cv = CountVectorizer() 29 | X = cv.fit_transform(corpus) 30 | 31 | # Loading our ML Model 32 | naivebayes_model = open("models/naivebayesgendermodel.pkl","rb") 33 | clf = joblib.load(naivebayes_model) 34 | 35 | # Receives the input query from form 36 | if request.method == 'POST': 37 | namequery = request.form['namequery'] 38 | data = [namequery] 39 | vect = cv.transform(data).toarray() 40 | my_prediction = clf.predict(vect) 41 | return render_template('results.html',prediction = my_prediction,name = namequery.upper()) 42 | 43 | 44 | if __name__ == '__main__': 45 | app.run(debug=True) -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /models/decisiontreemodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap /models/decisiontreemodel.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /models/naivebayesgendermodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap /models/naivebayesgendermodel.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /static/css/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font:15px/1.5 Arial, Helvetica,sans-serif; 3 | padding: 0px; 4 | background-color:#f4f3f3; 5 | } 6 | 7 | 8 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | {% block content %} 3 | 4 |
5 |
6 |

Gender Classifier

7 |

Using Machine Learning to Classify Gender

8 |
9 |

ML App.

10 |
11 | 12 | 13 |
14 |
15 |
Gender Classifier
16 |
17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 | 32 | 33 | {% endblock %} 34 | 35 | {% block styles %} 36 | {{super()}} 37 | 39 | {% endblock %} 40 | 41 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap /templates/results.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | {% block content %} 3 | 4 | 5 | 6 |
7 |
8 |

Gender Classifier

9 |

Using Machine Learning to Classify Gender

10 |
11 |

ML App.

12 |
13 | 14 |
15 |
16 | Results 17 |
18 |
19 |
Gender Classifier
20 |
21 |

24 | 25 | 26 | {% if prediction == 0 %} 27 |

30 | Female 31 | {% elif prediction == 1 %} 32 |

35 | Male 36 | {% endif%} 37 |
38 | 39 | 40 | 43 |
44 | 45 | 46 | {% endblock %} 47 | 48 | {% block styles %} 49 | {{super()}} 50 | 52 | {% endblock %} 53 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | from flask_bootstrap import Bootstrap 3 | import pandas as pd 4 | import numpy as np 5 | 6 | # ML Packages 7 | from sklearn.feature_extraction.text import CountVectorizer 8 | from sklearn.externals import joblib 9 | 10 | 11 | app = Flask(__name__) 12 | Bootstrap(app) 13 | 14 | 15 | @app.route('/') 16 | def index(): 17 | return render_template('index.html') 18 | 19 | @app.route('/predict', methods=['POST']) 20 | def predict(): 21 | df= pd.read_csv("data/names_dataset.csv") 22 | # Features and Labels 23 | df_X = df.name 24 | df_Y = df.sex 25 | 26 | # Vectorization 27 | corpus = df_X 28 | cv = CountVectorizer() 29 | X = cv.fit_transform(corpus) 30 | 31 | # Loading our ML Model 32 | naivebayes_model = open("models/naivebayesgendermodel.pkl","rb") 33 | clf = joblib.load(naivebayes_model) 34 | 35 | # Receives the input query from form 36 | if request.method == 'POST': 37 | namequery = request.form['namequery'] 38 | data = [namequery] 39 | vect = cv.transform(data).toarray() 40 | my_prediction = clf.predict(vect) 41 | return render_template('results.html',prediction = my_prediction,name = namequery.upper()) 42 | 43 | 44 | if __name__ == '__main__': 45 | app.run(debug=True) -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/data/gender_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap/data/gender_vectorizer.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/data/naivebayesgendermodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap/data/naivebayesgendermodel.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/models/decisiontreemodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap/models/decisiontreemodel.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/models/naivebayesgendermodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Gender-Classifier-ML-App-with-Flask + Bootstrap/models/naivebayesgendermodel.pkl -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/static/css/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font:15px/1.5 Arial, Helvetica,sans-serif; 3 | padding: 0px; 4 | background-color:#f4f3f3; 5 | } 6 | 7 | 8 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | {% block content %} 3 | 4 |
5 |
6 |

Gender Classifier

7 |

Using Machine Learning to Classify Gender

8 |
9 |

ML App.

10 |
11 | 12 | 13 |
14 |
15 |
Gender Classifier
16 |
17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 |
28 |
29 | 30 | 31 | 32 | 33 | {% endblock %} 34 | 35 | {% block styles %} 36 | {{super()}} 37 | 39 | {% endblock %} 40 | 41 | -------------------------------------------------------------------------------- /Gender-Classifier-ML-App-with-Flask + Bootstrap/templates/results.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | {% block content %} 3 | 4 | 5 | 6 |
7 |
8 |

Gender Classifier

9 |

Using Machine Learning to Classify Gender

10 |
11 |

ML App.

12 |
13 | 14 |
15 |
16 | Results 17 |
18 |
19 |
Gender Classifier
20 |
21 |

24 | 25 | 26 | {% if prediction == 0 %} 27 |

30 | Female 31 | {% elif prediction == 1 %} 32 |

35 | Male 36 | {% endif%} 37 |
38 | 39 | 40 | 43 |
44 | 45 | 46 | {% endblock %} 47 | 48 | {% block styles %} 49 | {{super()}} 50 | 52 | {% endblock %} 53 | -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | from flask_material import Material 3 | 4 | # EDA PKg 5 | import pandas as pd 6 | import numpy as np 7 | 8 | # ML Pkg 9 | from sklearn.externals import joblib 10 | 11 | 12 | app = Flask(__name__) 13 | Material(app) 14 | 15 | @app.route('/') 16 | def index(): 17 | return render_template("index.html") 18 | 19 | @app.route('/preview') 20 | def preview(): 21 | df = pd.read_csv("data/iris.csv") 22 | return render_template("preview.html",df_view = df) 23 | 24 | @app.route('/',methods=["POST"]) 25 | def analyze(): 26 | if request.method == 'POST': 27 | petal_length = request.form['petal_length'] 28 | sepal_length = request.form['sepal_length'] 29 | petal_width = request.form['petal_width'] 30 | sepal_width = request.form['sepal_width'] 31 | model_choice = request.form['model_choice'] 32 | 33 | # Clean the data by convert from unicode to float 34 | sample_data = [sepal_length,sepal_width,petal_length,petal_width] 35 | clean_data = [float(i) for i in sample_data] 36 | 37 | # Reshape the Data as a Sample not Individual Features 38 | ex1 = np.array(clean_data).reshape(1,-1) 39 | 40 | # ex1 = np.array([6.2,3.4,5.4,2.3]).reshape(1,-1) 41 | 42 | # Reloading the Model 43 | if model_choice == 'logitmodel': 44 | logit_model = joblib.load('data/logit_model_iris.pkl') 45 | result_prediction = logit_model.predict(ex1) 46 | elif model_choice == 'knnmodel': 47 | knn_model = joblib.load('data/knn_model_iris.pkl') 48 | result_prediction = knn_model.predict(ex1) 49 | elif model_choice == 'svmmodel': 50 | knn_model = joblib.load('data/svm_model_iris.pkl') 51 | result_prediction = knn_model.predict(ex1) 52 | 53 | return render_template('index.html', petal_width=petal_width, 54 | sepal_width=sepal_width, 55 | sepal_length=sepal_length, 56 | petal_length=petal_length, 57 | clean_data=clean_data, 58 | result_prediction=result_prediction, 59 | model_selected=model_choice) 60 | 61 | 62 | if __name__ == '__main__': 63 | app.run(debug=True) -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/dtree_model_iris.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/dtree_model_iris.pkl -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/iris.csv: -------------------------------------------------------------------------------- 1 | sepal_length,sepal_width,petal_length,petal_width,species 2 | 5.1,3.5,1.4,0.2,setosa 3 | 4.9,3.0,1.4,0.2,setosa 4 | 4.7,3.2,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | 5.0,3.6,1.4,0.2,setosa 7 | 5.4,3.9,1.7,0.4,setosa 8 | 4.6,3.4,1.4,0.3,setosa 9 | 5.0,3.4,1.5,0.2,setosa 10 | 4.4,2.9,1.4,0.2,setosa 11 | 4.9,3.1,1.5,0.1,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | 4.8,3.4,1.6,0.2,setosa 14 | 4.8,3.0,1.4,0.1,setosa 15 | 4.3,3.0,1.1,0.1,setosa 16 | 5.8,4.0,1.2,0.2,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,0.4,setosa 19 | 5.1,3.5,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,3.7,1.5,0.4,setosa 24 | 4.6,3.6,1.0,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,3.4,1.9,0.2,setosa 27 | 5.0,3.0,1.6,0.2,setosa 28 | 5.0,3.4,1.6,0.4,setosa 29 | 5.2,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,0.2,setosa 32 | 4.8,3.1,1.6,0.2,setosa 33 | 5.4,3.4,1.5,0.4,setosa 34 | 5.2,4.1,1.5,0.1,setosa 35 | 5.5,4.2,1.4,0.2,setosa 36 | 4.9,3.1,1.5,0.1,setosa 37 | 5.0,3.2,1.2,0.2,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,3.1,1.5,0.1,setosa 40 | 4.4,3.0,1.3,0.2,setosa 41 | 5.1,3.4,1.5,0.2,setosa 42 | 5.0,3.5,1.3,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,1.3,0.2,setosa 45 | 5.0,3.5,1.6,0.6,setosa 46 | 5.1,3.8,1.9,0.4,setosa 47 | 4.8,3.0,1.4,0.3,setosa 48 | 5.1,3.8,1.6,0.2,setosa 49 | 4.6,3.2,1.4,0.2,setosa 50 | 5.3,3.7,1.5,0.2,setosa 51 | 5.0,3.3,1.4,0.2,setosa 52 | 7.0,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,1.5,versicolor 54 | 6.9,3.1,4.9,1.5,versicolor 55 | 5.5,2.3,4.0,1.3,versicolor 56 | 6.5,2.8,4.6,1.5,versicolor 57 | 5.7,2.8,4.5,1.3,versicolor 58 | 6.3,3.3,4.7,1.6,versicolor 59 | 4.9,2.4,3.3,1.0,versicolor 60 | 6.6,2.9,4.6,1.3,versicolor 61 | 5.2,2.7,3.9,1.4,versicolor 62 | 5.0,2.0,3.5,1.0,versicolor 63 | 5.9,3.0,4.2,1.5,versicolor 64 | 6.0,2.2,4.0,1.0,versicolor 65 | 6.1,2.9,4.7,1.4,versicolor 66 | 5.6,2.9,3.6,1.3,versicolor 67 | 6.7,3.1,4.4,1.4,versicolor 68 | 5.6,3.0,4.5,1.5,versicolor 69 | 5.8,2.7,4.1,1.0,versicolor 70 | 6.2,2.2,4.5,1.5,versicolor 71 | 5.6,2.5,3.9,1.1,versicolor 72 | 5.9,3.2,4.8,1.8,versicolor 73 | 6.1,2.8,4.0,1.3,versicolor 74 | 6.3,2.5,4.9,1.5,versicolor 75 | 6.1,2.8,4.7,1.2,versicolor 76 | 6.4,2.9,4.3,1.3,versicolor 77 | 6.6,3.0,4.4,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3.0,5.0,1.7,versicolor 80 | 6.0,2.9,4.5,1.5,versicolor 81 | 5.7,2.6,3.5,1.0,versicolor 82 | 5.5,2.4,3.8,1.1,versicolor 83 | 5.5,2.4,3.7,1.0,versicolor 84 | 5.8,2.7,3.9,1.2,versicolor 85 | 6.0,2.7,5.1,1.6,versicolor 86 | 5.4,3.0,4.5,1.5,versicolor 87 | 6.0,3.4,4.5,1.6,versicolor 88 | 6.7,3.1,4.7,1.5,versicolor 89 | 6.3,2.3,4.4,1.3,versicolor 90 | 5.6,3.0,4.1,1.3,versicolor 91 | 5.5,2.5,4.0,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | 6.1,3.0,4.6,1.4,versicolor 94 | 5.8,2.6,4.0,1.2,versicolor 95 | 5.0,2.3,3.3,1.0,versicolor 96 | 5.6,2.7,4.2,1.3,versicolor 97 | 5.7,3.0,4.2,1.2,versicolor 98 | 5.7,2.9,4.2,1.3,versicolor 99 | 6.2,2.9,4.3,1.3,versicolor 100 | 5.1,2.5,3.0,1.1,versicolor 101 | 5.7,2.8,4.1,1.3,versicolor 102 | 6.3,3.3,6.0,2.5,virginica 103 | 5.8,2.7,5.1,1.9,virginica 104 | 7.1,3.0,5.9,2.1,virginica 105 | 6.3,2.9,5.6,1.8,virginica 106 | 6.5,3.0,5.8,2.2,virginica 107 | 7.6,3.0,6.6,2.1,virginica 108 | 4.9,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,1.8,virginica 111 | 7.2,3.6,6.1,2.5,virginica 112 | 6.5,3.2,5.1,2.0,virginica 113 | 6.4,2.7,5.3,1.9,virginica 114 | 6.8,3.0,5.5,2.1,virginica 115 | 5.7,2.5,5.0,2.0,virginica 116 | 5.8,2.8,5.1,2.4,virginica 117 | 6.4,3.2,5.3,2.3,virginica 118 | 6.5,3.0,5.5,1.8,virginica 119 | 7.7,3.8,6.7,2.2,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | 6.0,2.2,5.0,1.5,virginica 122 | 6.9,3.2,5.7,2.3,virginica 123 | 5.6,2.8,4.9,2.0,virginica 124 | 7.7,2.8,6.7,2.0,virginica 125 | 6.3,2.7,4.9,1.8,virginica 126 | 6.7,3.3,5.7,2.1,virginica 127 | 7.2,3.2,6.0,1.8,virginica 128 | 6.2,2.8,4.8,1.8,virginica 129 | 6.1,3.0,4.9,1.8,virginica 130 | 6.4,2.8,5.6,2.1,virginica 131 | 7.2,3.0,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,3.8,6.4,2.0,virginica 134 | 6.4,2.8,5.6,2.2,virginica 135 | 6.3,2.8,5.1,1.5,virginica 136 | 6.1,2.6,5.6,1.4,virginica 137 | 7.7,3.0,6.1,2.3,virginica 138 | 6.3,3.4,5.6,2.4,virginica 139 | 6.4,3.1,5.5,1.8,virginica 140 | 6.0,3.0,4.8,1.8,virginica 141 | 6.9,3.1,5.4,2.1,virginica 142 | 6.7,3.1,5.6,2.4,virginica 143 | 6.9,3.1,5.1,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,3.2,5.9,2.3,virginica 146 | 6.7,3.3,5.7,2.5,virginica 147 | 6.7,3.0,5.2,2.3,virginica 148 | 6.3,2.5,5.0,1.9,virginica 149 | 6.5,3.0,5.2,2.0,virginica 150 | 6.2,3.4,5.4,2.3,virginica 151 | 5.9,3.0,5.1,1.8,virginica 152 | -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/knn_model_iris.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/knn_model_iris.pkl -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/logit_model_iris.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/logit_model_iris.pkl -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/svm_model_iris.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/data/svm_model_iris.pkl -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_setosa.jpg -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_versicolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_versicolor.jpg -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_virginica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/static/imgs/iris_virginica.jpg -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "material/base.html" %} 2 | {% block content %} 3 |
4 |
5 |
6 |

Iris Species Predictor

7 |

ML Web App

8 | Reset 9 | View Dataset 10 |
11 | 12 |
13 |
14 |
103 | 104 | 105 | 106 | 107 | 108 | {% endblock%} 109 | 110 | {% block scripts %} 111 | {{super()}} 112 | 113 | 114 | 115 | 121 | 122 | 129 | 130 | {% endblock %} -------------------------------------------------------------------------------- /Iris-Species-Predictor-ML-Flask-App-With-Materialize.css/templates/preview.html: -------------------------------------------------------------------------------- 1 | {% extends "material/base.html" %} 2 | {% block content %} 3 |
4 |
5 |
6 |

Iris Species Predictor

7 |

ML Web App

8 | Back 9 | 10 |
11 | 12 |
13 |
14 | 15 |
16 | {{ df_view.to_html(classes="table striped",na_rep="-") | safe}} 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | {% endblock %} 27 | 28 | 29 | {% block scripts %} 30 | {{ super() }} 31 | 32 | 33 | 34 | 35 | {% endblock %} -------------------------------------------------------------------------------- /Iris_EDA_Web_App/README.md: -------------------------------------------------------------------------------- 1 | ### Iris EDA Web App 2 | 3 | + Iris Exploratory Data Analysis App built with Streamlit 4 | 5 | #### Description 6 | + This is a simple Exploratory Data Analysis of the Iris Dataset depicting the various species built with streamlit 7 | 8 | #### Purpose 9 | + Show a simple EDA of Iris using Streamlit framework 10 | 11 | ##### To Install Streamlit 12 | ```bash 13 | pip install streamlit 14 | ``` 15 | 16 | 17 | #### Running the App 18 | + cd into app 19 | + run the following 20 | 21 | ```bash 22 | streamlit run app.py 23 | ``` 24 | 25 | #### Intro 26 | ![](screenshots/home1.png) 27 | 28 | #### Show DataFrame/Columns 29 | ![](screenshots/home2.png) 30 | 31 | #### Show and Hide Image 32 | ![](screenshots/home3.png) 33 | 34 | #### With Description of App 35 | ![](screenshots/iris_eda_desc.png) 36 | 37 | ##### NB About Changes 38 | + app.py :from tutorial video 39 | + iris_app.py :restructured 40 | 41 | 42 | 43 | #### By 44 | + Jesse E.Agbe(JCharis) 45 | + Jesus Saves@JCharisTech 46 | 47 | #### More Thanks to The Streamlit Team 48 | + Awesome Tool -------------------------------------------------------------------------------- /Iris_EDA_Web_App/app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | import pandas as pd 3 | import numpy as np 4 | import os 5 | import matplotlib.pyplot as plt 6 | import seaborn as sns 7 | from PIL import Image,ImageFilter,ImageEnhance 8 | 9 | 10 | # Title and Subheader 11 | st.title("Iris EDA App") 12 | st.subheader("EDA Web App with Streamlit ") 13 | 14 | 15 | # EDA 16 | my_dataset = "iris.csv" 17 | 18 | # To Improve speed and cache data 19 | @st.cache(persist=True) 20 | def explore_data(dataset): 21 | df = pd.read_csv(os.path.join(dataset)) 22 | return df 23 | 24 | 25 | # Show Dataset 26 | if st.checkbox("Preview DataFrame"): 27 | data = explore_data(my_dataset) 28 | if st.button("Head"): 29 | st.write(data.head()) 30 | if st.button("Tail"): 31 | st.write(data.tail()) 32 | else: 33 | st.write(data.head(2)) 34 | 35 | # Show Entire Dataframe 36 | if st.checkbox("Show All DataFrame"): 37 | data = explore_data(my_dataset) 38 | st.dataframe(data) 39 | 40 | # Show Description 41 | if st.checkbox("Show All Column Name"): 42 | data = explore_data(my_dataset) 43 | st.text("Columns:") 44 | st.write(data.columns) 45 | 46 | # Dimensions 47 | data_dim = st.radio('What Dimension Do You Want to Show',('Rows','Columns')) 48 | if data_dim == 'Rows': 49 | data = explore_data(my_dataset) 50 | st.text("Showing Length of Rows") 51 | st.write(len(data)) 52 | if data_dim == 'Columns': 53 | data = explore_data(my_dataset) 54 | st.text("Showing Length of Columns") 55 | st.write(data.shape[1]) 56 | 57 | 58 | if st.checkbox("Show Summary of Dataset"): 59 | data = explore_data(my_dataset) 60 | st.write(data.describe()) 61 | 62 | # Selection 63 | species_option = st.selectbox('Select Columns',('sepal_length','sepal_width','petal_length','petal_width','species')) 64 | data = explore_data(my_dataset) 65 | if species_option == 'sepal_length': 66 | st.write(data['sepal_length']) 67 | elif species_option == 'sepal_width': 68 | st.write(data['sepal_width']) 69 | elif species_option == 'petal_length': 70 | st.write(data['petal_length']) 71 | elif species_option == 'petal_width': 72 | st.write(data['petal_width']) 73 | elif species_option == 'species': 74 | st.write(data['species']) 75 | else: 76 | st.write("Select A Column") 77 | 78 | # Show Plots 79 | if st.checkbox("Simple Bar Plot with Matplotlib "): 80 | data = explore_data(my_dataset) 81 | data.plot(kind='bar') 82 | st.pyplot() 83 | 84 | 85 | # Show Plots 86 | if st.checkbox("Simple Correlation Plot with Matplotlib "): 87 | data = explore_data(my_dataset) 88 | plt.matshow(data.corr()) 89 | st.pyplot() 90 | 91 | # Show Plots 92 | if st.checkbox("Simple Correlation Plot with Seaborn "): 93 | data = explore_data(my_dataset) 94 | st.write(sns.heatmap(data.corr(),annot=True)) 95 | # Use Matplotlib to render seaborn 96 | st.pyplot() 97 | 98 | # Show Plots 99 | if st.checkbox("Bar Plot of Groups or Counts"): 100 | data = explore_data(my_dataset) 101 | v_counts = data.groupby('species') 102 | st.bar_chart(v_counts) 103 | 104 | 105 | # Iris Image Manipulation 106 | @st.cache 107 | def load_image(img): 108 | im =Image.open(os.path.join(img)) 109 | return im 110 | 111 | # Image Type 112 | species_type = st.radio('What is the Iris Species do you want to see?',('Setosa','Versicolor','Virginica')) 113 | 114 | if species_type == 'Setosa': 115 | st.text("Showing Setosa Species") 116 | st.image(load_image('imgs/iris_setosa.jpg')) 117 | elif species_type == 'Versicolor': 118 | st.text("Showing Versicolor Species") 119 | st.image(load_image('imgs/iris_versicolor.jpg')) 120 | elif species_type == 'Virginica': 121 | st.text("Showing Virginica Species") 122 | st.image(load_image('imgs/iris_virginica.jpg')) 123 | 124 | 125 | 126 | # Show Image 127 | if st.checkbox("Show Image/Hide Image"): 128 | my_image = load_image('iris_setosa.jpg') 129 | enh = ImageEnhance.Contrast(my_image) 130 | num = st.slider("Set Your Contrast Number",1.0,3.0) 131 | img_width = st.slider("Set Image Width",300,500) 132 | st.image(enh.enhance(num),width=img_width) 133 | 134 | 135 | # About 136 | 137 | if st.button("About App"): 138 | st.subheader("Iris Dataset EDA App") 139 | st.text("Built with Streamlit") 140 | st.text("Thanks to the Streamlit Team Amazing Work") 141 | 142 | if st.checkbox("By"): 143 | st.text("Jesse E.Agbe(JCharis)") 144 | st.text("Jesus Saves@JCharisTech") 145 | 146 | 147 | -------------------------------------------------------------------------------- /Iris_EDA_Web_App/imgs/iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/imgs/iris_setosa.jpg -------------------------------------------------------------------------------- /Iris_EDA_Web_App/imgs/iris_versicolor.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/imgs/iris_versicolor.jpg -------------------------------------------------------------------------------- /Iris_EDA_Web_App/imgs/iris_virginica.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/imgs/iris_virginica.jpg -------------------------------------------------------------------------------- /Iris_EDA_Web_App/iris.csv: -------------------------------------------------------------------------------- 1 | sepal_length,sepal_width,petal_length,petal_width,species 2 | 5.1,3.5,1.4,0.2,setosa 3 | 4.9,3.0,1.4,0.2,setosa 4 | 4.7,3.2,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | 5.0,3.6,1.4,0.2,setosa 7 | 5.4,3.9,1.7,0.4,setosa 8 | 4.6,3.4,1.4,0.3,setosa 9 | 5.0,3.4,1.5,0.2,setosa 10 | 4.4,2.9,1.4,0.2,setosa 11 | 4.9,3.1,1.5,0.1,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | 4.8,3.4,1.6,0.2,setosa 14 | 4.8,3.0,1.4,0.1,setosa 15 | 4.3,3.0,1.1,0.1,setosa 16 | 5.8,4.0,1.2,0.2,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,0.4,setosa 19 | 5.1,3.5,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,3.7,1.5,0.4,setosa 24 | 4.6,3.6,1.0,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,3.4,1.9,0.2,setosa 27 | 5.0,3.0,1.6,0.2,setosa 28 | 5.0,3.4,1.6,0.4,setosa 29 | 5.2,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,0.2,setosa 32 | 4.8,3.1,1.6,0.2,setosa 33 | 5.4,3.4,1.5,0.4,setosa 34 | 5.2,4.1,1.5,0.1,setosa 35 | 5.5,4.2,1.4,0.2,setosa 36 | 4.9,3.1,1.5,0.1,setosa 37 | 5.0,3.2,1.2,0.2,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,3.1,1.5,0.1,setosa 40 | 4.4,3.0,1.3,0.2,setosa 41 | 5.1,3.4,1.5,0.2,setosa 42 | 5.0,3.5,1.3,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,1.3,0.2,setosa 45 | 5.0,3.5,1.6,0.6,setosa 46 | 5.1,3.8,1.9,0.4,setosa 47 | 4.8,3.0,1.4,0.3,setosa 48 | 5.1,3.8,1.6,0.2,setosa 49 | 4.6,3.2,1.4,0.2,setosa 50 | 5.3,3.7,1.5,0.2,setosa 51 | 5.0,3.3,1.4,0.2,setosa 52 | 7.0,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,1.5,versicolor 54 | 6.9,3.1,4.9,1.5,versicolor 55 | 5.5,2.3,4.0,1.3,versicolor 56 | 6.5,2.8,4.6,1.5,versicolor 57 | 5.7,2.8,4.5,1.3,versicolor 58 | 6.3,3.3,4.7,1.6,versicolor 59 | 4.9,2.4,3.3,1.0,versicolor 60 | 6.6,2.9,4.6,1.3,versicolor 61 | 5.2,2.7,3.9,1.4,versicolor 62 | 5.0,2.0,3.5,1.0,versicolor 63 | 5.9,3.0,4.2,1.5,versicolor 64 | 6.0,2.2,4.0,1.0,versicolor 65 | 6.1,2.9,4.7,1.4,versicolor 66 | 5.6,2.9,3.6,1.3,versicolor 67 | 6.7,3.1,4.4,1.4,versicolor 68 | 5.6,3.0,4.5,1.5,versicolor 69 | 5.8,2.7,4.1,1.0,versicolor 70 | 6.2,2.2,4.5,1.5,versicolor 71 | 5.6,2.5,3.9,1.1,versicolor 72 | 5.9,3.2,4.8,1.8,versicolor 73 | 6.1,2.8,4.0,1.3,versicolor 74 | 6.3,2.5,4.9,1.5,versicolor 75 | 6.1,2.8,4.7,1.2,versicolor 76 | 6.4,2.9,4.3,1.3,versicolor 77 | 6.6,3.0,4.4,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3.0,5.0,1.7,versicolor 80 | 6.0,2.9,4.5,1.5,versicolor 81 | 5.7,2.6,3.5,1.0,versicolor 82 | 5.5,2.4,3.8,1.1,versicolor 83 | 5.5,2.4,3.7,1.0,versicolor 84 | 5.8,2.7,3.9,1.2,versicolor 85 | 6.0,2.7,5.1,1.6,versicolor 86 | 5.4,3.0,4.5,1.5,versicolor 87 | 6.0,3.4,4.5,1.6,versicolor 88 | 6.7,3.1,4.7,1.5,versicolor 89 | 6.3,2.3,4.4,1.3,versicolor 90 | 5.6,3.0,4.1,1.3,versicolor 91 | 5.5,2.5,4.0,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | 6.1,3.0,4.6,1.4,versicolor 94 | 5.8,2.6,4.0,1.2,versicolor 95 | 5.0,2.3,3.3,1.0,versicolor 96 | 5.6,2.7,4.2,1.3,versicolor 97 | 5.7,3.0,4.2,1.2,versicolor 98 | 5.7,2.9,4.2,1.3,versicolor 99 | 6.2,2.9,4.3,1.3,versicolor 100 | 5.1,2.5,3.0,1.1,versicolor 101 | 5.7,2.8,4.1,1.3,versicolor 102 | 6.3,3.3,6.0,2.5,virginica 103 | 5.8,2.7,5.1,1.9,virginica 104 | 7.1,3.0,5.9,2.1,virginica 105 | 6.3,2.9,5.6,1.8,virginica 106 | 6.5,3.0,5.8,2.2,virginica 107 | 7.6,3.0,6.6,2.1,virginica 108 | 4.9,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,1.8,virginica 111 | 7.2,3.6,6.1,2.5,virginica 112 | 6.5,3.2,5.1,2.0,virginica 113 | 6.4,2.7,5.3,1.9,virginica 114 | 6.8,3.0,5.5,2.1,virginica 115 | 5.7,2.5,5.0,2.0,virginica 116 | 5.8,2.8,5.1,2.4,virginica 117 | 6.4,3.2,5.3,2.3,virginica 118 | 6.5,3.0,5.5,1.8,virginica 119 | 7.7,3.8,6.7,2.2,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | 6.0,2.2,5.0,1.5,virginica 122 | 6.9,3.2,5.7,2.3,virginica 123 | 5.6,2.8,4.9,2.0,virginica 124 | 7.7,2.8,6.7,2.0,virginica 125 | 6.3,2.7,4.9,1.8,virginica 126 | 6.7,3.3,5.7,2.1,virginica 127 | 7.2,3.2,6.0,1.8,virginica 128 | 6.2,2.8,4.8,1.8,virginica 129 | 6.1,3.0,4.9,1.8,virginica 130 | 6.4,2.8,5.6,2.1,virginica 131 | 7.2,3.0,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,3.8,6.4,2.0,virginica 134 | 6.4,2.8,5.6,2.2,virginica 135 | 6.3,2.8,5.1,1.5,virginica 136 | 6.1,2.6,5.6,1.4,virginica 137 | 7.7,3.0,6.1,2.3,virginica 138 | 6.3,3.4,5.6,2.4,virginica 139 | 6.4,3.1,5.5,1.8,virginica 140 | 6.0,3.0,4.8,1.8,virginica 141 | 6.9,3.1,5.4,2.1,virginica 142 | 6.7,3.1,5.6,2.4,virginica 143 | 6.9,3.1,5.1,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,3.2,5.9,2.3,virginica 146 | 6.7,3.3,5.7,2.5,virginica 147 | 6.7,3.0,5.2,2.3,virginica 148 | 6.3,2.5,5.0,1.9,virginica 149 | 6.5,3.0,5.2,2.0,virginica 150 | 6.2,3.4,5.4,2.3,virginica 151 | 5.9,3.0,5.1,1.8,virginica 152 | -------------------------------------------------------------------------------- /Iris_EDA_Web_App/iris_app.py: -------------------------------------------------------------------------------- 1 | """ 2 | ## App: Iris EDA App 3 | Author: [Jesse E.Agbe(JCharis)](https://github.com/Jcharis))\n 4 | Source: [Github](https://github.com/Jcharis/Machine-Learning-Web-Apps/tree/master/Iris_EDA_Web_App) 5 | Credits: Streamlit Team,Marc Skov Madsen(For Awesome-streamlit gallery) 6 | 7 | Description 8 | This is a simple Exploratory Data Analysis of the Iris Dataset depicting the various 9 | species built with Streamlit. 10 | We can preview the dataset,column names as well as show some basic plot with matplotlib and 11 | seaborn. 12 | There is also an image manipulation of a specie with changeable contrast and width using st.slider() 13 | 14 | Purpose 15 | To show a simple EDA of Iris using Streamlit framework. 16 | 17 | """ 18 | import streamlit as st 19 | 20 | # EDA Pkgs 21 | import pandas as pd 22 | import numpy as np 23 | import os 24 | 25 | # Plotting Pkgs 26 | import matplotlib.pyplot as plt 27 | import seaborn as sns 28 | from PIL import Image,ImageFilter,ImageEnhance 29 | 30 | def main(): 31 | st.title("Iris EDA App") 32 | st.subheader("EDA Web App with Streamlit ") 33 | st.markdown(""" 34 | #### Description 35 | + This is a simple Exploratory Data Analysis of the Iris Dataset depicting the various species built with Streamlit. 36 | 37 | #### Purpose 38 | + To show a simple EDA of Iris using Streamlit framework. 39 | """) 40 | 41 | # Your code goes below 42 | # Our Dataset 43 | my_dataset = "iris.csv" 44 | 45 | # To Improve speed and cache data 46 | @st.cache(persist=True) 47 | def explore_data(dataset): 48 | df = pd.read_csv(os.path.join(dataset)) 49 | return df 50 | 51 | # Load Our Dataset 52 | data = explore_data(my_dataset) 53 | 54 | # Show Dataset 55 | if st.checkbox("Preview DataFrame"): 56 | if st.button("Head"): 57 | st.write(data.head()) 58 | if st.button("Tail"): 59 | st.write(data.tail()) 60 | else: 61 | st.write(data.head(2)) 62 | 63 | # Show Entire Dataframe 64 | if st.checkbox("Show All DataFrame"): 65 | st.dataframe(data) 66 | 67 | # Show All Column Names 68 | if st.checkbox("Show All Column Name"): 69 | st.text("Columns:") 70 | st.write(data.columns) 71 | 72 | # Show Dimensions and Shape of Dataset 73 | data_dim = st.radio('What Dimension Do You Want to Show',('Rows','Columns')) 74 | if data_dim == 'Rows': 75 | st.text("Showing Length of Rows") 76 | st.write(len(data)) 77 | if data_dim == 'Columns': 78 | st.text("Showing Length of Columns") 79 | st.write(data.shape[1]) 80 | 81 | # Show Summary of Dataset 82 | if st.checkbox("Show Summary of Dataset"): 83 | st.write(data.describe()) 84 | 85 | # Selection of Columns 86 | species_option = st.selectbox('Select Columns',('sepal_length','sepal_width','petal_length','petal_width','species')) 87 | if species_option == 'sepal_length': 88 | st.write(data['sepal_length']) 89 | elif species_option == 'sepal_width': 90 | st.write(data['sepal_width']) 91 | elif species_option == 'petal_length': 92 | st.write(data['petal_length']) 93 | elif species_option == 'petal_width': 94 | st.write(data['petal_width']) 95 | elif species_option == 'species': 96 | st.write(data['species']) 97 | else: 98 | st.write("Select A Column") 99 | 100 | # Show Plots 101 | if st.checkbox("Simple Bar Plot with Matplotlib "): 102 | data.plot(kind='bar') 103 | st.pyplot() 104 | 105 | 106 | # Show Correlation Plots 107 | if st.checkbox("Simple Correlation Plot with Matplotlib "): 108 | plt.matshow(data.corr()) 109 | st.pyplot() 110 | 111 | # Show Correlation Plots with Sns 112 | if st.checkbox("Simple Correlation Plot with Seaborn "): 113 | st.write(sns.heatmap(data.corr(),annot=True)) 114 | # Use Matplotlib to render seaborn 115 | st.pyplot() 116 | 117 | # Show Plots 118 | if st.checkbox("Bar Plot of Groups or Counts"): 119 | v_counts = data.groupby('species') 120 | st.bar_chart(v_counts) 121 | 122 | 123 | # Iris Image Manipulation 124 | @st.cache 125 | def load_image(img): 126 | im =Image.open(os.path.join(img)) 127 | return im 128 | 129 | # Select Image Type using Radio Button 130 | species_type = st.radio('What is the Iris Species do you want to see?',('Setosa','Versicolor','Virginica')) 131 | 132 | if species_type == 'Setosa': 133 | st.text("Showing Setosa Species") 134 | st.image(load_image('imgs/iris_setosa.jpg')) 135 | elif species_type == 'Versicolor': 136 | st.text("Showing Versicolor Species") 137 | st.image(load_image('imgs/iris_versicolor.jpg')) 138 | elif species_type == 'Virginica': 139 | st.text("Showing Virginica Species") 140 | st.image(load_image('imgs/iris_virginica.jpg')) 141 | 142 | 143 | 144 | # Show Image or Hide Image with Checkbox 145 | if st.checkbox("Show Image/Hide Image"): 146 | my_image = load_image('iris_setosa.jpg') 147 | enh = ImageEnhance.Contrast(my_image) 148 | num = st.slider("Set Your Contrast Number",1.0,3.0) 149 | img_width = st.slider("Set Image Width",300,500) 150 | st.image(enh.enhance(num),width=img_width) 151 | 152 | 153 | # About 154 | if st.button("About App"): 155 | st.subheader("Iris Dataset EDA App") 156 | st.text("Built with Streamlit") 157 | st.text("Thanks to the Streamlit Team Amazing Work") 158 | 159 | if st.checkbox("By"): 160 | st.text("Jesse E.Agbe(JCharis)") 161 | st.text("Jesus Saves@JCharisTech") 162 | 163 | 164 | if __name__ == "__main__": 165 | main() -------------------------------------------------------------------------------- /Iris_EDA_Web_App/iris_setosa.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/iris_setosa.jpg -------------------------------------------------------------------------------- /Iris_EDA_Web_App/screenshots/home1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/screenshots/home1.png -------------------------------------------------------------------------------- /Iris_EDA_Web_App/screenshots/home2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/screenshots/home2.png -------------------------------------------------------------------------------- /Iris_EDA_Web_App/screenshots/home3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/screenshots/home3.png -------------------------------------------------------------------------------- /Iris_EDA_Web_App/screenshots/iris_eda_app_streamlit_python_JcharisTech.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/screenshots/iris_eda_app_streamlit_python_JcharisTech.png -------------------------------------------------------------------------------- /Iris_EDA_Web_App/screenshots/iris_eda_desc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Iris_EDA_Web_App/screenshots/iris_eda_desc.png -------------------------------------------------------------------------------- /NLP-Based Flask App with TextBlob(Main Points and Sentiment Analysis)/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template,request,url_for 2 | from flask_bootstrap import Bootstrap 3 | 4 | 5 | # NLP Packages 6 | from textblob import TextBlob,Word 7 | import random 8 | import time 9 | 10 | app = Flask(__name__) 11 | Bootstrap(app) 12 | 13 | @app.route('/') 14 | def index(): 15 | return render_template('index.html') 16 | 17 | 18 | @app.route('/analyse',methods=['POST']) 19 | def analyse(): 20 | start = time.time() 21 | if request.method == 'POST': 22 | rawtext = request.form['rawtext'] 23 | #NLP Stuff 24 | blob = TextBlob(rawtext) 25 | received_text2 = blob 26 | blob_sentiment,blob_subjectivity = blob.sentiment.polarity ,blob.sentiment.subjectivity 27 | number_of_tokens = len(list(blob.words)) 28 | # Extracting Main Points 29 | nouns = list() 30 | for word, tag in blob.tags: 31 | if tag == 'NN': 32 | nouns.append(word.lemmatize()) 33 | len_of_words = len(nouns) 34 | rand_words = random.sample(nouns,len(nouns)) 35 | final_word = list() 36 | for item in rand_words: 37 | word = Word(item).pluralize() 38 | final_word.append(word) 39 | summary = final_word 40 | end = time.time() 41 | final_time = end-start 42 | 43 | 44 | return render_template('index.html',received_text = received_text2,number_of_tokens=number_of_tokens,blob_sentiment=blob_sentiment,blob_subjectivity=blob_subjectivity,summary=summary,final_time=final_time) 45 | 46 | 47 | 48 | 49 | 50 | 51 | if __name__ == '__main__': 52 | app.run(debug=True) -------------------------------------------------------------------------------- /NLP-Based Flask App with TextBlob(Main Points and Sentiment Analysis)/templates/index.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | 3 | {% block content %} 4 | 5 | 33 | 34 | 35 |
36 |
37 |

Natural Language Processing App

38 |

Understanding Everyday Language

39 |
40 |
41 | 42 |
43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Reset 53 | 54 |
55 | 56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 | Main Points 64 |
65 |
66 |
69 |
70 |
Your Text
71 |

{{ received_text }}

72 |
73 |
74 |

Time Elapsed: {{ final_time }} seconds to analyse

75 |

This text is about:

76 | {% for i in summary %} 77 |
    78 |
  • {{i}} 79 | View 80 | 81 |
  • 82 |
83 | 84 | 85 | {% endfor %} 86 |
87 | 105 | 106 | 107 |
108 |
109 | 110 | 111 | {% endblock %} 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | {% block scripts %} 123 | 124 | {{ super() }} 125 | 126 | 131 | 145 | 146 | 147 | 148 | {% endblock %} -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/__pycache__/app.cpython-35.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/__pycache__/app.cpython-35.pyc -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,url_for,request,render_template,jsonify,send_file 2 | from flask_bootstrap import Bootstrap 3 | import json 4 | 5 | # NLP Pkgs 6 | import spacy 7 | from textblob import TextBlob 8 | nlp = spacy.load('en') 9 | 10 | # WordCloud & Matplotlib Packages 11 | from wordcloud import WordCloud 12 | import matplotlib.pyplot as plt 13 | from io import BytesIO 14 | import random 15 | import time 16 | 17 | 18 | 19 | # Initialize App 20 | app = Flask(__name__) 21 | Bootstrap(app) 22 | 23 | @app.route('/') 24 | def index(): 25 | return render_template('index.html') 26 | 27 | 28 | @app.route('/analyze',methods=['GET','POST']) 29 | def analyze(): 30 | start = time.time() 31 | # Receives the input query from form 32 | if request.method == 'POST': 33 | rawtext = request.form['rawtext'] 34 | # Analysis 35 | docx = nlp(rawtext) 36 | # Tokens 37 | custom_tokens = [token.text for token in docx ] 38 | # Word Info 39 | custom_wordinfo = [(token.text,token.lemma_,token.shape_,token.is_alpha,token.is_stop) for token in docx ] 40 | custom_postagging = [(word.text,word.tag_,word.pos_,word.dep_) for word in docx] 41 | # NER 42 | custom_namedentities = [(entity.text,entity.label_)for entity in docx.ents] 43 | blob = TextBlob(rawtext) 44 | blob_sentiment,blob_subjectivity = blob.sentiment.polarity ,blob.sentiment.subjectivity 45 | # allData = ['Token:{},Tag:{},POS:{},Dependency:{},Lemma:{},Shape:{},Alpha:{},IsStopword:{}'.format(token.text,token.tag_,token.pos_,token.dep_,token.lemma_,token.shape_,token.is_alpha,token.is_stop) for token in docx ] 46 | allData = [('"Token":"{}","Tag":"{}","POS":"{}","Dependency":"{}","Lemma":"{}","Shape":"{}","Alpha":"{}","IsStopword":"{}"'.format(token.text,token.tag_,token.pos_,token.dep_,token.lemma_,token.shape_,token.is_alpha,token.is_stop)) for token in docx ] 47 | 48 | result_json = json.dumps(allData, sort_keys = False, indent = 2) 49 | 50 | end = time.time() 51 | final_time = end-start 52 | return render_template('index.html',ctext=rawtext,custom_tokens=custom_tokens,custom_postagging=custom_postagging,custom_namedentities=custom_namedentities,custom_wordinfo=custom_wordinfo,blob_sentiment=blob_sentiment,blob_subjectivity=blob_subjectivity,final_time=final_time,result_json=result_json) 53 | 54 | # API ROUTES 55 | @app.route('/api') 56 | def basic_api(): 57 | return render_template('restfulapidocs.html') 58 | 59 | # API FOR TOKENS 60 | @app.route('/api/tokens/',methods=['GET']) 61 | def api_tokens(mytext): 62 | # Analysis 63 | docx = nlp(mytext) 64 | # Tokens 65 | mytokens = [token.text for token in docx ] 66 | return jsonify(mytext,mytokens) 67 | 68 | # API FOR LEMMA 69 | @app.route('/api/lemma/',methods=['GET']) 70 | def api_lemma(mytext): 71 | # Analysis 72 | docx = nlp(mytext.strip()) 73 | # Tokens & Lemma 74 | mylemma = [('Token:{},Lemma:{}'.format(token.text,token.lemma_))for token in docx ] 75 | return jsonify(mytext,mylemma) 76 | 77 | # API FOR NAMED ENTITY 78 | @app.route('/api/ner/',methods=['GET']) 79 | def api_ner(mytext): 80 | # Analysis 81 | docx = nlp(mytext) 82 | # Tokens 83 | mynamedentities = [(entity.text,entity.label_)for entity in docx.ents] 84 | return jsonify(mytext,mynamedentities) 85 | 86 | # API FOR NAMED ENTITY 87 | @app.route('/api/entities/',methods=['GET']) 88 | def api_entities(mytext): 89 | # Analysis 90 | docx = nlp(mytext) 91 | # Tokens 92 | mynamedentities = [(entity.text,entity.label_)for entity in docx.ents] 93 | return jsonify(mytext,mynamedentities) 94 | 95 | 96 | # API FOR SENTIMENT ANALYSIS 97 | @app.route('/api/sentiment/',methods=['GET']) 98 | def api_sentiment(mytext): 99 | # Analysis 100 | blob = TextBlob(mytext) 101 | mysentiment = [ mytext,blob.words,blob.sentiment ] 102 | return jsonify(mysentiment) 103 | 104 | # API FOR MORE WORD ANALYSIS 105 | @app.route('/api/nlpiffy/',methods=['GET']) 106 | def nlpifyapi(mytext): 107 | 108 | docx = nlp(mytext.strip()) 109 | allData = ['Token:{},Tag:{},POS:{},Dependency:{},Lemma:{},Shape:{},Alpha:{},IsStopword:{}'.format(token.text,token.tag_,token.pos_,token.dep_,token.lemma_,token.shape_,token.is_alpha,token.is_stop) for token in docx ] 110 | 111 | return jsonify(mytext,allData) 112 | 113 | 114 | # IMAGE WORDCLOUD 115 | @app.route('/images') 116 | def imagescloud(): 117 | return "Enter text into url eg. /fig/yourtext " 118 | 119 | 120 | @app.route('/images/') 121 | def images(mytext): 122 | return render_template("index.html", title=mytext) 123 | 124 | @app.route('/fig/') 125 | def fig(mytext): 126 | plt.figure(figsize=(20,10)) 127 | wordcloud = WordCloud(background_color='white', mode = "RGB", width = 2000, height = 1000).generate(mytext) 128 | plt.imshow(wordcloud) 129 | plt.axis("off") 130 | img = BytesIO() 131 | plt.savefig(img) 132 | img.seek(0) 133 | return send_file(img, mimetype='image/png') 134 | 135 | 136 | @app.route('/about') 137 | def about(): 138 | return render_template('about.html') 139 | 140 | if __name__ == '__main__': 141 | app.run(debug=True) -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/css/custom.css: -------------------------------------------------------------------------------- 1 | li{ 2 | font-size: 16px; 3 | } 4 | #exTab1 .tab-content { 5 | color : white; 6 | background-color: #3872fb;#428bca; 7 | padding : 5px 15px; 8 | } 9 | 10 | #exTab2 h3 { 11 | color : white; 12 | background-color: #3872fb;#428bca; 13 | padding : 5px 15px; 14 | } 15 | 16 | /* remove border radius for the tab */ 17 | 18 | #exTab1 .nav-pills > li > a { 19 | border-radius: 0; 20 | } 21 | 22 | /* change border radius for the tab , apply corners on top*/ 23 | 24 | #exTab3 .nav-pills > li > a { 25 | border-radius: 4px 4px 0 0 ; 26 | } 27 | 28 | #exTab3 .tab-content { 29 | color : white; 30 | background-color: #3872fb;#428bca; 31 | padding : 5px 15px; 32 | } 33 | 34 | .badge { 35 | font-size: 12.025px; 36 | font-weight: bold; 37 | } 38 | .badge:hover { 39 | color: #ffffff; 40 | text-decoration: none; 41 | cursor: pointer; 42 | } 43 | .badge-red { 44 | background-color: red; 45 | } 46 | .badge-red:hover { 47 | background-color: #953b39; 48 | } 49 | .badge-warning { 50 | background-color: #f89406; 51 | } 52 | .badge-warning:hover { 53 | background-color: #c67605; 54 | } 55 | .badge-success { 56 | background-color: #468847; 57 | } 58 | .badge-success:hover { 59 | background-color: #356635; 60 | } 61 | .badge-info { 62 | background-color: #3a87ad; 63 | } 64 | .badge-info:hover { 65 | background-color: #2d6987; 66 | } 67 | .badge-inverse { 68 | background-color: #333333; 69 | } 70 | .badge-inverse:hover { 71 | background-color: #1a1a1a; 72 | } 73 | 74 | 75 | .spinner-1:before{ 76 | content: ""; 77 | box-sizing: border-box; 78 | position: absolute; 79 | top:50%; 80 | left: 50%; 81 | height: 60px; 82 | width: 60px; 83 | margin-top: -30px; 84 | margin-left: -30px; 85 | border-radius: 50%; 86 | border:6px solid transparent; 87 | border-top-color: #0091EA; 88 | animation: spinner 0.7s linear infinite; 89 | } 90 | @keyframes spinner { 91 | to { 92 | transform: rotate(360deg); 93 | } 94 | 95 | -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy01.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy02.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy03.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/logo_nlpiffy04.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/nlpiffy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/nlpiffy.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/nlpiffy2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/NLPIffy_NLP_Based_SpaCy_Flask_App&_API/static/images/nlpiffy2.png -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/templates/images.html: -------------------------------------------------------------------------------- 1 | 2 | {% extends "bootstrap/base.html" %} 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 | {{ title }} - image 10 | 11 | 12 | 13 | 14 | 15 | {% block navbar %} 16 | 39 | 40 | {% endblock %} 41 |
42 |
43 |
44 |
45 |
46 |
47 |

NLPify

48 |

Where speed meet language

49 | Refresh » 50 |
51 |
52 | 53 | 54 |
55 |
56 |
57 | Image Placeholder 58 |
59 | 60 |
61 |
62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | 70 | {% endblock %} 71 | 72 | {% block styles %} 73 | {{super()}} 74 | 75 | 76 | 77 | 78 | 79 | {% endblock %} -------------------------------------------------------------------------------- /NLPIffy_NLP_Based_SpaCy_Flask_App&_API/templates/restfulapidocs.html: -------------------------------------------------------------------------------- 1 | {% extends "bootstrap/base.html" %} 2 | {% block content %} 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {% block navbar %} 15 | 38 | 39 | {% endblock %} 40 |
41 |
42 |
43 |
44 |
45 |
46 |

NLPiffy

47 |

Natural Language Processing simplified...

48 | Refresh » 49 |
50 |
51 | 52 | 53 |
54 |
55 |
56 |

API USAGE

57 |

For multiple words place inside a string(" ")

58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 | 67 |
68 |
69 | 70 | 71 |
72 |
73 | 74 | 75 | 76 | 77 | {% endblock %} 78 | 79 | {% block styles %} 80 | {{super()}} 81 | 82 | 83 | 84 | 85 | 86 | {% endblock %} -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/README.md: -------------------------------------------------------------------------------- 1 | ### Predicting Nationality and Gender Using Machine Learning 2 | 3 | #### Web App 4 | 5 | ##### Requirements 6 | + flask 7 | + sklearn 8 | + material_bootstrap 9 | 10 | 11 | 12 | ### Nationality and Ethnicity Predictor 13 | ![](images/image2.png) 14 | 15 | 16 | ### Gender Predictor 17 | ![](images/image1.png) 18 | 19 | 20 | 21 | #### By 22 | + Jesse E.Agbe(JCharis) 23 | + Jesus Saves@JCharisTech 24 | + J-Secur1ty -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | import numpy as np 3 | 4 | 5 | # ML Packages 6 | from sklearn.feature_extraction.text import CountVectorizer 7 | from sklearn.externals import joblib 8 | 9 | 10 | app = Flask(__name__) 11 | # Prediction 12 | def predict_gender(x): 13 | vect = gender_cv.transform(data).toarray() 14 | result = gender_clf.predict(vect) 15 | return result 16 | 17 | # Prediction 18 | def predict_nationality(x): 19 | vect = nationality_cv.transform(data).toarray() 20 | result = nationality_clf.predict(vect) 21 | return result 22 | 23 | 24 | 25 | 26 | @app.route('/') 27 | def index(): 28 | return render_template('index.html') 29 | 30 | @app.route('/gender') 31 | def gender(): 32 | return render_template('gender.html') 33 | 34 | @app.route('/predict', methods=['POST']) 35 | def predict(): 36 | # Load Our Count Vectorizer 37 | nationality_vectorizer = open("models/nationality_vectorizer.pkl","rb") 38 | cv_nationality = joblib.load(nationality_vectorizer) 39 | 40 | # Loading our ML Model 41 | nationality_nv_model = open("models/nationality_nv_model.pkl","rb") 42 | nationality_clf = joblib.load(nationality_nv_model) 43 | 44 | # Receives the input query from form 45 | if request.method == 'POST': 46 | namequery = request.form['namequery'] 47 | data = [namequery] 48 | 49 | vect = cv_nationality.transform(data).toarray() 50 | result = nationality_clf.predict(vect) 51 | 52 | return render_template('index.html',prediction = result ,name = namequery.upper()) 53 | 54 | 55 | @app.route('/predict_gender', methods=['POST']) 56 | def predict_gender(): 57 | # Load Our Count Vectorizer 58 | gender_vectorizer = open("models/gender_vectorizer.pkl","rb") 59 | cv_gender = joblib.load(gender_vectorizer) 60 | 61 | # Loading our ML Model 62 | gender_clf_nv_model = open("models/naivebayesgendermodel.pkl","rb") 63 | gender_clf = joblib.load(gender_clf_nv_model) 64 | 65 | # Receives the input query from form 66 | if request.method == 'POST': 67 | namequery = request.form['namequery'] 68 | data = [namequery] 69 | 70 | vect = cv_gender.transform(data).toarray() 71 | result = gender_clf.predict(vect) 72 | return render_template('gender.html',prediction = result ,name = namequery.upper()) 73 | 74 | 75 | if __name__ == '__main__': 76 | app.run(debug=True) -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/data/Predicting_Nationality_Ethnicity_with_Names_Using_ML/nationality_logit_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/data/Predicting_Nationality_Ethnicity_with_Names_Using_ML/nationality_logit_model.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/data/Predicting_Nationality_Ethnicity_with_Names_Using_ML/nationality_nv_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/data/Predicting_Nationality_Ethnicity_with_Names_Using_ML/nationality_nv_model.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/images/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/images/image1.png -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/images/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/images/image2.png -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/models/gender_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/models/gender_vectorizer.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/models/naivebayesgendermodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/models/naivebayesgendermodel.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/models/nationality_logit_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/models/nationality_logit_model.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/models/nationality_nv_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/models/nationality_nv_model.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/models/nationality_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Nationality_n_Gender Predictor_ML-WebApp/models/nationality_vectorizer.pkl -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/refactored_app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request,jsonify 2 | 3 | # ML Pkg 4 | from sklearn.externals import joblib 5 | # load Vectorizer For Gender Prediction 6 | gender_vectorizer = open("models/gender_vectorizer.pkl","rb") 7 | gender_cv = joblib.load(gender_vectorizer) 8 | 9 | # load Model For Gender Prediction 10 | gender_nv_model = open("models/naivebayesgendermodel.pkl","rb") 11 | gender_clf = joblib.load(gender_nv_model) 12 | 13 | 14 | # Load Vectorizer For Nationality Prediction 15 | nationality_vectorizer = open("models/nationality_vectorizer.pkl","rb") 16 | nationality_cv = joblib.load(nationality_vectorizer) 17 | # Load Models For Nationality Prediction 18 | nationality_nv_model = open("models/nationality_nv_model.pkl","rb") 19 | nationality_clf = joblib.load(nationality_nv_model) 20 | 21 | 22 | # Init App 23 | app = Flask(__name__) 24 | 25 | 26 | @app.route('/') 27 | def index(): 28 | return render_template('index.html') 29 | 30 | 31 | @app.route('/gender') 32 | def gender(): 33 | return render_template('gender.html') 34 | 35 | 36 | @app.route('/api') 37 | def api(): 38 | return render_template('api_docs.html') 39 | 40 | 41 | # ML Routes 42 | @app.route('/predict',methods=['GET','POST']) 43 | def predict(): 44 | if request.method == 'POST': 45 | namequery = request.form['namequery'] 46 | data = [namequery] 47 | 48 | # ML 49 | vect = nationality_cv.transform(data).toarray() 50 | result = nationality_clf.predict(vect) 51 | 52 | return render_template('index.html',name=namequery.upper(),prediction=result) 53 | 54 | 55 | @app.route('/predict_gender',methods=['GET','POST']) 56 | def predict_gender(): 57 | if request.method == 'POST': 58 | namequery = request.form['namequery'] 59 | data = [namequery] 60 | 61 | # ML 62 | vect = gender_cv.transform(data).toarray() 63 | result = gender_clf.predict(vect) 64 | return render_template('gender.html',name=namequery.title(),prediction=result) 65 | 66 | 67 | # Api 68 | @app.route('/api/nationality/') 69 | def api_nationality(name): 70 | data = [name] 71 | 72 | # ML 73 | vect = nationality_cv.transform(data).toarray() 74 | result = nationality_clf.predict(vect) 75 | 76 | return jsonify({"original name":name,"prediction":result[0]}) 77 | 78 | 79 | @app.route('/api/gender/') 80 | def api_gender(name): 81 | data= [name] 82 | 83 | # ML 84 | vect = gender_cv.transform(data).toarray() 85 | cus_prediction = gender_clf.predict(vect) 86 | if cus_prediction == 0: 87 | result = 'Female' 88 | else: 89 | result = 'Male' 90 | 91 | return jsonify({"original name":name,"prediction":result}) 92 | 93 | if __name__ == '__main__': 94 | app.run(debug=True) -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/templates/gender.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Nationality Predictor App 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 39 |
40 |
41 | 42 |
43 |
44 |

Gender Classifer and Predictor

45 |

Using Machine Learning

46 |

Refresh »

47 |
48 |
49 |
50 | 51 |
52 |
53 | 54 |
55 | 56 | 57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |

Original Text

66 |

{{ name }}

67 | 68 |
69 |
70 |
71 |
72 |

Prediction

73 | 74 | {% if prediction == 0 %} 75 |

78 | Female 79 | {% elif prediction == 1 %} 80 |

83 | Male 84 | {% endif%} 85 |
86 | 87 | 88 |
89 |
90 |
91 |
92 |
93 |
94 | 95 |
96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /Nationality_n_Gender Predictor_ML-WebApp/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Nationality Predictor App 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 39 |
40 |
41 | 42 |
43 |
44 |

Nationality of Names Predictor

45 |

Using Machine Learning

46 |

Refresh »

47 |
48 |
49 |
50 | 51 |
52 |
53 | 54 | 55 | 56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |

Original Name

65 |

{{ name }}

66 | 67 |
68 |
69 | 70 | 71 | 72 |
73 |
74 |

Prediction

75 | 76 | 77 |
78 |
79 |
80 |
81 |
82 |
83 | 84 |
85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Machine-Learning-Web-Apps 2 | Building and Embedding Machine Learning Model into a Web App(With Flask,Streamlit,Express,etc) 3 | 4 | 5 | ### Basic Requirements 6 | #### For Python ML Web Apps 7 | + Flask 8 | + Streamlit 9 | + Scikit-learn 10 | + Pandas 11 | + Numpy 12 | + Joblib/Pickle 13 | + Matplotlib 14 | + Spacy 15 | + NLTK 16 | + Textblob 17 | + Requests 18 | 19 | 20 | #### For Nodejs ML Web App 21 | + Express.js 22 | + Brainjs 23 | + Body-parser 24 | + etc 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/app.py: -------------------------------------------------------------------------------- 1 | # Flask Packages 2 | from flask import Flask,render_template,request,url_for 3 | from flask_bootstrap import Bootstrap 4 | from flask_uploads import UploadSet,configure_uploads,IMAGES,DATA,ALL 5 | from flask_sqlalchemy import SQLAlchemy 6 | 7 | from werkzeug import secure_filename 8 | import os 9 | import datetime 10 | import time 11 | 12 | 13 | # EDA Packages 14 | import pandas as pd 15 | import numpy as np 16 | 17 | # ML Packages 18 | from sklearn import model_selection 19 | from sklearn.linear_model import LogisticRegression 20 | from sklearn.tree import DecisionTreeClassifier 21 | from sklearn.neighbors import KNeighborsClassifier 22 | from sklearn.discriminant_analysis import LinearDiscriminantAnalysis 23 | from sklearn.naive_bayes import GaussianNB 24 | from sklearn.svm import SVC 25 | 26 | 27 | # ML Packages For Vectorization of Text For Feature Extraction 28 | from sklearn.feature_extraction.text import CountVectorizer 29 | from sklearn.feature_extraction.text import TfidfVectorizer 30 | 31 | 32 | 33 | 34 | app = Flask(__name__) 35 | Bootstrap(app) 36 | db = SQLAlchemy(app) 37 | 38 | # Configuration for File Uploads 39 | files = UploadSet('files',ALL) 40 | app.config['UPLOADED_FILES_DEST'] = 'static/uploadsDB' 41 | configure_uploads(app,files) 42 | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///static/uploadsDB/filestorage.db' 43 | 44 | # Saving Data To Database Storage 45 | class FileContents(db.Model): 46 | id = db.Column(db.Integer,primary_key=True) 47 | name = db.Column(db.String(300)) 48 | modeldata = db.Column(db.String(300)) 49 | data = db.Column(db.LargeBinary) 50 | 51 | 52 | @app.route('/') 53 | def index(): 54 | return render_template('index.html') 55 | 56 | # Route for our Processing and Details Page 57 | @app.route('/dataupload',methods=['GET','POST']) 58 | def dataupload(): 59 | if request.method == 'POST' and 'csv_data' in request.files: 60 | file = request.files['csv_data'] 61 | filename = secure_filename(file.filename) 62 | # os.path.join is used so that paths work in every operating system 63 | # file.save(os.path.join("wherever","you","want",filename)) 64 | file.save(os.path.join('static/uploadsDB',filename)) 65 | fullfile = os.path.join('static/uploadsDB',filename) 66 | 67 | # For Time 68 | date = str(datetime.datetime.fromtimestamp(time.time()).strftime("%Y-%m-%d %H:%M:%S")) 69 | 70 | # EDA function 71 | df = pd.read_csv(os.path.join('static/uploadsDB',filename)) 72 | df_size = df.size 73 | df_shape = df.shape 74 | df_columns = list(df.columns) 75 | df_targetname = df[df.columns[-1]].name 76 | df_featurenames = df_columns[0:-1] # select all columns till last column 77 | df_Xfeatures = df.iloc[:,0:-1] 78 | df_Ylabels = df[df.columns[-1]] # Select the last column as target 79 | # same as above df_Ylabels = df.iloc[:,-1] 80 | 81 | 82 | # Model Building 83 | X = df_Xfeatures 84 | Y = df_Ylabels 85 | seed = 7 86 | # prepare models 87 | models = [] 88 | models.append(('LR', LogisticRegression())) 89 | models.append(('LDA', LinearDiscriminantAnalysis())) 90 | models.append(('KNN', KNeighborsClassifier())) 91 | models.append(('CART', DecisionTreeClassifier())) 92 | models.append(('NB', GaussianNB())) 93 | models.append(('SVM', SVC())) 94 | # evaluate each model in turn 95 | 96 | 97 | results = [] 98 | names = [] 99 | allmodels = [] 100 | scoring = 'accuracy' 101 | for name, model in models: 102 | kfold = model_selection.KFold(n_splits=10, random_state=seed) 103 | cv_results = model_selection.cross_val_score(model, X, Y, cv=kfold, scoring=scoring) 104 | results.append(cv_results) 105 | names.append(name) 106 | msg = "%s: %f (%f)" % (name, cv_results.mean(), cv_results.std()) 107 | allmodels.append(msg) 108 | model_results = results 109 | model_names = names 110 | 111 | # Saving Results of Uploaded Files to Sqlite DB 112 | newfile = FileContents(name=file.filename,data=file.read(),modeldata=msg) 113 | db.session.add(newfile) 114 | db.session.commit() 115 | 116 | return render_template('details.html',filename=filename,date=date, 117 | df_size=df_size, 118 | df_shape=df_shape, 119 | df_columns =df_columns, 120 | df_targetname =df_targetname, 121 | model_results = allmodels, 122 | model_names = names, 123 | fullfile = fullfile, 124 | dfplot = df 125 | ) 126 | 127 | 128 | 129 | 130 | if __name__ == '__main__': 131 | app.run(debug=True) 132 | 133 | 134 | 135 | 136 | 137 | # Jesus Saves @ JCharisTech -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/app.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/app.pyc -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/static/uploadsDB/filestorage.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/static/uploadsDB/filestorage.db -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/static/uploadsDB/iris.csv: -------------------------------------------------------------------------------- 1 | sepal_length,sepal_width,petal_length,petal_width,species 2 | 5.1,3.5,1.4,0.2,setosa 3 | 4.9,3.0,1.4,0.2,setosa 4 | 4.7,3.2,1.3,0.2,setosa 5 | 4.6,3.1,1.5,0.2,setosa 6 | 5.0,3.6,1.4,0.2,setosa 7 | 5.4,3.9,1.7,0.4,setosa 8 | 4.6,3.4,1.4,0.3,setosa 9 | 5.0,3.4,1.5,0.2,setosa 10 | 4.4,2.9,1.4,0.2,setosa 11 | 4.9,3.1,1.5,0.1,setosa 12 | 5.4,3.7,1.5,0.2,setosa 13 | 4.8,3.4,1.6,0.2,setosa 14 | 4.8,3.0,1.4,0.1,setosa 15 | 4.3,3.0,1.1,0.1,setosa 16 | 5.8,4.0,1.2,0.2,setosa 17 | 5.7,4.4,1.5,0.4,setosa 18 | 5.4,3.9,1.3,0.4,setosa 19 | 5.1,3.5,1.4,0.3,setosa 20 | 5.7,3.8,1.7,0.3,setosa 21 | 5.1,3.8,1.5,0.3,setosa 22 | 5.4,3.4,1.7,0.2,setosa 23 | 5.1,3.7,1.5,0.4,setosa 24 | 4.6,3.6,1.0,0.2,setosa 25 | 5.1,3.3,1.7,0.5,setosa 26 | 4.8,3.4,1.9,0.2,setosa 27 | 5.0,3.0,1.6,0.2,setosa 28 | 5.0,3.4,1.6,0.4,setosa 29 | 5.2,3.5,1.5,0.2,setosa 30 | 5.2,3.4,1.4,0.2,setosa 31 | 4.7,3.2,1.6,0.2,setosa 32 | 4.8,3.1,1.6,0.2,setosa 33 | 5.4,3.4,1.5,0.4,setosa 34 | 5.2,4.1,1.5,0.1,setosa 35 | 5.5,4.2,1.4,0.2,setosa 36 | 4.9,3.1,1.5,0.1,setosa 37 | 5.0,3.2,1.2,0.2,setosa 38 | 5.5,3.5,1.3,0.2,setosa 39 | 4.9,3.1,1.5,0.1,setosa 40 | 4.4,3.0,1.3,0.2,setosa 41 | 5.1,3.4,1.5,0.2,setosa 42 | 5.0,3.5,1.3,0.3,setosa 43 | 4.5,2.3,1.3,0.3,setosa 44 | 4.4,3.2,1.3,0.2,setosa 45 | 5.0,3.5,1.6,0.6,setosa 46 | 5.1,3.8,1.9,0.4,setosa 47 | 4.8,3.0,1.4,0.3,setosa 48 | 5.1,3.8,1.6,0.2,setosa 49 | 4.6,3.2,1.4,0.2,setosa 50 | 5.3,3.7,1.5,0.2,setosa 51 | 5.0,3.3,1.4,0.2,setosa 52 | 7.0,3.2,4.7,1.4,versicolor 53 | 6.4,3.2,4.5,1.5,versicolor 54 | 6.9,3.1,4.9,1.5,versicolor 55 | 5.5,2.3,4.0,1.3,versicolor 56 | 6.5,2.8,4.6,1.5,versicolor 57 | 5.7,2.8,4.5,1.3,versicolor 58 | 6.3,3.3,4.7,1.6,versicolor 59 | 4.9,2.4,3.3,1.0,versicolor 60 | 6.6,2.9,4.6,1.3,versicolor 61 | 5.2,2.7,3.9,1.4,versicolor 62 | 5.0,2.0,3.5,1.0,versicolor 63 | 5.9,3.0,4.2,1.5,versicolor 64 | 6.0,2.2,4.0,1.0,versicolor 65 | 6.1,2.9,4.7,1.4,versicolor 66 | 5.6,2.9,3.6,1.3,versicolor 67 | 6.7,3.1,4.4,1.4,versicolor 68 | 5.6,3.0,4.5,1.5,versicolor 69 | 5.8,2.7,4.1,1.0,versicolor 70 | 6.2,2.2,4.5,1.5,versicolor 71 | 5.6,2.5,3.9,1.1,versicolor 72 | 5.9,3.2,4.8,1.8,versicolor 73 | 6.1,2.8,4.0,1.3,versicolor 74 | 6.3,2.5,4.9,1.5,versicolor 75 | 6.1,2.8,4.7,1.2,versicolor 76 | 6.4,2.9,4.3,1.3,versicolor 77 | 6.6,3.0,4.4,1.4,versicolor 78 | 6.8,2.8,4.8,1.4,versicolor 79 | 6.7,3.0,5.0,1.7,versicolor 80 | 6.0,2.9,4.5,1.5,versicolor 81 | 5.7,2.6,3.5,1.0,versicolor 82 | 5.5,2.4,3.8,1.1,versicolor 83 | 5.5,2.4,3.7,1.0,versicolor 84 | 5.8,2.7,3.9,1.2,versicolor 85 | 6.0,2.7,5.1,1.6,versicolor 86 | 5.4,3.0,4.5,1.5,versicolor 87 | 6.0,3.4,4.5,1.6,versicolor 88 | 6.7,3.1,4.7,1.5,versicolor 89 | 6.3,2.3,4.4,1.3,versicolor 90 | 5.6,3.0,4.1,1.3,versicolor 91 | 5.5,2.5,4.0,1.3,versicolor 92 | 5.5,2.6,4.4,1.2,versicolor 93 | 6.1,3.0,4.6,1.4,versicolor 94 | 5.8,2.6,4.0,1.2,versicolor 95 | 5.0,2.3,3.3,1.0,versicolor 96 | 5.6,2.7,4.2,1.3,versicolor 97 | 5.7,3.0,4.2,1.2,versicolor 98 | 5.7,2.9,4.2,1.3,versicolor 99 | 6.2,2.9,4.3,1.3,versicolor 100 | 5.1,2.5,3.0,1.1,versicolor 101 | 5.7,2.8,4.1,1.3,versicolor 102 | 6.3,3.3,6.0,2.5,virginica 103 | 5.8,2.7,5.1,1.9,virginica 104 | 7.1,3.0,5.9,2.1,virginica 105 | 6.3,2.9,5.6,1.8,virginica 106 | 6.5,3.0,5.8,2.2,virginica 107 | 7.6,3.0,6.6,2.1,virginica 108 | 4.9,2.5,4.5,1.7,virginica 109 | 7.3,2.9,6.3,1.8,virginica 110 | 6.7,2.5,5.8,1.8,virginica 111 | 7.2,3.6,6.1,2.5,virginica 112 | 6.5,3.2,5.1,2.0,virginica 113 | 6.4,2.7,5.3,1.9,virginica 114 | 6.8,3.0,5.5,2.1,virginica 115 | 5.7,2.5,5.0,2.0,virginica 116 | 5.8,2.8,5.1,2.4,virginica 117 | 6.4,3.2,5.3,2.3,virginica 118 | 6.5,3.0,5.5,1.8,virginica 119 | 7.7,3.8,6.7,2.2,virginica 120 | 7.7,2.6,6.9,2.3,virginica 121 | 6.0,2.2,5.0,1.5,virginica 122 | 6.9,3.2,5.7,2.3,virginica 123 | 5.6,2.8,4.9,2.0,virginica 124 | 7.7,2.8,6.7,2.0,virginica 125 | 6.3,2.7,4.9,1.8,virginica 126 | 6.7,3.3,5.7,2.1,virginica 127 | 7.2,3.2,6.0,1.8,virginica 128 | 6.2,2.8,4.8,1.8,virginica 129 | 6.1,3.0,4.9,1.8,virginica 130 | 6.4,2.8,5.6,2.1,virginica 131 | 7.2,3.0,5.8,1.6,virginica 132 | 7.4,2.8,6.1,1.9,virginica 133 | 7.9,3.8,6.4,2.0,virginica 134 | 6.4,2.8,5.6,2.2,virginica 135 | 6.3,2.8,5.1,1.5,virginica 136 | 6.1,2.6,5.6,1.4,virginica 137 | 7.7,3.0,6.1,2.3,virginica 138 | 6.3,3.4,5.6,2.4,virginica 139 | 6.4,3.1,5.5,1.8,virginica 140 | 6.0,3.0,4.8,1.8,virginica 141 | 6.9,3.1,5.4,2.1,virginica 142 | 6.7,3.1,5.6,2.4,virginica 143 | 6.9,3.1,5.1,2.3,virginica 144 | 5.8,2.7,5.1,1.9,virginica 145 | 6.8,3.2,5.9,2.3,virginica 146 | 6.7,3.3,5.7,2.5,virginica 147 | 6.7,3.0,5.2,2.3,virginica 148 | 6.3,2.5,5.0,1.9,virginica 149 | 6.5,3.0,5.2,2.0,virginica 150 | 6.2,3.4,5.4,2.3,virginica 151 | 5.9,3.0,5.1,1.8,virginica 152 | -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/templates/details.html: -------------------------------------------------------------------------------- 1 | {%extends "bootstrap/base.html" %} 2 | 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |

Simplified MLApp

12 |

Simplify Your Machine Learning and Data Exploration(Semi-Automated ML)

13 |

Refresh

14 |
15 |
16 | 17 | 18 | 19 |
20 | 21 |
22 |
23 |

Details of Dataset

24 | 25 | 28 | 29 | 32 | 33 |

Exploratory Data Analysis

34 | 35 | 36 | 39 | 40 | 49 | 50 | 53 |

Model Score

54 | 55 | {% for mlaccuracy in model_results %} 56 | 57 | 62 | 63 | {% endfor %} 64 | 65 |
66 | 67 | 68 |
69 |

Details of Dataset

70 |

{{ fullfile }}

71 | 72 |
73 |
74 |
75 | {{ dfplot.to_html(classes="table table-striped table-hover",na_rep="-") | safe}} 76 |
77 | 78 | 79 | 80 |
81 | 82 | 83 |
84 | 85 | 86 | 87 |
88 | 89 | 90 | {% endblock %} 91 | 92 | 93 | 94 | {% block scripts %} 95 | 96 | {{ super() }} 97 | 98 | 99 | 100 | 110 | 111 | 112 | 113 | {% endblock%} 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Completed-Semi-Automated-ML-Flask-App-With Drag-&-Drop/templates/index.html: -------------------------------------------------------------------------------- 1 | {%extends "bootstrap/base.html" %} 2 | 3 | {% block content %} 4 | 5 | 6 | 33 | 34 | {% block styles %} 35 | {{super()}} 36 | 37 | {% endblock %} 38 | 39 | 40 |
41 |
42 |

Simplified MLApp

43 |

Simplify Your Machine Learning and Data Exploration(Semi-Automated ML)

44 |

Refresh

45 |
46 | 47 | 48 |
49 |
50 |
51 |
52 |

Upload Your Dataset

53 |

We only accept csv format numerical data

54 |
55 |
56 | 57 |
58 |
59 | 60 | 61 | 62 |
63 |
64 |
65 |
66 | 67 |
68 |
69 |
70 | 71 | 72 | {% endblock %} 73 | 74 | 75 | 76 | {% block scripts %} 77 | 78 | {{ super() }} 79 | 80 | 94 | 95 | 96 | {% endblock%} 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Start- Semi-Automated-ML/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | from flask_bootstrap import Bootstrap 3 | 4 | 5 | 6 | app = Flask(__name__) 7 | Bootstrap(app) 8 | 9 | # Configuration 10 | 11 | 12 | import os 13 | import datetime 14 | import time 15 | 16 | 17 | #EDA Packages 18 | import pandas as pd 19 | import numpy as np 20 | 21 | 22 | # ML Packages 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | @app.route('/') 31 | def index(): 32 | return render_template('index.html') 33 | 34 | 35 | 36 | 37 | if __name__ == '__main__': 38 | app.run(debug=True) -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Start- Semi-Automated-ML/templates/details.html: -------------------------------------------------------------------------------- 1 | {%extends "bootstrap/base.html" %} 2 | 3 | {% block content %} 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |

Simplified MLApp

12 |

Simplify Your Machine Learning and Data Exploration(Semi-Automated ML)

13 |

Refresh

14 |
15 |
16 | 17 |
18 |

Results

19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {% endblock %} 37 | 38 | 39 | 40 | {% block scripts %} 41 | 42 | {{ super() }} 43 | 44 | 45 | 46 | 47 | {% endblock%} 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /Semi-Automated-Machine-Learning-Flask-App(Drag-&-Drop-Dataset)/Start- Semi-Automated-ML/templates/index.html: -------------------------------------------------------------------------------- 1 | {%extends "bootstrap/base.html" %} 2 | 3 | {% block content %} 4 | 5 |
6 |
7 |

Simplified MLApp

8 |

Simplify Your Machine Learning and Data Exploration(Semi-Automated ML)

9 |

Refresh

10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 | 18 |
19 | 20 |
21 | 22 |
23 | 24 | 25 | 26 | {% endblock %} 27 | 28 | 29 | 30 | {% block scripts %} 31 | 32 | {{ super() }} 33 | 34 | 35 | 36 | {% endblock%} 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/README.md: -------------------------------------------------------------------------------- 1 | ### Serving Machine Learning Models as API 2 | 3 | + Using FastAPI 4 | 5 | #### Installation 6 | ```bash 7 | pip install fastapi 8 | ``` 9 | 10 | #### Requires ASGI server to work 11 | + uvicorn or hypercorn 12 | ```bash 13 | pip install uvicorn 14 | ``` 15 | 16 | #### Screenshot 17 | ![](images/fastapi_tutorial_jcharistech01.png) 18 | 19 | 20 | ![](images/fastapi_tutorial_jcharistech03.png) 21 | 22 | 23 | ![](images/fastapi_tutorial_jcharistech04.png) 24 | 25 | 26 | ![](images/fastapi_tutorial_jcharistech06.png) 27 | 28 | 29 | ### By 30 | + Jesse E.Agbe(JCharis) 31 | + J-Secur1ty 32 | + Jesus Saves@JCharisTech -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/app.py: -------------------------------------------------------------------------------- 1 | import uvicorn 2 | from fastapi import FastAPI,Query 3 | 4 | 5 | 6 | # ML Pkg 7 | import joblib 8 | 9 | # Vectorizer 10 | gender_vectorizer = open("models/gender_vectorizer.pkl","rb") 11 | gender_cv = joblib.load(gender_vectorizer) 12 | 13 | 14 | # Models 15 | gender_nv_model = open("models/gender_nv_model.pkl","rb") 16 | gender_clf = joblib.load(gender_nv_model) 17 | 18 | 19 | # init app 20 | app = FastAPI() 21 | 22 | # Routes 23 | @app.get('/') 24 | async def index(): 25 | return {"text":"Hello API Masters"} 26 | 27 | @app.get('/items/') 28 | async def get_items(name:str = Query(None,min_length=2,max_length=7)): 29 | return {"name":name} 30 | 31 | # ML Aspect 32 | 33 | @app.get('/predict/') 34 | async def predict(name:str = Query(None,min_length=2,max_length=12)): 35 | vectorized_name = gender_cv.transform([name]).toarray() 36 | prediction = gender_clf.predict(vectorized_name) 37 | if prediction[0] == 0: 38 | result = "female" 39 | else: 40 | result = "male" 41 | 42 | return {"orig_name":name,"prediction":result} 43 | 44 | 45 | @app.post('/predict/{name}') 46 | async def predict(name): 47 | vectorized_name = gender_cv.transform([name]).toarray() 48 | prediction = gender_clf.predict(vectorized_name) 49 | if prediction[0] == 0: 50 | result = "female" 51 | else: 52 | result = "male" 53 | 54 | return {"orig_name":name,"prediction":result} 55 | 56 | 57 | 58 | if __name__ == '__main__': 59 | uvicorn.run(app,host="127.0.0.1",port=8000) -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech01.png -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech03.png -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech04.png -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/images/fastapi_tutorial_jcharistech06.png -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/models/__init__.py -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/models/gender_nv_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/models/gender_nv_model.pkl -------------------------------------------------------------------------------- /Serving_ML_Models_as_API_with_FastAPI/models/gender_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Serving_ML_Models_as_API_with_FastAPI/models/gender_vectorizer.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/README.md: -------------------------------------------------------------------------------- 1 | ### Using Machine Learning Models as a Package 2 | 3 | #### Spamdetector ML Package 4 | 5 | #### Resources 6 | + jupyter notebook with how the model was built 7 | + video tutorials 8 | + Using Poetry to Build Packages 9 | 10 | 11 | #### Code 12 | ```bash 13 | pip install poetry 14 | ``` 15 | 16 | #### Create A New Project and Package 17 | ```bash 18 | poetry new spamdetector 19 | ``` 20 | 21 | #### Add Packages to Our Project 22 | ```bash 23 | poetry add joblib scikit-learn 24 | ``` 25 | 26 | 27 | #### Building the Package 28 | 29 | ```bash 30 | poetry publish 31 | ``` 32 | ### NB 33 | + You need to create a TestPyPI and PyPI account to be able to publish officially 34 | for the general public. 35 | 36 | 37 | #### Usage of Package 38 | 39 | ```python 40 | >>> from spamdetector import CommentClassifier 41 | >>> cc = CommentClassifier() 42 | >>> cc.text = "this is a great tutorials" 43 | >>> cc.predict() 44 | 45 | ``` 46 | 47 | #### Loading Different Models and Classify 48 | ```python 49 | >>> from spamdetector import CommentClassifier 50 | >>> cc = CommentClassifier() 51 | >>> cc.text = "this is a great tutorials" 52 | >>> cc.load('nb') 53 | 54 | ``` 55 | 56 | ```python 57 | >>> from spamdetector import CommentClassifier 58 | >>> cc = CommentClassifier() 59 | >>> mytext = "this is a great tutorials" 60 | >>> cc.classify(mytext) 61 | ``` 62 | 63 | #### . 64 | + Jesus Saves@JCharisTech 65 | + Jesse E.Agbe(JCharis) -------------------------------------------------------------------------------- /SpamDetector_ML_Package/models/spam_detector_logit_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/models/spam_detector_logit_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/models/spam_detector_nb_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/models/spam_detector_nb_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/models/spam_detector_rf_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/models/spam_detector_rf_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/models/spam_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/models/spam_vectorizer.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/README.rst: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/README.rst -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "spamdetector" 3 | version = "0.0.1" 4 | description = "Spam Detector ML Package" 5 | authors = ["Jesse E.Agbe JCharis "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.7" 9 | joblib = "^0.14.0" 10 | scikit-learn = "^0.22.0" 11 | 12 | [tool.poetry.dev-dependencies] 13 | pytest = "^3.0" 14 | 15 | [build-system] 16 | requires = ["poetry>=0.12"] 17 | build-backend = "poetry.masonry.api" 18 | -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '0.0.1' 2 | from .spamdetector import CommentClassifier 3 | -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_logit_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_logit_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_nb_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_nb_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_rf_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_detector_rf_model.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/spamdetector/models/spam_vectorizer.pkl -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/spamdetector/spamdetector.py: -------------------------------------------------------------------------------- 1 | import os,joblib 2 | PACKAGE_DIR = os.path.dirname(__file__) 3 | 4 | class CommentClassifier(object): 5 | """docstring for CommentClassifier""" 6 | def __init__(self, text=None): 7 | super(CommentClassifier, self).__init__() 8 | self.text = text 9 | 10 | def __repr__(self): 11 | return 'CommentClassifier(text={})'.format(self.text) 12 | 13 | def predict(self): 14 | """Predict If It is Spam or Not 15 | By Default It uses the Naive Bayes Algorithm 16 | 17 | s = CommentClassifier() 18 | s.text = " " 19 | s.predict() 20 | 21 | """ 22 | # load Vectorizer For Spam Prediction 23 | spam_vectorizer = open(os.path.join(PACKAGE_DIR,"models/spam_vectorizer.pkl"),"rb") 24 | spam_cv = joblib.load(spam_vectorizer) 25 | 26 | # load Model For Spam Prediction 27 | spam_detector_nb_model = open(os.path.join(PACKAGE_DIR,"models/spam_detector_nb_model.pkl"),"rb") 28 | spam_detector_clf = joblib.load(spam_detector_nb_model) 29 | vectorized_data = spam_cv.transform([self.text]).toarray() 30 | prediction = spam_detector_clf.predict(vectorized_data) 31 | if prediction[0] == 0: 32 | result = 'Non-Spam' 33 | elif prediction[0] == 1: 34 | result = 'Spam' 35 | return result 36 | 37 | def load(self,model_type): 38 | """ 39 | Load A Model [nb:naive bayes,logit:logisticRegression] 40 | g = CommentClassifier() 41 | g.load('nb') 42 | 43 | """ 44 | if model_type == 'nb': 45 | spam_detector_nb_model = open(os.path.join(PACKAGE_DIR,"models/spam_detector_nb_model.pkl"),"rb") 46 | spam_detector_clf = joblib.load(spam_detector_nb_model) 47 | elif model_type == 'logit': 48 | spam_detector_logit_model = open(os.path.join(PACKAGE_DIR,"models/spam_detector_logit_model.pkl"),"rb") 49 | spam_detector_clf = joblib.load(spam_detector_logit_model) 50 | elif model_type == 'rf': 51 | spam_detector_rf_model = open(os.path.join(PACKAGE_DIR,"models/spam_detector_rf_model.pkl"),"rb") 52 | spam_detector_clf = joblib.load(spam_detector_rf_model) 53 | else: 54 | print("Please Select A Model Type [nb:naive bayes ,logit: logisticRegression, rf: Random Forest") 55 | 56 | return spam_detector_clf 57 | 58 | def classify(self,new_text): 59 | """ 60 | Classify Comment as Spam or Ham 61 | 62 | s = CommentClassifier() 63 | s.load('nb') 64 | s.classify('great package') 65 | 66 | """ 67 | self.text = new_text 68 | 69 | result = self.predict() 70 | return result 71 | 72 | 73 | def is_spam(self,new_text): 74 | 75 | self.text = new_text 76 | result = self.predict() 77 | return result == 'Spam' 78 | 79 | 80 | 81 | # Jesus Saves@JCharisTech -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/SpamDetector_ML_Package/spamdetector/tests/__init__.py -------------------------------------------------------------------------------- /SpamDetector_ML_Package/spamdetector/tests/test_spamdetector.py: -------------------------------------------------------------------------------- 1 | from spamdetector import __version__ 2 | from spamdetector import CommentClassifier 3 | 4 | 5 | def test_version(): 6 | assert __version__ == '0.0.1' 7 | 8 | 9 | def test_is_spam(): 10 | cc = CommentClassifier() 11 | cc.text = "please subcribe to our channel" 12 | result = cc.predict() 13 | assert result == 'Spam' 14 | 15 | def test_is_ham(): 16 | cc = CommentClassifier() 17 | result = cc.classify('great') 18 | assert result == 'Non-Spam' 19 | -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/__pycache__/spacy_summarization.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/__pycache__/spacy_summarization.cpython-36.pyc -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/app.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | from flask import Flask,render_template,url_for,request 3 | 4 | from spacy_summarization import text_summarizer 5 | from gensim.summarization import summarize 6 | from nltk_summarization import nltk_summarizer 7 | import time 8 | import spacy 9 | nlp = spacy.load('en') 10 | app = Flask(__name__) 11 | 12 | # Web Scraping Pkg 13 | from bs4 import BeautifulSoup 14 | # from urllib.request import urlopen 15 | from urllib import urlopen 16 | 17 | # Sumy Pkg 18 | from sumy.parsers.plaintext import PlaintextParser 19 | from sumy.nlp.tokenizers import Tokenizer 20 | from sumy.summarizers.lex_rank import LexRankSummarizer 21 | 22 | # Sumy 23 | def sumy_summary(docx): 24 | parser = PlaintextParser.from_string(docx,Tokenizer("english")) 25 | lex_summarizer = LexRankSummarizer() 26 | summary = lex_summarizer(parser.document,3) 27 | summary_list = [str(sentence) for sentence in summary] 28 | result = ' '.join(summary_list) 29 | return result 30 | 31 | 32 | # Reading Time 33 | def readingTime(mytext): 34 | total_words = len([ token.text for token in nlp(mytext)]) 35 | estimatedTime = total_words/200.0 36 | return estimatedTime 37 | 38 | # Fetch Text From Url 39 | def get_text(url): 40 | page = urlopen(url) 41 | soup = BeautifulSoup(page) 42 | fetched_text = ' '.join(map(lambda p:p.text,soup.find_all('p'))) 43 | return fetched_text 44 | 45 | @app.route('/') 46 | def index(): 47 | return render_template('index.html') 48 | 49 | 50 | @app.route('/analyze',methods=['GET','POST']) 51 | def analyze(): 52 | start = time.time() 53 | if request.method == 'POST': 54 | rawtext = request.form['rawtext'] 55 | final_reading_time = readingTime(rawtext) 56 | final_summary = text_summarizer(rawtext) 57 | summary_reading_time = readingTime(final_summary) 58 | end = time.time() 59 | final_time = end-start 60 | return render_template('index.html',ctext=rawtext,final_summary=final_summary,final_time=final_time,final_reading_time=final_reading_time,summary_reading_time=summary_reading_time) 61 | 62 | @app.route('/analyze_url',methods=['GET','POST']) 63 | def analyze_url(): 64 | start = time.time() 65 | if request.method == 'POST': 66 | raw_url = request.form['raw_url'] 67 | rawtext = get_text(raw_url) 68 | final_reading_time = readingTime(rawtext) 69 | final_summary = text_summarizer(rawtext) 70 | summary_reading_time = readingTime(final_summary) 71 | end = time.time() 72 | final_time = end-start 73 | return render_template('index.html',ctext=rawtext,final_summary=final_summary,final_time=final_time,final_reading_time=final_reading_time,summary_reading_time=summary_reading_time) 74 | 75 | 76 | 77 | @app.route('/compare_summary') 78 | def compare_summary(): 79 | return render_template('compare_summary.html') 80 | 81 | @app.route('/comparer',methods=['GET','POST']) 82 | def comparer(): 83 | start = time.time() 84 | if request.method == 'POST': 85 | rawtext = request.form['rawtext'] 86 | final_reading_time = readingTime(rawtext) 87 | final_summary_spacy = text_summarizer(rawtext) 88 | summary_reading_time = readingTime(final_summary_spacy) 89 | # Gensim Summarizer 90 | final_summary_gensim = summarize(rawtext) 91 | summary_reading_time_gensim = readingTime(final_summary_gensim) 92 | # NLTK 93 | final_summary_nltk = nltk_summarizer(rawtext) 94 | summary_reading_time_nltk = readingTime(final_summary_nltk) 95 | # Sumy 96 | final_summary_sumy = sumy_summary(rawtext) 97 | summary_reading_time_sumy = readingTime(final_summary_sumy) 98 | 99 | end = time.time() 100 | final_time = end-start 101 | return render_template('compare_summary.html',ctext=rawtext,final_summary_spacy=final_summary_spacy,final_summary_gensim=final_summary_gensim,final_summary_nltk=final_summary_nltk,final_time=final_time,final_reading_time=final_reading_time,summary_reading_time=summary_reading_time,summary_reading_time_gensim=summary_reading_time_gensim,final_summary_sumy=final_summary_sumy,summary_reading_time_sumy=summary_reading_time_sumy,summary_reading_time_nltk=summary_reading_time_nltk) 102 | 103 | 104 | 105 | @app.route('/about') 106 | def about(): 107 | return render_template('index.html') 108 | 109 | if __name__ == '__main__': 110 | app.run(debug=True) -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-41-28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-41-28.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-42-12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-42-12.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-43-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-43-05.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-43-22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-43-22.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-44-13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-44-13.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-44-37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-44-37.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-46-54.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/imagesforapp/Screenshot from 2019-01-02 16-46-54.png -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/nltk_summarization.py: -------------------------------------------------------------------------------- 1 | import nltk 2 | from nltk.corpus import stopwords 3 | from nltk.tokenize import word_tokenize, sent_tokenize 4 | import heapq 5 | 6 | def nltk_summarizer(raw_text): 7 | stopWords = set(stopwords.words("english")) 8 | word_frequencies = {} 9 | for word in nltk.word_tokenize(raw_text): 10 | if word not in stopWords: 11 | if word not in word_frequencies.keys(): 12 | word_frequencies[word] = 1 13 | else: 14 | word_frequencies[word] += 1 15 | 16 | maximum_frequncy = max(word_frequencies.values()) 17 | 18 | for word in word_frequencies.keys(): 19 | word_frequencies[word] = (word_frequencies[word]/maximum_frequncy) 20 | 21 | sentence_list = nltk.sent_tokenize(raw_text) 22 | sentence_scores = {} 23 | for sent in sentence_list: 24 | for word in nltk.word_tokenize(sent.lower()): 25 | if word in word_frequencies.keys(): 26 | if len(sent.split(' ')) < 30: 27 | if sent not in sentence_scores.keys(): 28 | sentence_scores[sent] = word_frequencies[word] 29 | else: 30 | sentence_scores[sent] += word_frequencies[word] 31 | 32 | 33 | 34 | summary_sentences = heapq.nlargest(7, sentence_scores, key=sentence_scores.get) 35 | 36 | summary = ' '.join(summary_sentences) 37 | return summary -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/nltk_summarization.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/nltk_summarization.pyc -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4 4.7.0 2 | bs4 0.0.1 3 | Flask 1.0.2 4 | nltk 3.4 5 | spacy 2.0.18 6 | sumy 0.7.0 7 | thinc 6.12.1 8 | urllib3 1.24.1 9 | gensim 3.6.0 10 | gensim-sum-ext 0.1.2 -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/spacy_summarization.py: -------------------------------------------------------------------------------- 1 | # NLP Pkgs 2 | import spacy 3 | nlp = spacy.load('en') 4 | # Pkgs for Normalizing Text 5 | from spacy.lang.en.stop_words import STOP_WORDS 6 | from string import punctuation 7 | # Import Heapq for Finding the Top N Sentences 8 | from heapq import nlargest 9 | 10 | 11 | 12 | def text_summarizer(raw_docx): 13 | raw_text = raw_docx 14 | docx = nlp(raw_text) 15 | stopwords = list(STOP_WORDS) 16 | # Build Word Frequency # word.text is tokenization in spacy 17 | word_frequencies = {} 18 | for word in docx: 19 | if word.text not in stopwords: 20 | if word.text not in word_frequencies.keys(): 21 | word_frequencies[word.text] = 1 22 | else: 23 | word_frequencies[word.text] += 1 24 | 25 | 26 | maximum_frequncy = max(word_frequencies.values()) 27 | 28 | for word in word_frequencies.keys(): 29 | word_frequencies[word] = (word_frequencies[word]/maximum_frequncy) 30 | # Sentence Tokens 31 | sentence_list = [ sentence for sentence in docx.sents ] 32 | 33 | # Sentence Scores 34 | sentence_scores = {} 35 | for sent in sentence_list: 36 | for word in sent: 37 | if word.text.lower() in word_frequencies.keys(): 38 | if len(sent.text.split(' ')) < 30: 39 | if sent not in sentence_scores.keys(): 40 | sentence_scores[sent] = word_frequencies[word.text.lower()] 41 | else: 42 | sentence_scores[sent] += word_frequencies[word.text.lower()] 43 | 44 | 45 | summarized_sentences = nlargest(7, sentence_scores, key=sentence_scores.get) 46 | final_sentences = [ w.text for w in summarized_sentences ] 47 | summary = ' '.join(final_sentences) 48 | return summary 49 | -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/spacy_summarization.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Summaryzer_Text_Summarization_App/spacy_summarization.pyc -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/spacy_summarizer.py: -------------------------------------------------------------------------------- 1 | # NLP Pkgs 2 | import spacy 3 | nlp = spacy.load('en') 4 | # Pkgs for Normalizing Text 5 | from spacy.lang.en.stop_words import STOP_WORDS 6 | from string import punctuation 7 | # Import Heapq for Finding the Top N Sentences 8 | from heapq import nlargest 9 | 10 | 11 | 12 | def text_summarizer(raw_docx): 13 | raw_text = raw_docx 14 | docx = nlp(raw_text) 15 | stopwords = list(STOP_WORDS) 16 | # Build Word Frequency # word.text is tokenization in spacy 17 | word_frequencies = {} 18 | for word in docx: 19 | if word.text not in stopwords: 20 | if word.text not in word_frequencies.keys(): 21 | word_frequencies[word.text] = 1 22 | else: 23 | word_frequencies[word.text] += 1 24 | 25 | 26 | maximum_frequncy = max(word_frequencies.values()) 27 | 28 | for word in word_frequencies.keys(): 29 | word_frequencies[word] = (word_frequencies[word]/maximum_frequncy) 30 | # Sentence Tokens 31 | sentence_list = [ sentence for sentence in docx.sents ] 32 | 33 | # Sentence Scores 34 | sentence_scores = {} 35 | for sent in sentence_list: 36 | for word in sent: 37 | if word.text.lower() in word_frequencies.keys(): 38 | if len(sent.text.split(' ')) < 30: 39 | if sent not in sentence_scores.keys(): 40 | sentence_scores[sent] = word_frequencies[word.text.lower()] 41 | else: 42 | sentence_scores[sent] += word_frequencies[word.text.lower()] 43 | 44 | 45 | summarized_sentences = nlargest(7, sentence_scores, key=sentence_scores.get) 46 | final_sentences = [ w.text for w in summarized_sentences ] 47 | summary = ' '.join(final_sentences) 48 | print("Original Document\n") 49 | print(raw_docx) 50 | print("Total Length:",len(raw_docx)) 51 | print('\n\nSummarized Document\n') 52 | print(summary) 53 | print("Total Length:",len(summary)) 54 | -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/static/css/custom.css: -------------------------------------------------------------------------------- 1 | /* Custom Stylesheet */ 2 | /** 3 | * Use this file to override Materialize files so you can update 4 | * the core Materialize files in the future 5 | * 6 | * Made By MaterializeCSS.com 7 | */ 8 | 9 | nav ul a, 10 | nav .brand-logo { 11 | color: #444; 12 | } 13 | 14 | p { 15 | line-height: 2rem; 16 | } 17 | 18 | .sidenav-trigger { 19 | color: #26a69a; 20 | } 21 | 22 | .parallax-container { 23 | min-height: 380px; 24 | line-height: 0; 25 | height: auto; 26 | color: rgba(255,255,255,.9); 27 | } 28 | .parallax-container .section { 29 | width: 100%; 30 | } 31 | 32 | @media only screen and (max-width : 992px) { 33 | .parallax-container .section { 34 | position: absolute; 35 | top: 40%; 36 | } 37 | #index-banner .section { 38 | top: 10%; 39 | } 40 | } 41 | 42 | @media only screen and (max-width : 600px) { 43 | #index-banner .section { 44 | top: 0; 45 | } 46 | } 47 | 48 | .icon-block { 49 | padding: 0 15px; 50 | } 51 | .icon-block .material-icons { 52 | font-size: inherit; 53 | } 54 | 55 | footer.page-footer { 56 | margin: 0; 57 | } 58 | -------------------------------------------------------------------------------- /Summaryzer_Text_Summarization_App/static/js/init.js: -------------------------------------------------------------------------------- 1 | (function($){ 2 | $(function(){ 3 | 4 | $('.sidenav').sidenav(); 5 | $('.parallax').parallax(); 6 | // TABS INIT 7 | $('.tabs').tabs(); 8 | // CAROUSEL INIT 9 | $('.carousel.carousel-slider').carousel({ fullWidth: true }); 10 | // SLIDER INIT 11 | $('.slider').slider({ 12 | indicators: false, 13 | // we don't want the little dots to show 14 | height: 500, 15 | transition: 500, 16 | interval: 6000 17 | // how long the slide stays for 18 | }); 19 | 20 | 21 | }); // end of document ready 22 | })(jQuery); // end of jQuery name space 23 | 24 | 25 | -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask,render_template,url_for,request 2 | import pandas as pd 3 | import pickle 4 | from sklearn.feature_extraction.text import CountVectorizer 5 | from sklearn.naive_bayes import MultinomialNB 6 | from sklearn.externals import joblib 7 | 8 | 9 | app = Flask(__name__) 10 | 11 | @app.route('/') 12 | def home(): 13 | return render_template('home.html') 14 | 15 | @app.route('/predict',methods=['POST']) 16 | def predict(): 17 | df= pd.read_csv("YoutubeSpamMergedData.csv") 18 | df_data = df[["CONTENT","CLASS"]] 19 | # Features and Labels 20 | df_x = df_data['CONTENT'] 21 | df_y = df_data.CLASS 22 | # Extract Feature With CountVectorizer 23 | corpus = df_x 24 | cv = CountVectorizer() 25 | X = cv.fit_transform(corpus) # Fit the Data 26 | from sklearn.model_selection import train_test_split 27 | X_train, X_test, y_train, y_test = train_test_split(X, df_y, test_size=0.33, random_state=42) 28 | #Naive Bayes Classifier 29 | from sklearn.naive_bayes import MultinomialNB 30 | clf = MultinomialNB() 31 | clf.fit(X_train,y_train) 32 | clf.score(X_test,y_test) 33 | #Alternative Usage of Saved Model 34 | # ytb_model = open("naivebayes_spam_model.pkl","rb") 35 | # clf = joblib.load(ytb_model) 36 | 37 | if request.method == 'POST': 38 | comment = request.form['comment'] 39 | data = [comment] 40 | vect = cv.transform(data).toarray() 41 | my_prediction = clf.predict(vect) 42 | return render_template('result.html',prediction = my_prediction) 43 | 44 | 45 | 46 | if __name__ == '__main__': 47 | app.run(debug=True) -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/data/YoutubeSpamMergeddata.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Youtube-Spam-Detector-ML-Flask-App/data/YoutubeSpamMergeddata.csv -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/data/naivebayes_spam_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/Youtube-Spam-Detector-ML-Flask-App/data/naivebayes_spam_model.pkl -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/static/css/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | font:15px/1.5 Arial, Helvetica,sans-serif; 3 | padding: 0px; 4 | background-color:#f4f3f3; 5 | } 6 | 7 | .container{ 8 | width:100%; 9 | margin: auto; 10 | overflow: hidden; 11 | } 12 | 13 | header{ 14 | background:#03A9F4;#35434a; 15 | border-bottom:#448AFF 3px solid; 16 | height:120px; 17 | width:100%; 18 | padding-top:30px; 19 | 20 | } 21 | 22 | .main-header{ 23 | text-align:center; 24 | background-color: blue; 25 | height:100px; 26 | width:100%; 27 | margin:0px; 28 | } 29 | #brandname{ 30 | float:left; 31 | font-size:30px; 32 | color: #fff; 33 | margin: 10px; 34 | } 35 | 36 | header h2{ 37 | text-align:center; 38 | color:#fff; 39 | 40 | } 41 | 42 | 43 | 44 | .btn-info {background-color: #2196F3; 45 | height:40px; 46 | width:100px;} /* Blue */ 47 | .btn-info:hover {background: #0b7dda;} 48 | 49 | 50 | .resultss{ 51 | border-radius: 15px 50px; 52 | background: #345fe4; 53 | padding: 20px; 54 | width: 200px; 55 | height: 150px; 56 | } -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/templates/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Home 5 | 6 | 7 | 8 | 9 | 10 |
11 |
12 |
13 | ML App 14 |
15 |

Spam Detection For Youtube Comments

16 | 17 |
18 |
19 | 20 |
21 | 22 |
23 |

Enter Your Comment Here

24 | 25 | 26 |
27 | 28 | 29 | 30 |
31 | 32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Youtube-Spam-Detector-ML-Flask-App/templates/result.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 |
11 |
12 | ML App 13 |
14 |

Spam Detection For Youtube Comments

15 | 16 |
17 |
18 |

Results for Comment

19 |
20 | 21 | 22 | 23 | {% if prediction == 1%} 24 |

Spam

25 | {% elif prediction == 0%} 26 |

Not a Spam (It is a Ham)

27 | {% endif %} 28 | 29 |
30 | 31 | 32 | -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/README.md: -------------------------------------------------------------------------------- 1 | ### Gender Classifier ML App with Streamlit 2 | 3 | 4 | #### Home 5 | ![](images/gc_app01.png) 6 | 7 | 8 | #### Prediction 9 | ![](images/gc_app02.png) 10 | 11 | 12 | #### Prediction 13 | ![](images/gc_app04.png) 14 | 15 | 16 | #### By 17 | + Jesse E.Agbe(JCharis) 18 | + Jesus Saves@[JCharisTech](https://jcharistech.com) -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/app.py: -------------------------------------------------------------------------------- 1 | import streamlit as st 2 | # ML Pkg 3 | # from sklearn.externals import joblib 4 | import joblib 5 | import time 6 | from PIL import Image 7 | 8 | # load Vectorizer For Gender Prediction 9 | gender_vectorizer = open("models/gender_vectorizer.pkl","rb") 10 | gender_cv = joblib.load(gender_vectorizer) 11 | 12 | # load Model For Gender Prediction 13 | gender_nv_model = open("models/naivebayesgendermodel.pkl","rb") 14 | gender_clf = joblib.load(gender_nv_model) 15 | 16 | 17 | # Prediction 18 | def predict_gender(data): 19 | vect = gender_cv.transform(data).toarray() 20 | result = gender_clf.predict(vect) 21 | return result 22 | 23 | # Load CSS File 24 | def load_css(file_name): 25 | with open(file_name) as f: 26 | st.markdown(''.format(f.read()), unsafe_allow_html=True) 27 | 28 | def load_icon(icon_name): 29 | st.markdown('{}'.format(icon_name), unsafe_allow_html=True) 30 | 31 | # Images 32 | def load_images(file_name): 33 | img = Image.open(file_name) 34 | return st.image(img,width=300) 35 | 36 | 37 | def main(): 38 | """Gender Classifier App 39 | Using Machine Learning and Streamlit 40 | 41 | """ 42 | 43 | st.title("Gender Classifier") 44 | html_temp = """ 45 |
46 |

Streamlit ML App

47 |
48 | 49 | """ 50 | st.markdown(html_temp,unsafe_allow_html=True) 51 | load_css('icon.css') 52 | load_icon('people') 53 | 54 | name = st.text_input("Enter Name","Type Here") 55 | if st.button("Predict"): 56 | result = predict_gender([name]) 57 | if result[0] == 0: 58 | prediction = 'Female' 59 | c_img = 'female.png' 60 | else: 61 | result[0] == 1 62 | prediction = 'Male' 63 | c_img = 'male.png' 64 | 65 | st.success('Name: {} was classified as {}'.format(name.title(),prediction)) 66 | load_images(c_img) 67 | 68 | 69 | if st.button("About"): 70 | 71 | st.text("Jesus Saves @JCharisTech") 72 | st.text("By Jesse E.Agbe(JCharis)") 73 | st.text("Built with Streamlit") 74 | 75 | 76 | 77 | if __name__ == '__main__': 78 | main() -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/female.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/female.png -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/icon.css: -------------------------------------------------------------------------------- 1 | /* fallback */ 2 | @font-face { 3 | font-family: 'Material Icons'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: url(https://fonts.gstatic.com/s/materialicons/v48/flUhRq6tzZclQEJ-Vdg-IuiaDsNc.woff2) format('woff2'); 7 | } 8 | 9 | .material-icons { 10 | font-family: 'Material Icons'; 11 | font-weight: normal; 12 | font-style: normal; 13 | font-size: 24px; 14 | line-height: 1; 15 | letter-spacing: normal; 16 | text-transform: none; 17 | display: inline-block; 18 | white-space: nowrap; 19 | word-wrap: normal; 20 | direction: ltr; 21 | -webkit-font-feature-settings: 'liga'; 22 | -webkit-font-smoothing: antialiased; 23 | } 24 | -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/images/gc_app01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/images/gc_app01.png -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/images/gc_app02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/images/gc_app02.png -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/images/gc_app04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/images/gc_app04.png -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/male.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/male.png -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/models/gender_vectorizer.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/models/gender_vectorizer.pkl -------------------------------------------------------------------------------- /gender_classifier_mlapp_with_streamlit/models/naivebayesgendermodel.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Jcharis/Machine-Learning-Web-Apps/a6996b634d98ccec4701ac8934016e8175b60eb5/gender_classifier_mlapp_with_streamlit/models/naivebayesgendermodel.pkl --------------------------------------------------------------------------------