Skip to main content

No project description provided

Project description

CatMod (Categorical classification Model)

Short introduction

  • In a modern word that required fast robust and simple development process with Machine Learning, AI and Deep Learning, there are countless of projects require Natural Language Processing (NLP) classification problems such as Commodity Classification, Company Type Classification, Food Type classification, etc.
    More and more people want to train, test and deploy NLP classification model without having to know the background of advanced in programming and AI knowledge.
  • This Framework will allow everyone to train, test and save and load their own model and deploy it wherever they want with some simple lines of code.

Virtual Enviroment / Dependencies

  • It is recommended to create a vitual enviroment for your project when using CatMod as it will download and install packages and dependencies that might conflict with your dependencies on your machine.
  • If you don't mind about the version of the libraries listed in the requirements.txt you can leave it as it is.

How to use

  • Please clone or download this repository to your project folder, please assure that catmod.py file stay in the same folder of your python main file (The file in which you want to import CatMod)

e.g.

ProjectFolder
|---main.py
|---catmod.py
|---utils
|   |----...
|   |
...
from cat_mod import CatMod
cat = CatMod('[your_file_path]')

e.g.

file_path = 'C:/User/Desktop/glove.6B.50d.txt'
cat = CatMod(glove_file = file_path)
file_path = 'Machintosh HD/Users/yourName/Desktop/glove.6B.50d.txt'
cat = CatMode(glove_file = file_path)

Training Process

This Framework will allow you to input a .csv file with many columns but you have to specify 2 columns corresponding to values (X) and targets (Y).

Let's say you have a csv file product.csv with columns look like this

company name product name category
... ... ...
  • You can use 1 out of 2 ways to load the csv file and load the pre-defined model into the instance.
cat.load_csv('[your_csv_file_path]', '[X_column_name]', '[Y_column_name]')
cat.load_model()

e.g.

cat.load_csv('product.csv', 'product name', 'category')
cat.load_model()

OR

cat.load_model('[your_csv_file_path]', '[X_column_name]', '[Y_column_name]')

e.g.

cat.load_model('product.csv', 'product name', 'category')

We can also specified how many LSTM layers you want by adding the corresponding parameter.

cat.load_model('product.csv', 'product name', 'category', num_of_LSTM = 4)

Then we just do one more easy step:

cat.train([number_of_iterations])

e.g.

cat.train(10)

If the number of iterations is not specified the number of iteration is 50. e.g.

cat.train() # 50 iterations

Save Weights

After training you can save your model on your local machine by using .save_weights([name]) method. (No file name suffix is needed)

cat.save_weights('my_model')

If the model is saved successfully we will see the folder appear in the same folder of your project

ProjectFolder
|---main.py
|---catmod.py
|---utils
|   |---...
|   |
|
|---my_model
|   |---...
|   |
|
...

Load Pre-Trained Model

When we have saved the training file, we can reuse it in the future by just loading it back to a new instance.
There are 2 ways of doing it.

The RECOMMENDED way:

from catmod import CatMod

new_cat = CatMod(load_mode = True, load_file = 'my_model')

The other way:

from catmod import CatMod

new_cat = CatMod(glove_file_path = [the_GloVe_file_path_but_it_must_have_the_same_dimension_with_the_pre_trained_model])

new_cat.load_weights('my_model')

Prediction

Prediction the the most easiest and provide many customization so that everyone can predict and export the predict result in .pd, .csv, .xlsx at their own need. e.g.

X = df['X']
new_cat.predict(X, to_csv = True)

The result will export out the csv file that have both column X and Y together.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cat_mod-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

cat_mod-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file cat_mod-0.1.0.tar.gz.

File metadata

  • Download URL: cat_mod-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for cat_mod-0.1.0.tar.gz
Algorithm Hash digest
SHA256 49844ac0bb05b34a40ba19b533cf4e8d9bd2650ee6b902c62d33504d4686aabe
MD5 c812ceed0e56d97937c05bc19821866b
BLAKE2b-256 26d2bc89bd4aa3bade5be7084e1d3c5f975e277395b70dcdd1b254bb09aadd42

See more details on using hashes here.

File details

Details for the file cat_mod-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cat_mod-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.5

File hashes

Hashes for cat_mod-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a1916d60eac32783ea899b89f6773943db24aaa661161434b45375b6b429aded
MD5 fd3677a219404b00529a2529a22740b6
BLAKE2b-256 62efd3632dba09ef9747016925f9aef94f6d86bbb7cde968deb1fdb5d22a4b4a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page