• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.names_demo函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nltk.classify.util.names_demo函数的典型用法代码示例。如果您正苦于以下问题:Python names_demo函数的具体用法?Python names_demo怎么用?Python names_demo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了names_demo函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: demo

def demo():
    from nltk.classify.util import names_demo, binary_names_demo_features

    classifier = names_demo(
        f, binary_names_demo_features  # DecisionTreeClassifier.train,
    )
    print(classifier.pp(depth=7))
    print(classifier.pseudocode(depth=7))
开发者ID:prz3m,项目名称:kind2anki,代码行数:8,代码来源:decisiontree.py


示例2: demo

def demo():
    from nltk.classify.util import names_demo
    classifier = names_demo(NaiveBayesClassifier.train)
    classifier.show_most_informative_features()
开发者ID:LowResourceLanguages,项目名称:hltdi-l3,代码行数:4,代码来源:naivebayes.py


示例3: isinstance

            labeled = tokens and isinstance(tokens[0], (tuple, list))
        if not labeled:
            tokens = [(tok, None) for tok in tokens]
    
        # Data section
        s = '\[email protected]\n'
        for (tok, label) in tokens:
            for fname, ftype in self._features:
                s += '%s,' % self._fmt_arff_val(tok.get(fname))
            s += '%s\n' % self._fmt_arff_val(label)
    
        return s

    def _fmt_arff_val(self, fval):
        if fval is None:
            return '?'
        elif isinstance(fval, (bool, int, long)):
            return '%s' % fval
        elif isinstance(fval, float):
            return '%r' % fval
        else:
            return '%r' % fval


if __name__ == '__main__':
    from nltk.classify.util import names_demo, binary_names_demo_features
    def make_classifier(featuresets):
        return WekaClassifier.train('/tmp/name.model', featuresets,
                                    'C4.5')
    classifier = names_demo(make_classifier, binary_names_demo_features)
开发者ID:B-Rich,项目名称:Fem-Coding-Challenge,代码行数:30,代码来源:weka.py


示例4: setup_module

# skip doctests if scikit-learn is not installed
def setup_module(module):
    from nose import SkipTest

    try:
        import sklearn
    except ImportError:
        raise SkipTest("scikit-learn is not installed")


if __name__ == "__main__":
    from nltk.classify.util import names_demo, names_demo_features
    from sklearn.linear_model import LogisticRegression
    from sklearn.naive_bayes import BernoulliNB

    # Bernoulli Naive Bayes is designed for binary classification. We set the
    # binarize option to False since we know we're passing boolean features.
    print("scikit-learn Naive Bayes:")
    names_demo(
        SklearnClassifier(BernoulliNB(binarize=False)).train,
        features=names_demo_features,
    )

    # The C parameter on logistic regression (MaxEnt) controls regularization.
    # The higher it's set, the less regularized the classifier is.
    print("\n\nscikit-learn logistic regression:")
    names_demo(
        SklearnClassifier(LogisticRegression(C=1000)).train,
        features=names_demo_features,
    )
开发者ID:prz3m,项目名称:kind2anki,代码行数:30,代码来源:scikitlearn.py


示例5: names_demo

def names_demo():
    from nltk.classify.util import names_demo
    from nltk.classify.maxent import TadmMaxentClassifier
    classifier = names_demo(TadmMaxentClassifier.train)
开发者ID:Weiming-Hu,项目名称:text-based-six-degree,代码行数:4,代码来源:tadm.py


示例6: print

    p = subprocess.Popen(cmd, stdout=sys.stdout)
    (stdout, stderr) = p.communicate()

    # Check the return code.
    if p.returncode != 0:
        print()
        print(stderr)
        raise OSError('tadm command failed!')

def names_demo():
    from nltk.classify.util import names_demo
    from nltk.classify.maxent import TadmMaxentClassifier
    classifier = names_demo(TadmMaxentClassifier.train)

def encoding_demo():
    import sys
    from nltk.classify.maxent import TadmEventMaxentFeatureEncoding
    tokens = [({'f0':1, 'f1':1, 'f3':1}, 'A'),
              ({'f0':1, 'f2':1, 'f4':1}, 'B'),
              ({'f0':2, 'f2':1, 'f3':1, 'f4':1}, 'A')]
    encoding = TadmEventMaxentFeatureEncoding.train(tokens)
    write_tadm_file(tokens, encoding, sys.stdout)
    print()
    for i in range(encoding.length()):
        print('%s --> %d' % (encoding.describe(i), i))
    print()

if __name__ == '__main__':
    encoding_demo()
    names_demo()
开发者ID:Weiming-Hu,项目名称:text-based-six-degree,代码行数:30,代码来源:tadm.py


示例7: _make_probdist

        return X

    def _make_probdist(self, y_proba):
        return DictionaryProbDist(dict((self._index_label[i], p)
                                       for i, p in enumerate(y_proba)))


# skip doctests if scikit-learn is not installed
def setup_module(module):
    from nose import SkipTest
    try:
        import sklearn
    except ImportError:
        raise SkipTest("scikit-learn is not installed")

if __name__ == "__main__":
    from nltk.classify.util import names_demo, binary_names_demo_features
    from sklearn.linear_model import LogisticRegression
    from sklearn.naive_bayes import BernoulliNB

    print("scikit-learn Naive Bayes:")
    # Bernoulli Naive Bayes is designed for binary classification. We set the
    # binarize option to False since we know we're passing binary features
    # (when binarize=False, scikit-learn does x>0 on the feature values x).
    names_demo(SklearnClassifier(BernoulliNB(binarize=False), dtype=bool).train,
               features=binary_names_demo_features)
    print("scikit-learn logistic regression:")
    names_demo(SklearnClassifier(LogisticRegression(), dtype=np.float64).train,
               features=binary_names_demo_features)
开发者ID:deanmalmgren,项目名称:nltk,代码行数:29,代码来源:scikitlearn.py


示例8: name_features

######################################################################
##
##  Guess an unseen name's gender!
##

from nltk.classify.naivebayes import NaiveBayesClassifier
from nltk.classify.util import names_demo

# Feature Extraction:
def name_features(name):
    features = {}
    return features

# Test the classifier:
classifier = names_demo(NaiveBayesClassifier.train, name_features)

# Feature Analysis:
#classifier.show_most_informative_features()
开发者ID:B-Rich,项目名称:nltk_book,代码行数:18,代码来源:names.py


示例9: demo

def demo():
    from nltk.classify.util import names_demo, binary_names_demo_features

    classifier = names_demo(DecisionTreeClassifier.train, binary_names_demo_features)
    print classifier.pp(depth=7)
开发者ID:aminorex,项目名称:icsisumm,代码行数:5,代码来源:decisiontree.py


示例10: demo

def demo():
	classifier = names_demo(f, binary_names_demo_features)
	#print (classifier.pp(depth=7))
	print (classifier.pseudocode(depth=7))
开发者ID:ericcquachh,项目名称:yelp_dataset_challenge,代码行数:4,代码来源:decision_tree.py


示例11: demo

def demo():
    from nltk.classify.util import names_demo
    print 'Generalized Iterative Scaling:'
    classifier = names_demo(train_maxent_classifier_with_gis)
    print 'Improved Iterative Scaling:'
    classifier = names_demo(train_maxent_classifier_with_iis)
开发者ID:DrDub,项目名称:icsisumm,代码行数:6,代码来源:maxent.py



注:本文中的nltk.classify.util.names_demo函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.VectorSpaceClusterer类代码示例发布时间:2022-05-27
下一篇:
Python util.accuracy函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap