An AI solution which cognitively able to detect(classify) reviews in fractions of seconds. hence, fewer human interventions, more precise, uniform results, and most importantly operational efficiency.
- Project Structure Overview
- Model Training Part
- Run python app
- Dockerizing an application
- Deploy to Kubernetes
- Version
- Author
- References
├── TextClassifier
│ │
│ ├── common_operations - this package contains common operation tasks.
│ │ ├── __init__.py
│ │ └── common_operations.py - this file reads config and convert to dictionary.
│ │
│ ├── data - this folder contains data for testing.
│ │ ├── Contraction.json - file for text preprocessing.
│ │ └── TouchnoteReveiws.csv - Sample reviews of touch note app.
│ │
│ └── logger - here's the logger package.
│ │ ├── __init__.py
│ │ ├── APILogger.py - to send non-success code to front-end.
│ │ ├── logger.py - to log info & error in the code.
│ │ └── LoggerError.py - to log error while creating a logger object.
│ │
│ └── ModelPredictor - this package is used to get prediction.
│ │ ├── __init__.py
│ │ └── ModelPredictor.py - this code reads input and return prediction.
│ │
│ └── models - this folder contains exported models.
│ │ ├── model_mapping.json - to store model metadata. ex. Path.
│ │ ├── log_reg.sav
│ │ ├── naive_bayes.sav
│ │ └── svm.sav
│ │
│ └── TextPreprocessor - here's the package used to clean the raw input.
│ │ ├── __init__.py
│ │ └── TextPreprocessor.py - this code takes raw text and return clean string for prediction.
│ │
│ └── TextClassifier.py - driver code to execute operations smoothly.
│
│
├── Touch Note App Review Analysis - this folder contains model training related data, models & notebook.
| |
│ └── models - this folder holds exported models.
│ │ ├── log_reg.sav - Logistic Regression Model.
│ │ ├── naive_bayes.sav - Naive Bayes Model
│ │ └── svm.sav - SVM Model.
│ │
│ └── data - this folder contains data used for model training.
│ │ ├── Contraction.json - here's the file for text preprocessing.
│ │ └── google_play_store_apps_reviews_training.csv - Training Dataset.
| |
│ ├── Touch Note App Review Analysis.ipynb - Data Analysis & Model Training Notebook.
│ └── Touch Note App Review Analysis.html - Exported version in HTML.
|
│
├── static - this folder contains bootstrap 4 files.
│ └── asset
│ └── img
│ └── js
│ └── style
│ └── index.js - here's the file for frond-end form submission to flask app and vice versa.
│
│
├── templates - this folder contains front-end html files.
│ └── index.html
│
│
├── kubernetes - this folder contains yaml file for deployment.
│ └── deployment.yaml - Kubernetes YAML file
│
│
├── Dockerfile - here's the docker file used to create docker image.
├── README.md - here's the ReadMe of an application.
├── config.ini - here's the specific config file for the application.
├── requirements.txt - here's the python package requirement txt.
└── run.py - here's runnable of an application.
Please refer Touch Note App Review Analysis/Touch Note App Review Analysis.ipynb
notebook for data analysis & model training.
A step by step series of examples that tell you how to get a development env running
pip install -r requirements.txt
If successfully installed, Change values in config file.
[Path]
ModelMappingFilePath = .\models\model_mapping.json
etc..
Now, you can run project as follows
python run.py
C:\Users\Alice> python run.py
* Serving Flask app "run" (lazy loading)
* Environment: production
* Debug mode: on
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
FROM python:3.7
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
EXPOSE 5000
RUN python -m nltk.downloader popular
ENTRYPOINT [ "python" ]
CMD [ "run.py" ]
Make sure you are in root directory of the project and run the following command.
docker build --tag touchnote-review-analysis-app .
The above command will create an app with the tag touchnote-review-analysis-app
docker run --name touchnote-review-analysis-app -p 5000:5000 touchnote-review-analysis-app
docker commit container-id user-name/touchnote-review-analysis-app:latest
docker login
docker push user-name/touchnote-review-analysis-app:latest
Progress bars are shown during docker push, which show the uncompressed size. The actual amount of data that’s pushed will be compressed before sending, so the uploaded size will not be reflected by the progress bar.
I have already wrote a Kubernetes YAML file. Place the following in a file called deployment.yaml under kubernetes folder:
apiVersion: apps/v1
kind: Deployment
metadata:
name: touchnote-app
namespace: default
spec:
replicas: 2
selector:
matchLabels:
touchnote_app: web
template:
metadata:
labels:
touchnote_app: web
spec:
containers:
- name: app-site
image: rahul2010/touchnote-review-analysis-app:latest
ports:
- containerPort: 5000
- In a terminal, navigate to where you created deployment.yaml and deploy your application to Kubernetes:
kubectl apply -f .\kubernetes\deployment.yaml
you should see output that looks like the following, indicating your Kubernetes objects were created successfully:
deployment.apps/touchnote-app created
- Make sure everything worked by listing your deployments:
NAME READY UP-TO-DATE AVAILABLE AGE
touchnote-app 2/2 2 2 53m
This indicates all one of the pods you asked for in your YAML are up and running.
1.0.0
- Rahul Gaikwad - Initial work and development