0
$\begingroup$

I need to build ML/NN model to classify/predict a given string pattern. Sample training data looks as shown in the image. Input will be the string in the column "Id Number", i need to tell to which class it belongs to in column "Id Type".

Sample Data Set

How do i move forward in building a model for text classification? How to convert string to digit for using embedding in keras?

$\endgroup$

1 Answer 1

2
$\begingroup$

From the sample you have here it is not obvious that you need to apply some fancy ML technics. A simple rule based approach might also give you great results. For instance:

  • if the string contains only numbers, then return B
  • If the string starts with 5 letters then return A
  • If the string starts with 2 letters and and then numbers return D Etc.

That being said, to transform your strings into numbers a simple approach -looking at your data- could consist in assigning to each character a value in the set {0,1,...,9,10,..35,36}, 0 being assigned to the value 0, 9 to the value 9, A to the value 10, Z to the value 35, and NULL to the value 36 (as your strings don't have the same size, it might come in handy to introduce some placeholder for the blank values so that all your final vectors get to be of the same size)

Hope this helps!

$\endgroup$
5
  • $\begingroup$ i have attached only a sample data. Just a rule based approach cannot be used. $\endgroup$
    – Harshith
    Nov 26, 2019 at 8:57
  • $\begingroup$ @ Jeanba, after assigning a unique number to each character, i should take that vector as an input data and build a model? $\endgroup$
    – Harshith
    Nov 26, 2019 at 8:58
  • $\begingroup$ Then still considering the outlook of your data, If I were you I would go first for a tree-based ML approach. It has the advantage to give results with much more interpretability and is easier to maintain. :-) $\endgroup$
    – Jeanba
    Nov 26, 2019 at 9:01
  • $\begingroup$ Just to be sure I was clear enough about the input vector: in the model stated above, "AAAAB1 " would become before normalisation: [10,10,10,10,11,1,36,36,36]. For each sample, there should be as much null values as required for your vectors to be all of the same size. $\endgroup$
    – Jeanba
    Nov 26, 2019 at 9:21
  • $\begingroup$ Thank you @ Jeanba $\endgroup$
    – Harshith
    Nov 26, 2019 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.