Skip to main content

pandas, scikit-learn and xgboost integration

Project description

https://img.shields.io/pypi/v/pandas_ml.svg Latest Docs https://travis-ci.org/pandas-ml/pandas-ml.svg?branch=master https://coveralls.io/repos/pandas-ml/pandas-ml/badge.svg?branch=master&service=github

Overview

pandas, scikit-learn and xgboost integration.

Installation

$ pip install pandas_ml

Documentation

http://pandas-ml.readthedocs.org/en/stable/

Example

>>> import pandas_ml as pdml
>>> import sklearn.datasets as datasets

# create ModelFrame instance from sklearn.datasets
>>> df = pdml.ModelFrame(datasets.load_digits())
>>> type(df)
<class 'pandas_ml.core.frame.ModelFrame'>

# binarize data (features), not touching target
>>> df.data = df.data.preprocessing.binarize()
>>> df.head()
   .target  0  1  2  3  4  5  6  7  8 ...  54  55  56  57  58  59  60  61  62  63
0        0  0  0  1  1  1  1  0  0  0 ...   0   0   0   0   1   1   1   0   0   0
1        1  0  0  0  1  1  1  0  0  0 ...   0   0   0   0   0   1   1   1   0   0
2        2  0  0  0  1  1  1  0  0  0 ...   1   0   0   0   0   1   1   1   1   0
3        3  0  0  1  1  1  1  0  0  0 ...   1   0   0   0   1   1   1   1   0   0
4        4  0  0  0  1  1  0  0  0  0 ...   0   0   0   0   0   1   1   1   0   0
[5 rows x 65 columns]

# split to training and test data
>>> train_df, test_df = df.model_selection.train_test_split()

# create estimator (accessor is mapped to sklearn namespace)
>>> estimator = df.svm.LinearSVC()

# fit to training data
>>> train_df.fit(estimator)

# predict test data
>>> test_df.predict(estimator)
0     4
1     2
2     7
...
448    5
449    8
Length: 450, dtype: int64

# Evaluate the result
>>> test_df.metrics.confusion_matrix()
Predicted   0   1   2   3   4   5   6   7   8   9
Target
0          52   0   0   0   0   0   0   0   0   0
1           0  37   1   0   0   1   0   0   3   3
2           0   2  48   1   0   0   0   1   1   0
3           1   1   0  44   0   1   0   0   3   1
4           1   0   0   0  43   0   1   0   0   0
5           0   1   0   0   0  39   0   0   0   0
6           0   1   0   0   1   0  35   0   0   0
7           0   0   0   0   2   0   0  42   1   0
8           0   2   1   0   1   0   0   0  33   1
9           0   2   1   2   0   0   0   0   1  38

Supported Packages

  • scikit-learn

  • patsy

  • xgboost

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pandas_ml-0.6.0.tar.gz (76.8 kB view details)

Uploaded Source

Built Distributions

pandas_ml-0.6.0-py3.6.egg (256.2 kB view details)

Uploaded Egg

pandas_ml-0.6.0-py3-none-any.whl (102.9 kB view details)

Uploaded Python 3

File details

Details for the file pandas_ml-0.6.0.tar.gz.

File metadata

  • Download URL: pandas_ml-0.6.0.tar.gz
  • Upload date:
  • Size: 76.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.7

File hashes

Hashes for pandas_ml-0.6.0.tar.gz
Algorithm Hash digest
SHA256 43e54b1a6d17ef76c7c7bc64ac2a2a9ef4060e57b920e81a81895897e2cd9125
MD5 68f0a19a0110e1a0bbb27d6010e6e712
BLAKE2b-256 af7ed7f73fa543c4b922f31e05c4625cce552ed4b19a8bc87407f7e75076452c

See more details on using hashes here.

File details

Details for the file pandas_ml-0.6.0-py3.6.egg.

File metadata

  • Download URL: pandas_ml-0.6.0-py3.6.egg
  • Upload date:
  • Size: 256.2 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.7

File hashes

Hashes for pandas_ml-0.6.0-py3.6.egg
Algorithm Hash digest
SHA256 c0dfb7979d8eabf7278a563c33042c97a2e6a9dbfbb4a828a261aa52551d0e91
MD5 9f19aada1ec5dbb7b0f03b0521e7f603
BLAKE2b-256 706482eb29e829008f12ddbf08752a6615ef4400b3744f68258b03841b356b06

See more details on using hashes here.

File details

Details for the file pandas_ml-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: pandas_ml-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 102.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.7

File hashes

Hashes for pandas_ml-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a22251d3c170afd5327783ccb86ce033c810180a4a6e03c1e63e6de2cc884bb5
MD5 60f1f589bc38970cb50e94fe1405a2e0
BLAKE2b-256 8ccdefa2c3c4ab89c03184e96692c7e288c8272b08614b52786cbadb3c7b50aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page