Skip to content

Commit 00e7b95

Browse files
committed
col_wrap
1 parent 67b4a56 commit 00e7b95

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

CompStats/interface.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,10 @@ def plot(self, value_name:str=None,
370370
value_name = 'Error'
371371
if not isinstance(self.statistic, dict):
372372
comparison = False
373+
best = self.best
374+
if isinstance(best, np.ndarray):
375+
if best.shape[0] < col_wrap:
376+
col_wrap = best.shape[0]
373377
df = self.dataframe(value_name=value_name, var_name=var_name,
374378
alg_legend=alg_legend, perf_names=perf_names,
375379
comparison=comparison, alpha=CI, right=right,

CompStats/tests/test_interface.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,30 @@
1717
from sklearn.svm import LinearSVC
1818
from sklearn.ensemble import RandomForestClassifier
1919
from sklearn.naive_bayes import GaussianNB
20-
from sklearn.datasets import load_iris, load_digits
20+
from sklearn.datasets import load_iris, load_digits, load_breast_cancer
2121
from sklearn.model_selection import train_test_split
2222
import pandas as pd
2323
from CompStats.tests.test_performance import DATA
2424

2525

26+
def test_Perf_plot_col_wrap():
27+
"""Test plot when 2 classes"""
28+
from CompStats.metrics import f1_score
29+
30+
X, y = load_breast_cancer(return_X_y=True)
31+
_ = train_test_split(X, y, test_size=0.3)
32+
X_train, X_val, y_train, y_val = _
33+
ens = RandomForestClassifier().fit(X_train, y_train)
34+
nb = GaussianNB().fit(X_train, y_train)
35+
svm = LinearSVC().fit(X_train, y_train)
36+
score = f1_score(y_val, ens.predict(X_val),
37+
average=None,
38+
num_samples=50)
39+
score(nb.predict(X_val))
40+
score(svm.predict(X_val))
41+
score.plot()
42+
43+
2644
def test_Difference_dataframe():
2745
"""Test Difference dataframe"""
2846
from CompStats.metrics import f1_score

0 commit comments

Comments
 (0)