-
Notifications
You must be signed in to change notification settings - Fork 380
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to 'use' this model in our own project ? #56
Comments
I have used this code in a recent project on customer feedback. Here is what I did.
import pandas as pd
from encoder import Model
sentiment_model = Model()
data_df = pd.read_csv('/path/to/samples/') # all the feedback text was placed in a pandas data frame
samples = list(data_df['samples'])
text_features = sentiment_model.transform(samples)
sentiment_scores = text_features[:, 2388]
data_df['sentiment_scores'] = sentiment_scores
data_df.to_csv('/path/to/output_dir') Note that the code runs significantly faster on a GPU. |
@pgurazada I'm a total beginner to python and pandas trying to apply this code to my csv. If possible, would love any help whatsoever as to why I'm getting this error. I replaced '/path/to/samples/' with a file names 'samples.csv in the same directory
|
@pgurazada I should mention I also don't know how to convert csv to pandas dataframe |
Firstly, I understand where you are coming from. I am sure this link would help you grok pandas better - https://tomaugspurger.github.io/modern-1-intro.html |
@pgurazada
It seems to me this means the (variable?) 'model' hasn't been given a value? I'm not sure what value to give it though... |
I saw in someone else's example: https://github.com/ModelDepot/Sentiment-Neuron-Demonstration/blob/master/Sentiment_Neuron.ipynb that they defined So I also tried replacing
|
@massimosclaw Thank you for pointing the error on the sentiment_model out. I now corrected my original comment. Seems to me there is some error in the data types of your columns. The encoder is returning an error on iteration? Would you be able to check if there are any missing values? Also, any data sanity checks on whether the strings are all encoded properly would help. |
@pgurazada No prob! Unfortunately, I don't know how to check if there are any missing values (or what that means exactly... empty cells?) as well as data sanity checks on whether the strings are all encoded properly... don't know what that means either. Anything in particular I should search for to learn more about that? Will do some googling around with those terms... |
Found this... https://towardsdatascience.com/data-cleaning-with-python-and-pandas-detecting-missing-values-3e9c6ebcf78b - will read up on it. |
@pgurazada I finally managed to get it to work just by deleting all other columns which contained links, dates, times, and other data. Thank you so much again for the help. Wanted to ask one last question... how do you get the code to run on your GPU? As it takes a long time to run on my CPU. |
I am so sorry, missed this out for some reason. On a GPU predictions are about 10x faster. I was using the standard Colaboratory GPUs. |
could you kindly tell ,why you have taken ""sentiment_scores = text_features[:, 2388]"",2388 in text features.What is the use of it? |
@divyag11 Please check out the original paper from Open AI. This is the activation of the sentiment neuron. |
okay,thanks for your reply |
I can't find a way how to incorporate this model to my code? I just need to get sentiment scores on some Feedbacks. As this model is pre-trained, it will be of much help. How do i do this? Thanks!
The text was updated successfully, but these errors were encountered: