« first day (10 days earlier)      last day (110 days later) » 

5:45 PM
Hey
Sorry I am thinking I may not have done the mapping correctly, the weird thing is when I take a random comment and see what its associated value it seems the same as all the other ones i.e. `[("There isn't enough support to our site",
'Staff Not Onsite',
0.7323943661971831),
('I would like to have them on site more frequently',
'Staff Not Onsite',
0.6875),`
My guess is that I am doing something wrong here ```d = {}
a = []
for x, y in zip(df['comments'], df['negative_category']):
for z in unlabeled_df['comments']:
a.append((x, y, difflib.SequenceMatcher(None, x, z).ratio()))
d[z] = a```
 
Hi @justanewb
 
```
 
Can you please format the code while pasting?
 
I guess I should ask does it make sense what I am trying to do?
sure one moment
 
Just press CTRL + K
 
5:48 PM
d = {}
a = []
for x, y in zip(df['comments'], df['negative_category']):
    for z in unlabeled_df['comments']:
        a.append((x, y, difflib.SequenceMatcher(None, x, z).ratio()))
        d[z] = a
 
Just a sec let me check.
 
What I am trying to do here is that I am trying to find the similarity score between the comments in df and unlabeled_df. I then map the comment, the negative category, and similarity score. I want to provide the unlabeled_df a recommended negative category based on the top similarity scores between the comment in df and unlabeled_df
sure thanks
 
I guess you have revert the looping order:
Can you check:
d = {}
for z in unlabeled_df['comments']:
    a = []
    for x, y in zip(df['comments'], df['negative_category']):
        a.append((x, y, difflib.SequenceMatcher(None, x, z).ratio()))
    d[z] = a
 
sure one moment
That worked
thanks
but I just need to fix the way we are creating the new columns
each comment needs to have its associated top two tuples, does that make sense?
 
Not sure i understand..Can you explain a little more?
 
5:56 PM
Yea so we have this mapping where each comment in unlabeled_df has a associated tuple
I want to take the first two tuples for each comment and put that into new columns
am I making sense or is it still confusing?
 
I guess we are already doing that using np.hstack(v[:2])?
 
thats what I thought but for some reason there is alot of NaN
wait nvm
it works
accepting your answer
thanks for the help
 
great!
glad i could help :)
 
Do you know I rename the 0,1,... columns? Pandas seems to have a hard time with that
 
Just define a list of cols in sequence you want to name those columns.
For example:
cols = [] # list of your column names in sequence
df.join(pd.DataFrame(df['comments'].map(mapping).dropna().tolist(), columns=cols))
 
6:11 PM
perfect thanks
 

« first day (10 days earlier)      last day (110 days later) »