位置:科技大田大数据产业专题>>资讯>>市场>>内容阅读
人工智能和数据科学的七大 Python 库
本文作者Favio Vázquez从2018年开始发布《数据科学和人工智能每周文摘:Python & R》系列文章,为数据科学家介绍最好的库、repos、packages以及工具。

本文作者Favio Vázquez从2018年开始发布《数据科学家介绍最好的库、repos、packages以及工具。

一年结束,作者列出了2018年的7大最好的Python库,这些库确实地改进了研究人员的工作方式。

=1.7.0"

从源代码安装

要从源代码进行安装,首先需要安装bazel。

下一步,复制adanet和cd到它的根目录:

$ git clone && cd adanet

从adanet根目录运行测试:

$ cd adanet $ bazel test -c opt //...

确认一切正常后,将adanet安装为pip包。

现在,可以对adanet进行试验了。

import adanet

用法

  • 14)
  • 15exported_pipeline.fit(training_features, training_classes)
  • 16results = exported_pipeline.predict(testing_features)
  • 就是这样。你已经以一种简单但强大的方式为Iris数据集构建一个分类器。

    现在我们来看看MNIST的数据集:

  • 1from tpot import TPOTClassifier
  • 2from sklearn.datasets import load_digits
  • 3from sklearn.model_selection import train_test_split
  • 4
  • 5# load and split dataset
  • 6digitsdigits == load_digitsload_di ()
  • 7X_train, X_test, y_train, y_test = train_test_split(digits.data, digits.target,
  • 8 train_size=0.75, test_size=0.25)
  • 9
  • 10# Fit the TPOT classifier
  • 11tpot = TPOTClassifier(verbosity=2, max_time_mins=5, population_size=40)
  • 12tpot.fit(X_train, y_train)
  • 13
  • 14# Export pipeline
  • 15tpot.export('tpot_mnist_pipeline.py')
  • 接下来我们再次加载生成的 .py文件,你将看到:

  • 1import numpy as np
  • 2from sklearn.model_selection import train_test_split
  • 3from sklearn.neighbors import KNeighborsClassifier
  • 4# NOTE: Make sure that the class is labeled 'class' in the data file
  • 5tpot_data = np.recfromcsv('PATH/TO/DATA/FILE', delimiter='COLUMN_SEPARATOR', dtype=np.float64)
  • 6features = np.delete(tpot_data.view(np.float64).reshape(tpot_data.size, -1), tpot_data.dtype.names.index('class'), axis=1)
  • 7training_features, testing_features, training_classes, testing_classes =
  • 8 train_test_split(features, tpot_data['class'], random_state=42)
  • 9exported_pipeline = KNeighborsClassifier(n_neighbors=4, p=2, weights="distance")
  • 10exported_pipeline.fit(training_features, training_classes)
  • 11results = exported_pipeline.predict(testing_features)
  • 5. SHAP ——一个解释任何机器模型输出的统一方法

  • df =op.load.url("
  • df
  • .rows.sort("product","desc")
  • .cols.lower(["firstName","lastName"])
  • .cols.date_transform("birth", "new_date", "yyyy/MM/dd", "dd-MM-YYYY")
  • .cols.years_between("birth", "years_between", "yyyy/MM/dd")
  • .cols.remove_accents("lastName")
  • .cols.remove_special_chars("lastName")
  • .cols.replace("product","taaaccoo","taco")
  • .cols.replace("product",["piza","pizzza"],"pizza")
  • .rows.drop(df["id"]7)
  • .cols.drop("dummyCol")
  • .cols.rename(str.lower)
  • .cols.apply_by_dtypes("product",func,"string", data_type="integer")
  • .cols.trim("*")
  • .show()
  • 你可以将这个表格

  • u"Google in 2007, few people outside of the company took him "
  • u"seriously. “I can tell you very senior CEOs of major American "
  • u"car companies would shake my hand and turn away because I wasn’t "
  • u"worth talking to,” said Thrun, now the co-founder and CEO of "
  • u"online higher education startup Udacity, in an interview with "
  • u"Recode earlier this week.")
  • doc = nlp(text)
  • # Find named entities, phrases and concepts
  • for entity in doc.ents:
  • print(entity.text, entity.label_)
  • # Determine semantic similarities
  • doc1 = nlp(u"my fries were super gross")
  • doc2 = nlp(u"such disgusting fries")
  • similarity = doc1.similarity(doc2)
  • print(doc1.text, doc2.text, similarity)
  • 在这个示例中,我们首先下载English tokenizer, tagger, parser, NER和word vectors。然后创建一些文本,打印找到的实体、短语和概念,最后确定两个短语的语义相似性。运行这段代码,你会得到:

  • Sebastian Thrun PERSON
  • Google ORG
  • 2007 DATE
  • American NORP
  • Thrun PERSON
  • Recode ORG
  • earlier this week DATE
  • my fries were super gross such disgusting fries 0.7139701635071919
  • 2. jupytext

    重启Jupyter,即运行:

  • jupyter notebook
  • 你可以在这里试试:

    1.Chartify ——让数据科学家很容易创建图表的Python库

  • ch.set_subtitle("Represent changes in distribution.")
  • ch.plot.area(
  • data_frame=total_quantity_by_month_and_fruit,
  • x_column='month',
  • y_column='quantity',
  • color_column='fruit',
  • stacked=True)
  • ch.show('png')
  • 超级容易创建一个互动的plot。

    更多示例:

    免责声明:本网站部 分文章和信息来源于互联网,本网转载出于传递更多信息和学习之目的,并不意味着赞同其观点或证实其内容的真实性。如转载稿涉及版权等问题,请立即联系管理 员,我们会予以更改或删除相关文章,保证您的权利。对使用本网站信息和服务所引起的后果,本网站不作任何承诺。

    Copyright 版权所有 Copyright 2013-2014 福建省云创集成科技服务有限公司
    All Rights Reserved. 运营维护:三明市明网网络信息技术有限公司 业务咨询:0598-8233595 0598-5831286 技术咨询:0598-8915168