Permalink
Browse files

adds missing examples

  • Loading branch information...
edublancas committed Nov 12, 2016
1 parent 092f725 commit 1368efccd7aa1861410383c78a9bce3a7295a809
View
@@ -7,8 +7,7 @@ sklearn_evaluation/tests/*.html
# Do not include docs build folder
docs/build/
# Do not include examples produced using ..plot::
docs/examples/*.png
docs/examples/*.pdf
docs/examples/
#####=== IPythonNotebook ===#####
# Temporary data

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,22 @@
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import train_test_split
from sklearn_evaluation import plot
data = datasets.make_classification(200, 10, 5, class_sep=0.65)
X = data[0]
y = data[1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
est = RandomForestClassifier()
est.fit(X_train, y_train)
y_pred = est.predict(X_test)
y_score = est.predict_proba(X_test)
y_true = y_test
plot.confusion_matrix(y_true, y_pred)
plt.show()
@@ -0,0 +1,18 @@
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import train_test_split
from sklearn_evaluation import plot
data = datasets.make_classification(200, 10, 5, class_sep=0.65)
X = data[0]
y = data[1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
est = RandomForestClassifier()
est.fit(X_train, y_train)
plot.feature_importances(est, top_n=5)
plt.show()
@@ -0,0 +1,21 @@
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import train_test_split
from sklearn_evaluation import plot
data = datasets.make_classification(200, 10, 5, class_sep=0.65)
X = data[0]
y = data[1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
est = RandomForestClassifier()
est.fit(X_train, y_train)
y_pred = est.predict(X_test)
y_score = est.predict_proba(X_test)
y_true = y_test
plot.precision_recall(y_true, y_score)
View
@@ -0,0 +1,21 @@
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.ensemble import RandomForestClassifier
from sklearn.cross_validation import train_test_split
from sklearn_evaluation import plot
data = datasets.make_classification(200, 10, 5, class_sep=0.65)
X = data[0]
y = data[1]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
est = RandomForestClassifier()
est.fit(X_train, y_train)
y_pred = est.predict(X_test)
y_score = est.predict_proba(X_test)
y_true = y_test
plot.roc(y_true, y_score)
@@ -38,6 +38,10 @@ def confusion_matrix(y_true, y_pred, target_names=None, normalize=False,
ax: matplotlib Axes
Axes containing the plot
Examples
--------
.. plot:: ../../examples/confusion_matrix.py
"""
# calculate how many names you expect
values = set(y_true).union(set(y_pred))
@@ -125,6 +129,10 @@ def feature_importances(data, top_n=None, feature_names=None, ax=None):
ax: matplotlib Axes
Axes containing the plot
Examples
--------
.. plot:: ../../examples/feature_importances.py
"""
# If no feature_names is provided, assign numbers
res = compute.feature_importances(data, top_n, feature_names)
@@ -33,6 +33,10 @@ def precision_recall(y_true, y_score, ax=None):
ax: matplotlib Axes
Axes containing the plot
Examples
--------
.. plot:: ../../examples/precision_recall.py
"""
if ax is None:
ax = plt.gca()
@@ -33,6 +33,10 @@ def roc(y_true, y_score, ax=None):
ax: matplotlib Axes
Axes containing the plot
Examples
--------
.. plot:: ../../examples/roc.py
"""
if ax is None:
ax = plt.gca()

0 comments on commit 1368efc

Please sign in to comment.