pandas, scikit-learn and xgboost integration
Project description
Overview
pandas, scikit-learn and xgboost integration.
Installation
$ pip install pandas_ml
Documentation
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.1.tar.gz
(76.6 kB
view details)
Built Distribution
pandas_ml-0.6.1-py3-none-any.whl
(100.3 kB
view details)
File details
Details for the file pandas_ml-0.6.1.tar.gz
.
File metadata
- Download URL: pandas_ml-0.6.1.tar.gz
- Upload date:
- Size: 76.6 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.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
f5d4f7c6eeada8e98856daace511cdc84995b593a3ae2741dcc4e665ec2918d3
|
|
MD5 |
02bd005d22954f682388621ea131b475
|
|
BLAKE2b-256 |
ac69f63b234546e39558e8121980daaf7389e52554a608da50005f52dc14f53f
|
File details
Details for the file pandas_ml-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: pandas_ml-0.6.1-py3-none-any.whl
- Upload date:
- Size: 100.3 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.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
89fb14c2c655170ac9dc42a29bd6ecdc085f0eaf1213c03149738c540d8a55f5
|
|
MD5 |
4108ef948e3651c34d3a878971c76940
|
|
BLAKE2b-256 |
ae726d90debfcb9ea74ec00927fa7ed0204dcc560b1f9ffcd8b239daa7fd106d
|