-
Notifications
You must be signed in to change notification settings - Fork 0
Add README.md #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,202 @@ | ||||||
| # Classifier-Server | ||||||
|
|
||||||
| A Flask-based REST API server for document classification using machine learning models. This server provides two types of classifiers: a General Classifier and a Confidential Classifier, both built using scikit-learn and deployed as RESTful web services. | ||||||
|
|
||||||
| ## Features | ||||||
|
|
||||||
| - **General Classification**: Classifies documents into general categories (e.g., sports, politics, technology) | ||||||
| - **Confidential Classification**: Specialized classifier for confidential document categorization | ||||||
| - **REST API**: Easy-to-use HTTP endpoints for text classification | ||||||
| - **Cross-Origin Resource Sharing (CORS)**: Enabled for cross-domain requests | ||||||
| - **Pre-trained Models**: Uses pickled machine learning models for fast inference | ||||||
|
|
||||||
| ## Technology Stack | ||||||
|
|
||||||
| - **Flask**: Web framework for the REST API | ||||||
| - **Flask-CORS**: Cross-origin resource sharing support | ||||||
| - **scikit-learn**: Machine learning library (TF-IDF vectorization and classification models) | ||||||
| - **Python 3**: Programming language | ||||||
|
|
||||||
| ## Installation | ||||||
|
|
||||||
| 1. Clone the repository: | ||||||
| ```bash | ||||||
| git clone https://github.com/AyeshW/Classifer-Server.git | ||||||
| cd Classifer-Server | ||||||
| ``` | ||||||
|
|
||||||
| 2. Install the required dependencies: | ||||||
| ```bash | ||||||
| pip install flask flask-cors scikit-learn | ||||||
| ``` | ||||||
|
|
||||||
| 3. Ensure the following pickle files are present in the root directory: | ||||||
| - `gen_clf.pickle` - General classifier model | ||||||
| - `gen_tfidf.pickle` - General TF-IDF vectorizer | ||||||
| - `gen_id_map.pickle` - General category ID mapping | ||||||
| - `conf_clf.pickle` - Confidential classifier model | ||||||
| - `conf_tfidf.pickle` - Confidential TF-IDF vectorizer | ||||||
| - `conf_id_map.pickle` - Confidential category ID mapping | ||||||
|
|
||||||
| ## Usage | ||||||
|
|
||||||
| ### Starting the Server | ||||||
|
|
||||||
| Run the Flask application: | ||||||
| ```bash | ||||||
| python app.py | ||||||
| ``` | ||||||
|
|
||||||
| The server will start on the default Flask port (5000). You can access the welcome page at: | ||||||
| ``` | ||||||
| http://localhost:5000/ | ||||||
| ``` | ||||||
|
|
||||||
| ### API Endpoints | ||||||
|
|
||||||
| #### 1. General Classification | ||||||
|
|
||||||
| **Endpoint**: `/gen_category` | ||||||
| **Method**: `POST` | ||||||
| **Content-Type**: `application/json` | ||||||
|
|
||||||
| **Request Body**: | ||||||
| ```json | ||||||
| [ | ||||||
| { | ||||||
| "path": "document1.txt", | ||||||
| "text": "Sri Lanka cricket team won the 1996 world championship" | ||||||
| }, | ||||||
| { | ||||||
| "path": "document2.txt", | ||||||
| "text": "Your text content here" | ||||||
| } | ||||||
| ] | ||||||
| ``` | ||||||
|
|
||||||
| **Response**: | ||||||
| ```json | ||||||
| [ | ||||||
| { | ||||||
| "path": "document1.txt", | ||||||
| "category": "sport" | ||||||
| }, | ||||||
| { | ||||||
| "path": "document2.txt", | ||||||
| "category": "politics" | ||||||
| } | ||||||
| ] | ||||||
| ``` | ||||||
|
|
||||||
| #### 2. Confidential Classification | ||||||
|
|
||||||
| **Endpoint**: `/conf_category` | ||||||
| **Method**: `POST` | ||||||
| **Content-Type**: `application/json` | ||||||
|
|
||||||
| **Request Body**: | ||||||
| ```json | ||||||
| [ | ||||||
| { | ||||||
| "path": "confidential_doc1.txt", | ||||||
| "text": "Your confidential text content here" | ||||||
| } | ||||||
| ] | ||||||
| ``` | ||||||
|
|
||||||
| **Response**: | ||||||
| ```json | ||||||
| [ | ||||||
| { | ||||||
| "path": "confidential_doc1.txt", | ||||||
| "category": "classified_category" | ||||||
| } | ||||||
| ] | ||||||
| ``` | ||||||
|
|
||||||
| ### Example Usage with cURL | ||||||
|
|
||||||
| ```bash | ||||||
| curl -X POST http://localhost:5000/gen_category \ | ||||||
| -H "Content-Type: application/json" \ | ||||||
| -d '[{"path": "test.txt", "text": "Sri Lanka cricket team won the 1996 world championship"}]' | ||||||
| ``` | ||||||
|
|
||||||
| ## Project Structure | ||||||
|
|
||||||
| ``` | ||||||
| Classifer-Server/ | ||||||
|
||||||
| Classifer-Server/ | |
| Classifier-Server/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The repository name in the installation instructions is inconsistent with the project title: here it uses
Classifer-Serverwhile the header usesClassifier-Server. To avoid confusing users or causinggit clone/cdcommands to fail when copied, please standardize the spelling of the repository name across the README (likely toClassifier-Server).