小编cec*_*lia的帖子

在iPython Notebook中调用parse_args()时出现SystemExit:2错误

我正在学习使用Python和scikit-learn并执行以下代码块(最初来自http://scikit-learn.org/stable/auto_examples/document_classification_20newsgroups.html#example-document-classification-20newsgroups-py) iPython笔记本(使用Python 2.7):

from __future__ import print_function
from optparse import OptionParser

# parse commandline arguments
op = OptionParser()
op.add_option("--report",
              action="store_true", dest="print_report",
              help="Print a detailed classification report.")
op.add_option("--chi2_select",
              action="store", type="int", dest="select_chi2",
              help="Select some number of features using a chi-squared test")
op.add_option("--confusion_matrix",
              action="store_true", dest="print_cm",
              help="Print the confusion matrix.")
op.add_option("--top10",
              action="store_true", dest="print_top10",
              help="Print ten most discriminative terms per class"
                   " for every classifier.")
op.add_option("--all_categories",
              action="store_true", dest="all_categories",
              help="Whether to use all categories or not.")
op.add_option("--use_hashing",
              action="store_true",
              help="Use a hashing vectorizer.")
op.add_option("--n_features",
              action="store", …
Run Code Online (Sandbox Code Playgroud)

python optparse ipython-notebook

7
推荐指数
1
解决办法
4672
查看次数

标签 统计

ipython-notebook ×1

optparse ×1

python ×1