Comments (4)
I believe you need to create 2 columns in your DF: ['postive', 'negative'] and set them to 0 or 1,
df['postive'] = df['labels'].apply(lambda x: 1 if x == 1 else 0)
df['negative'] = df['labels'].apply(lambda x: 1 if x == 0 else 0)
then call:
(x_train, y_train), (x_test, y_test), preproc = text.texts_from_df(
train_df=df, text_column='Source_NOFT', label_columns=['postive', 'negative'], max_features=MAX_FEATURES,
maxlen=MAX_LENGTH, ngram_range=3, preprocess_mode='standard')
then call:
predictor.predict(data)
from ktrain.
Thank you, @Bidek56
Yes, the labels are expected to be 1-hot-encoded. I have corrected the docstring for texts_from_csv
and texts_from_df
to make this clear.
In addition to @Bidek56 's answer, see also this example notebook for converting integer labels in a Pandas dataframe to be 1-hot-encoded.
from ktrain.
Thank you very much for your quick responses @Bidek56 and @amaiya!
That makes sense I guess, I'm going to try right away
from ktrain.
Works like a charm now!
Thank you very much again :)
from ktrain.
Related Issues (20)
- Bug with ktrain.text.translation HOT 7
- texts_from_df throws error AttributeError: 'NoneType' object has no attribute 'utils' HOT 2
- The initializer GlorotNormal is unseeded and being called multiple times, which will return identical values each time (even if the initializer is unseeded). HOT 3
- switch to textract-py3 HOT 1
- switch from chardet to charset-normalizer
- Unable to reload predictor : `model.compile` was created inside a different distribution strategy scope than the model HOT 1
- Is there a method to convert ktrain predictor to onnx model (optimized and quantized) without using transformers PyTorch dependencies HOT 2
- Any plans for supporting python 3.11? HOT 1
- Load model without training. HOT 1
- Ktrain on colab not working HOT 1
- predictor.explain() not working with inputs of type "$()" HOT 2
- Saved checkpoints not titled with descriptive information HOT 1
- Memory leak when using predict_filename in lambda function HOT 3
- Memory Leak with predictor.predict_proba in ktrain HOT 2
- remove `text.qa.generative_qa` module
- Could not interpret optimizer identifier HOT 5
- Overfitting Issue HOT 1
- Import ktrain default error HOT 1
- Image generator for only validation set? HOT 1
- Training resnets on a loop results in loss plots with multiple lines HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ktrain.