Skip to content

ye-lun/skflow

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Scikit Flow

This is a simplified interface for TensorFlow, to get people started on predictive analytics and data mining.

Installation

First, make sure you have TensorFlow and Scikit Learn installed, then just run:

pip install git+git://github.com/google/skflow.git

Tutorial

Usage

Example usage:

Linear Classifier

Simple linear classification.

import skflow
from sklearn import datasets, metrics

iris = datasets.load_iris()
classifier = skflow.TensorFlowLinearClassifier(n_classes=3)
classifier.fit(iris.data, iris.target)
score = metrics.accuracy_score(classifier.predict(iris.data), iris.target)
print "Accuracy: ", score

Deep Neural Network

Example of 3 layer network with 10, 20 and 10 hidden units respectively:

import skflow
from sklearn import datasets, metrics

iris = datasets.load_iris()
classifier = skflow.TensorFlowDNNClassifier(hidden_units=[10, 20, 10], n_classes=3)
classifier.fit(iris.data, iris.target)
score = accuracy_score(classifier.predict(iris.data), iris.target)
print "Accuracy: ", score

Custom model

This is example of how to pass custom model to the TensorFlowEstimator

import skflow
from sklearn import datasets, metrics

iris = datasets.load_iris()

def my_model(X, y):
    """This is DNN with 10, 20, 10 hidden layers, and dropout of 0.5 probability."""
    layers = skflow.ops.dnn(X, [10, 20, 10], keep_prob=0.5)
    return skflow.ops.logistic_classifier(layers, y)

classifier = skflow.TensorFlowEstimator(model_fn=my_model, n_classes=3)
classifier.fit(iris.data, iris.target)
score = accuracy_score(classifier.predict(iris.data), iris.target)
print "Accuracy: ", score

Coming soon

  • Easy way to handle categorical variables
  • Text categorization
  • Images (CNNs)
  • More & deeper

About

Simplified interface for TensorFlow (mimicking Scikit Learn)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%