DOC Reorganize document classification example into subsections
@@ -11,9 +11,6 @@ efficiently handle sparse matrices.
The dataset used in this example is the 20 newsgroups dataset. It will be
automatically downloaded, then cached.
-The bar plot indicates the accuracy, training time (normalized) and test time
-(normalized) of each classifier.
-
"""
# Author: Peter Prettenhofer <peter.prettenhofer@gmail.com>
@@ -51,8 +48,6 @@ from sklearn import metrics
logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)s %(message)s')
-
-# parse commandline arguments
op = OptionParser()
op.add_option("--report",
action="store_true", dest="print_report",
@@ -99,7 +94,11 @@ print()
##############################################################################
-# Load some categories from the training set
+# Load data from the training set
+# ------------------------------------
+# Let's load data from the newsgroups dataset which comprises around 18000
+# newsgroups posts on 20 topics split in two subsets: one for training (or
+# development) and the other one for testing (or for performance evaluation).
if opts.all_categories:
categories = None
else:
@@ -202,6 +201,9 @@ def trim(s):
##############################################################################
# Benchmark classifiers
+# ------------------------------------
+# We train and test the datasets with 15 different classification models
+# and get performance results for each model.
def benchmark(clf):
print('_' * 80)
print("Training: ")
@@ -294,8 +296,12 @@ results.append(benchmark(Pipeline([
tol=1e-3))),
('classification', LinearSVC(penalty="l2"))])))
-# make some plots
+##############################################################################
+# Add plots
+# ------------------------------------
+# The bar plot indicates the accuracy, training time (normalized) and test time
+# (normalized) of each classifier.
indices = np.arange(len(results))
results = [[x[i] for x in results] for i in range(4)]
