Ejemplo n.º 1
0
def tf_idf_multi_nb():
    features = FeatureUnion(
        [("tfidf",
          make_pipeline(ColumnSelector(TEXT),
                        TfidfVectorizer(stop_words='english'))),
         ("sentiment", ColumnSelector(['pos', 'neu', 'neg']))],
        n_jobs=-1)
    return make_pipeline(features, MultinomialNB())
Ejemplo n.º 2
0
def tf_idf_senti_xgboost():
    features = FeatureUnion(
        [("tfidf",
          make_pipeline(ColumnSelector(TEXT),
                        TfidfVectorizer(stop_words='english'))),
         ("sentiment", ColumnSelector(['pos', 'neu', 'neg']))],
        n_jobs=-1)
    return make_pipeline(
        features, xgb.XGBClassifier(random_state=1234, learning_rate=0.01))
Ejemplo n.º 3
0
def tf_idf_logistic_senti():
    features = FeatureUnion(
        [("tfidf",
          make_pipeline(ColumnSelector(TEXT),
                        TfidfVectorizer(stop_words='english'))),
         ("sentiment", ColumnSelector(['pos', 'neu', 'neg'])),
         ("hate_model", ColumnSelector(['hate_model']))],
        n_jobs=-1)
    return make_pipeline(
        features,
        LogisticRegression(class_weight='balanced', n_jobs=-1, max_iter=2000))
Ejemplo n.º 4
0
def bow_svm():
    features = FeatureUnion(
        [("bow",
          make_pipeline(ColumnSelector(TEXT),
                        CountVectorizer(stop_words='english')))],
        n_jobs=-1)

    return make_pipeline(features, LinearSVC(class_weight='balanced'))
Ejemplo n.º 5
0
def bow_logistic():
    features = FeatureUnion(
        [("bow",
          make_pipeline(ColumnSelector(TEXT),
                        CountVectorizer(stop_words='english')))],
        n_jobs=-1)

    return make_pipeline(
        features,
        LogisticRegression(class_weight='balanced', n_jobs=-1, max_iter=2000))
Ejemplo n.º 6
0
def use_random_forest():
    return make_pipeline(
        ColumnSelector(TEXT), USEEncoder(),
        RandomForestClassifier(n_estimators=10,
                               random_state=1234,
                               class_weight='balanced'))
Ejemplo n.º 7
0
def use_svm_pipeline():
    return make_pipeline(ColumnSelector(TEXT), USEEncoder(),
                         LinearSVC(class_weight='balanced'))
Ejemplo n.º 8
0
def tf_idf_logistic():
    return make_pipeline(
        ColumnSelector(TEXT), TfidfVectorizer(stop_words='english'),
        LogisticRegression(class_weight='balanced', n_jobs=-1, max_iter=2000))
Ejemplo n.º 9
0
def tf_idf_svm_pipeline():
    return make_pipeline(ColumnSelector(TEXT),
                         TfidfVectorizer(stop_words='english'),
                         LinearSVC(class_weight='balanced', max_iter=2000))
Ejemplo n.º 10
0
def use_logistic():
    return make_pipeline(
        ColumnSelector(TEXT), USEEncoder(),
        LogisticRegression(class_weight='balanced', max_iter=2000))