<jupyter_start><jupyter_text>Load data<jupyter_code>movie_reviews_data_folder = "data/movie_reviews/txt_sentoken/"
dataset = load_files(movie_reviews_data_folder, shuffle=False)
print("n_samples: %d" % len(dataset.data))

# split the dataset in training and test set:
docs_train, docs_test, y_train, y_test = train_test_split(
    dataset.data, dataset.target, test_size=0.25, random_state=None)
text_clf = Pipeline([('vect', TfidfVectorizer(min_df=3, max_df=0.95)),
                     ('clf', LinearSVC())])
text_clf.fit(docs_train, y_train)
test_classifier(text_clf)
parameters = {'vect__ngram_range': [(1, 1), (1, 2)],
              'vect__use_idf': (True, False)}
gs_clf = GridSearchCV(text_clf, parameters)
gs_clf = gs_clf.fit(docs_train, y_train)
for param_name in sorted(parameters.keys()):
    print("%s: %r" % (param_name, gs_clf.best_params_[param_name]))
text_clf = Pipeline([('vect', TfidfVectorizer(ngram_range=(1, 2),
                                              use_idf=True,
                                              min_df=3, max_df=0.95)),
                     ('clf', LinearSVC())])
text_clf.fit(docs_train, y_train)
test_classifier(text_clf)<jupyter_output>precision    recall  f1-score   support

        neg       0.88      0.86      0.87       263
        pos       0.85      0.87      0.86       237

avg / total       0.87      0.87      0.87       500
{'fraction_non_alphanumeric': 0.12572254335260116, 'fraction_numerical': 0.03901734104046243, 'mean_word_length': 2.71313672922252, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '139623', 'license': 'MIT', 'n_tokens_mistral': 530, 'n_tokens_neox': 494, 'n_words': 89, 'path': 'Sentiment analysis.ipynb', 'repo_name': 'heolin123/text_analysis', 'size': '1384'}