Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Language Identifier
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
## OVERVIEW
|
| 5 |
+
This project is a Flask web application that identifies the language of input text. It uses a machine learning model trained on text data to make predictions. The user inputs text into a form on the web app, and the app returns the predicted language.
|
| 6 |
+
|
| 7 |
+
## SPECIFICATIONS
|
| 8 |
+
- The data used for training is taken from Kaggle. It has 22 different languages.
|
| 9 |
+
- The text in the dataset has tokenization, non alphanumeric characters removal and vectorization applied to it.
|
| 10 |
+
- The model used for training has 4 layers with 27M params which is enough for getting high accuracy. Complex architectures couldn’t be used because of not sufficient GPUs.
|
| 11 |
+
- Techniques like early stopping, learning rate decay and weight decay are used while training to get the most accurate results.
|
| 12 |
+
- The metrics used for evaluation is accuracy, 97.89% of which is achieved.
|
| 13 |
+
- I usually use Pytorch but this time I used Tensorflow because converting tokens into tensors crashed the GPU constantly.
|
| 14 |
+
- The project uses Flask, a lightweight web framework for Python, to create the web application.
|
| 15 |
+
- The input text is preprocessed before being fed into the model for prediction.
|
| 16 |
+
|
| 17 |
+
## USAGE
|
| 18 |
+
|
| 19 |
+
```python
|
| 20 |
+
def predict_language(text, model, cv, le):
|
| 21 |
+
cleaned_text = clean_text(text)
|
| 22 |
+
text_vectorized = cv.transform([cleaned_text])
|
| 23 |
+
prediction = model.predict(text_vectorized)
|
| 24 |
+
predicted_label = le.inverse_transform([np.argmax(prediction)])[0] # Get the first element of the list
|
| 25 |
+
return predicted_label
|
| 26 |
+
sentence = 'random text'
|
| 27 |
+
predicted_label = predict_language(sentence, model, cv, le)
|
| 28 |
+
print(predicted_label)
|