I would need to better understand how can be created a machine learning algorithm from scratch using an own model developed based on boolean values, for example # of words in a text, # of punctuation, # of capital letters, and so on, to determine if a text is formal or informal. For instance: I have
Text
there is a new major in this town
WTF?!?
you're a great person. Really glad to have met you
I don't know what to say
BYE BYE BABY
I created some rules to assign a label on this (small) train dataset, but I would need to understand how to apply these rules to a new dataset (test):
- if there is an upper case word then I;
- if there is a short expression, like don't, 'm ,'s, ... , then I;
- if there are two symbols (punctuation) close to each other, then I;
- if a word is in list of extra words, then I;
- otherwise F.
Suppose that I have a dataframe to test and to assign these labels (I or F):
FREEDOM!!! I don't need to go to school anymore
What are u thinking?
Hey men!
I am glad to hear that.
how could I apply my model to this new dataset, adding labels?
Test Output
FREEDOM!!! I don't need to go to school anymore I
What are u thinking? I
Hey men! I
I am glad to hear that. F
Update after mnm's comment:
Would it be considered a machine learning problem the following one?
import pandas as pd
import numpy as np
data = { "ID":[1,2,3,4],
"Text":["FREEDOM!!! I don't need to go to school anymore",
"What are u thinking?",
"Hey men!","
I am glad to hear that."]}
# here there should be the part of modelling
df['upper'] = # if there is an upper case word then "I"
df['short_exp'] = # if there is a short exp then "I"
df['two_cons'] = # if there are two consecutive symbols then "I"
list_extra=['u','hey']
df['extra'] = # if row contains at least one of the word included in list_extra then 'I'
# append cols to original dataframe
df_new = df
df_new['upper'] = df1['upper']
df_new['short_exp'] = df1['short_exp']
# and similar for others
It is not clear, however, the latest part, that one based on condition. How can I predict the new values for the other texts?