Giter Site home page Giter Site logo

Comments (4)

Bidek56 avatar Bidek56 commented on June 15, 2024

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.

amaiya avatar amaiya commented on June 15, 2024

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.

fcasadome avatar fcasadome commented on June 15, 2024

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.

fcasadome avatar fcasadome commented on June 15, 2024

Works like a charm now!
Thank you very much again :)

from ktrain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.