Mercurial > repos > bgruening > sklearn_searchcv
annotate iraps_classifier.py @ 8:1c4a241bef5c draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
| author | bgruening | 
|---|---|
| date | Tue, 14 May 2019 18:05:43 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 8 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 1 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 2 class IRAPSCore | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 3 class IRAPSClassifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 4 class BinarizeTargetClassifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 5 class BinarizeTargetRegressor | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 6 class _BinarizeTargetScorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 7 class _BinarizeTargetProbaScorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 8 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 9 binarize_auc_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 10 binarize_average_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 11 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 12 binarize_accuracy_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 13 binarize_balanced_accuracy_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 14 binarize_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 15 binarize_recall_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 16 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 17 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 18 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 19 import numpy as np | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 20 import random | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 21 import warnings | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 22 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 23 from abc import ABCMeta | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 24 from scipy.stats import ttest_ind | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 25 from sklearn import metrics | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 26 from sklearn.base import BaseEstimator, clone, RegressorMixin | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 27 from sklearn.externals import six | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 28 from sklearn.feature_selection.univariate_selection import _BaseFilter | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 29 from sklearn.metrics.scorer import _BaseScorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 30 from sklearn.pipeline import Pipeline | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 31 from sklearn.utils import as_float_array, check_X_y | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 32 from sklearn.utils._joblib import Parallel, delayed | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 33 from sklearn.utils.validation import (check_array, check_is_fitted, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 34 check_memory, column_or_1d) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 35 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 36 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 37 VERSION = '0.1.1' | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 38 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 39 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 40 class IRAPSCore(six.with_metaclass(ABCMeta, BaseEstimator)): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 41 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 42 Base class of IRAPSClassifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 43 From sklearn BaseEstimator: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 44 get_params() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 45 set_params() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 46 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 47 Parameters | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 48 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 49 n_iter : int | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 50 sample count | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 51 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 52 positive_thres : float | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 53 z_score shreshold to discretize positive target values | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 54 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 55 negative_thres : float | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 56 z_score threshold to discretize negative target values | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 57 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 58 verbose : int | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 59 0 or geater, if not 0, print progress | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 60 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 61 n_jobs : int, default=1 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 62 The number of CPUs to use to do the computation. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 63 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 64 pre_dispatch : int, or string. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 65 Controls the number of jobs that get dispatched during parallel | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 66 execution. Reducing this number can be useful to avoid an | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 67 explosion of memory consumption when more jobs get dispatched | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 68 than CPUs can process. This parameter can be: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 69 - None, in which case all the jobs are immediately | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 70 created and spawned. Use this for lightweight and | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 71 fast-running jobs, to avoid delays due to on-demand | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 72 spawning of the jobs | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 73 - An int, giving the exact number of total jobs that are | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 74 spawned | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 75 - A string, giving an expression as a function of n_jobs, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 76 as in '2*n_jobs' | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 77 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 78 random_state : int or None | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 79 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 80 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 81 def __init__(self, n_iter=1000, positive_thres=-1, negative_thres=0, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 82 verbose=0, n_jobs=1, pre_dispatch='2*n_jobs', | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 83 random_state=None): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 84 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 85 IRAPS turns towwards general Anomaly Detection | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 86 It comapares positive_thres with negative_thres, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 87 and decide which portion is the positive target. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 88 e.g.: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 89 (positive_thres=-1, negative_thres=0) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 90 => positive = Z_score of target < -1 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 91 (positive_thres=1, negative_thres=0) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 92 => positive = Z_score of target > 1 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 93 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 94 Note: The positive targets here is always the | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 95 abnormal minority group. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 96 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 97 self.n_iter = n_iter | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 98 self.positive_thres = positive_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 99 self.negative_thres = negative_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 100 self.verbose = verbose | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 101 self.n_jobs = n_jobs | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 102 self.pre_dispatch = pre_dispatch | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 103 self.random_state = random_state | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 104 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 105 def fit(self, X, y): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 106 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 107 X: array-like (n_samples x n_features) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 108 y: 1-d array-like (n_samples) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 109 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 110 X, y = check_X_y(X, y, ['csr', 'csc'], multi_output=False) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 111 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 112 def _stochastic_sampling(X, y, random_state=None, positive_thres=-1, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 113 negative_thres=0): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 114 # each iteration select a random number of random subset of | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 115 # training samples. this is somewhat different from the original | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 116 # IRAPS method, but effect is almost the same. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 117 SAMPLE_SIZE = [0.25, 0.75] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 118 n_samples = X.shape[0] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 119 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 120 if random_state is None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 121 n_select = random.randint(int(n_samples * SAMPLE_SIZE[0]), | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 122 int(n_samples * SAMPLE_SIZE[1])) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 123 index = random.sample(list(range(n_samples)), n_select) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 124 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 125 n_select = random.Random(random_state).randint( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 126 int(n_samples * SAMPLE_SIZE[0]), | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 127 int(n_samples * SAMPLE_SIZE[1])) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 128 index = random.Random(random_state).sample( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 129 list(range(n_samples)), n_select) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 130 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 131 X_selected, y_selected = X[index], y[index] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 132 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 133 # Spliting by z_scores. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 134 y_selected = (y_selected - y_selected.mean()) / y_selected.std() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 135 if positive_thres < negative_thres: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 136 X_selected_positive = X_selected[y_selected < positive_thres] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 137 X_selected_negative = X_selected[y_selected > negative_thres] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 138 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 139 X_selected_positive = X_selected[y_selected > positive_thres] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 140 X_selected_negative = X_selected[y_selected < negative_thres] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 141 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 142 # For every iteration, at least 5 responders are selected | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 143 if X_selected_positive.shape[0] < 5: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 144 warnings.warn("Warning: fewer than 5 positives were selected!") | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 145 return | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 146 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 147 # p_values | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 148 _, p = ttest_ind(X_selected_positive, X_selected_negative, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 149 axis=0, equal_var=False) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 150 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 151 # fold_change == mean change? | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 152 # TODO implement other normalization method | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 153 positive_mean = X_selected_positive.mean(axis=0) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 154 negative_mean = X_selected_negative.mean(axis=0) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 155 mean_change = positive_mean - negative_mean | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 156 # mean_change = np.select( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 157 # [positive_mean > negative_mean, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 158 # positive_mean < negative_mean], | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 159 # [positive_mean / negative_mean, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 160 # -negative_mean / positive_mean]) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 161 # mean_change could be adjusted by power of 2 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 162 # mean_change = 2**mean_change \ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 163 # if mean_change>0 else -2**abs(mean_change) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 164 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 165 return p, mean_change, negative_mean | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 166 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 167 parallel = Parallel(n_jobs=self.n_jobs, verbose=self.verbose, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 168 pre_dispatch=self.pre_dispatch) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 169 if self.random_state is None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 170 res = parallel(delayed(_stochastic_sampling)( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 171 X, y, random_state=None, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 172 positive_thres=self.positive_thres, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 173 negative_thres=self.negative_thres) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 174 for i in range(self.n_iter)) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 175 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 176 res = parallel(delayed(_stochastic_sampling)( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 177 X, y, random_state=seed, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 178 positive_thres=self.positive_thres, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 179 negative_thres=self.negative_thres) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 180 for seed in range(self.random_state, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 181 self.random_state+self.n_iter)) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 182 res = [_ for _ in res if _] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 183 if len(res) < 50: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 184 raise ValueError("too few (%d) valid feature lists " | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 185 "were generated!" % len(res)) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 186 pvalues = np.vstack([x[0] for x in res]) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 187 fold_changes = np.vstack([x[1] for x in res]) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 188 base_values = np.vstack([x[2] for x in res]) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 189 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 190 self.pvalues_ = np.asarray(pvalues) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 191 self.fold_changes_ = np.asarray(fold_changes) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 192 self.base_values_ = np.asarray(base_values) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 193 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 194 return self | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 195 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 196 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 197 def _iraps_core_fit(iraps_core, X, y): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 198 return iraps_core.fit(X, y) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 199 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 200 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 201 class IRAPSClassifier(six.with_metaclass(ABCMeta, _BaseFilter, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 202 BaseEstimator, RegressorMixin)): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 203 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 204 Extend the bases of both sklearn feature_selector and classifier. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 205 From sklearn BaseEstimator: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 206 get_params() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 207 set_params() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 208 From sklearn _BaseFilter: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 209 get_support() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 210 fit_transform(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 211 transform(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 212 From sklearn RegressorMixin: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 213 score(X, y): R2 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 214 New: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 215 predict(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 216 predict_label(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 217 get_signature() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 218 Properties: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 219 discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 220 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 221 Parameters | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 222 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 223 iraps_core: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 224 p_thres: float, threshold for p_values | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 225 fc_thres: float, threshold for fold change or mean difference | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 226 occurrence: float, occurrence rate selected by set of p_thres and fc_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 227 discretize: float, threshold of z_score to discretize target value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 228 memory: None, str or joblib.Memory object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 229 min_signature_features: int, the mininum number of features in a signature | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 230 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 231 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 232 def __init__(self, iraps_core, p_thres=1e-4, fc_thres=0.1, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 233 occurrence=0.8, discretize=-1, memory=None, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 234 min_signature_features=1): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 235 self.iraps_core = iraps_core | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 236 self.p_thres = p_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 237 self.fc_thres = fc_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 238 self.occurrence = occurrence | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 239 self.discretize = discretize | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 240 self.memory = memory | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 241 self.min_signature_features = min_signature_features | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 242 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 243 def fit(self, X, y): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 244 memory = check_memory(self.memory) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 245 cached_fit = memory.cache(_iraps_core_fit) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 246 iraps_core = clone(self.iraps_core) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 247 # allow pre-fitted iraps_core here | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 248 if not hasattr(iraps_core, 'pvalues_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 249 iraps_core = cached_fit(iraps_core, X, y) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 250 self.iraps_core_ = iraps_core | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 251 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 252 pvalues = as_float_array(iraps_core.pvalues_, copy=True) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 253 # why np.nan is here? | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 254 pvalues[np.isnan(pvalues)] = np.finfo(pvalues.dtype).max | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 255 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 256 fold_changes = as_float_array(iraps_core.fold_changes_, copy=True) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 257 fold_changes[np.isnan(fold_changes)] = 0.0 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 258 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 259 base_values = as_float_array(iraps_core.base_values_, copy=True) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 260 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 261 p_thres = self.p_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 262 fc_thres = self.fc_thres | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 263 occurrence = self.occurrence | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 264 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 265 mask_0 = np.zeros(pvalues.shape, dtype=np.int32) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 266 # mark p_values less than the threashold | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 267 mask_0[pvalues <= p_thres] = 1 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 268 # mark fold_changes only when greater than the threashold | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 269 mask_0[abs(fold_changes) < fc_thres] = 0 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 270 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 271 # count the occurrence and mask greater than the threshold | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 272 counts = mask_0.sum(axis=0) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 273 occurrence_thres = int(occurrence * iraps_core.n_iter) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 274 mask = np.zeros(counts.shape, dtype=bool) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 275 mask[counts >= occurrence_thres] = 1 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 276 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 277 # generate signature | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 278 fold_changes[mask_0 == 0] = 0.0 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 279 signature = fold_changes[:, mask].sum(axis=0) / counts[mask] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 280 signature = np.vstack((signature, base_values[:, mask].mean(axis=0))) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 281 # It's not clearn whether min_size could impact prediction | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 282 # performance | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 283 if signature is None\ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 284 or signature.shape[1] < self.min_signature_features: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 285 raise ValueError("The classifier got None signature or the number " | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 286 "of sinature feature is less than minimum!") | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 287 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 288 self.signature_ = np.asarray(signature) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 289 self.mask_ = mask | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 290 # TODO: support other discretize method: fixed value, upper | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 291 # third quater, etc. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 292 self.discretize_value = y.mean() + y.std() * self.discretize | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 293 if iraps_core.negative_thres > iraps_core.positive_thres: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 294 self.less_is_positive = True | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 295 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 296 self.less_is_positive = False | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 297 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 298 return self | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 299 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 300 def _get_support_mask(self): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 301 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 302 return mask of feature selection indices | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 303 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 304 check_is_fitted(self, 'mask_') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 305 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 306 return self.mask_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 307 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 308 def get_signature(self): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 309 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 310 return signature | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 311 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 312 check_is_fitted(self, 'signature_') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 313 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 314 return self.signature_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 315 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 316 def predict(self, X): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 317 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 318 compute the correlation coefficient with irpas signature | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 319 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 320 signature = self.get_signature() | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 321 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 322 X = as_float_array(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 323 X_transformed = self.transform(X) - signature[1] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 324 corrcoef = np.array( | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 325 [np.corrcoef(signature[0], e)[0][1] for e in X_transformed]) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 326 corrcoef[np.isnan(corrcoef)] = np.finfo(np.float32).min | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 327 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 328 return corrcoef | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 329 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 330 def predict_label(self, X, clf_cutoff=0.4): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 331 return self.predict(X) >= clf_cutoff | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 332 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 333 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 334 class BinarizeTargetClassifier(BaseEstimator, RegressorMixin): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 335 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 336 Convert continuous target to binary labels (True and False) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 337 and apply a classification estimator. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 338 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 339 Parameters | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 340 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 341 classifier: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 342 Estimator object such as derived from sklearn `ClassifierMixin`. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 343 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 344 z_score: float, default=-1.0 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 345 Threshold value based on z_score. Will be ignored when | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 346 fixed_value is set | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 347 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 348 value: float, default=None | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 349 Threshold value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 350 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 351 less_is_positive: boolean, default=True | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 352 When target is less the threshold value, it will be converted | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 353 to True, False otherwise. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 354 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 355 Attributes | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 356 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 357 classifier_: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 358 Fitted classifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 359 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 360 discretize_value: float | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 361 The threshold value used to discretize True and False targets | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 362 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 363 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 364 def __init__(self, classifier, z_score=-1, value=None, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 365 less_is_positive=True): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 366 self.classifier = classifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 367 self.z_score = z_score | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 368 self.value = value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 369 self.less_is_positive = less_is_positive | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 370 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 371 def fit(self, X, y, sample_weight=None): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 372 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 373 Convert y to True and False labels and then fit the classifier | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 374 with X and new y | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 375 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 376 Returns | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 377 ------ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 378 self: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 379 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 380 y = check_array(y, accept_sparse=False, force_all_finite=True, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 381 ensure_2d=False, dtype='numeric') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 382 y = column_or_1d(y) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 383 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 384 if self.value is None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 385 discretize_value = y.mean() + y.std() * self.z_score | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 386 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 387 discretize_value = self.Value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 388 self.discretize_value = discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 389 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 390 if self.less_is_positive: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 391 y_trans = y < discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 392 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 393 y_trans = y > discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 394 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 395 self.classifier_ = clone(self.classifier) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 396 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 397 if sample_weight is not None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 398 self.classifier_.fit(X, y_trans, sample_weight=sample_weight) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 399 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 400 self.classifier_.fit(X, y_trans) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 401 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 402 if hasattr(self.classifier_, 'feature_importances_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 403 self.feature_importances_ = self.classifier_.feature_importances_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 404 if hasattr(self.classifier_, 'coef_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 405 self.coef_ = self.classifier_.coef_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 406 if hasattr(self.classifier_, 'n_outputs_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 407 self.n_outputs_ = self.classifier_.n_outputs_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 408 if hasattr(self.classifier_, 'n_features_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 409 self.n_features_ = self.classifier_.n_features_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 410 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 411 return self | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 412 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 413 def predict(self, X): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 414 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 415 Predict class probabilities of X. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 416 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 417 check_is_fitted(self, 'classifier_') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 418 proba = self.classifier_.predict_proba(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 419 return proba[:, 1] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 420 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 421 def predict_label(self, X): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 422 """Predict class label of X | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 423 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 424 check_is_fitted(self, 'classifier_') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 425 return self.classifier_.predict(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 426 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 427 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 428 class _BinarizeTargetProbaScorer(_BaseScorer): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 429 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 430 base class to make binarized target specific scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 431 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 432 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 433 def __call__(self, clf, X, y, sample_weight=None): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 434 clf_name = clf.__class__.__name__ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 435 # support pipeline object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 436 if isinstance(clf, Pipeline): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 437 main_estimator = clf.steps[-1][-1] | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 438 # support stacking ensemble estimators | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 439 # TODO support nested pipeline/stacking estimators | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 440 elif clf_name in ['StackingCVClassifier', 'StackingClassifier']: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 441 main_estimator = clf.meta_clf_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 442 elif clf_name in ['StackingCVRegressor', 'StackingRegressor']: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 443 main_estimator = clf.meta_regr_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 444 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 445 main_estimator = clf | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 446 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 447 discretize_value = main_estimator.discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 448 less_is_positive = main_estimator.less_is_positive | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 449 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 450 if less_is_positive: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 451 y_trans = y < discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 452 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 453 y_trans = y > discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 454 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 455 y_pred = clf.predict(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 456 if sample_weight is not None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 457 return self._sign * self._score_func(y_trans, y_pred, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 458 sample_weight=sample_weight, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 459 **self._kwargs) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 460 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 461 return self._sign * self._score_func(y_trans, y_pred, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 462 **self._kwargs) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 463 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 464 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 465 # roc_auc | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 466 binarize_auc_scorer =\ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 467 _BinarizeTargetProbaScorer(metrics.roc_auc_score, 1, {}) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 468 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 469 # average_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 470 binarize_average_precision_scorer =\ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 471 _BinarizeTargetProbaScorer(metrics.average_precision_score, 1, {}) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 472 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 473 # roc_auc_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 474 iraps_auc_scorer = binarize_auc_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 475 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 476 # average_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 477 iraps_average_precision_scorer = binarize_average_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 478 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 479 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 480 class BinarizeTargetRegressor(BaseEstimator, RegressorMixin): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 481 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 482 Extend regression estimator to have discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 483 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 484 Parameters | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 485 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 486 regressor: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 487 Estimator object such as derived from sklearn `RegressionMixin`. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 488 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 489 z_score: float, default=-1.0 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 490 Threshold value based on z_score. Will be ignored when | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 491 fixed_value is set | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 492 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 493 value: float, default=None | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 494 Threshold value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 495 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 496 less_is_positive: boolean, default=True | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 497 When target is less the threshold value, it will be converted | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 498 to True, False otherwise. | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 499 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 500 Attributes | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 501 ---------- | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 502 regressor_: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 503 Fitted regressor | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 504 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 505 discretize_value: float | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 506 The threshold value used to discretize True and False targets | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 507 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 508 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 509 def __init__(self, regressor, z_score=-1, value=None, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 510 less_is_positive=True): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 511 self.regressor = regressor | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 512 self.z_score = z_score | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 513 self.value = value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 514 self.less_is_positive = less_is_positive | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 515 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 516 def fit(self, X, y, sample_weight=None): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 517 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 518 Calculate the discretize_value fit the regressor with traning data | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 519 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 520 Returns | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 521 ------ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 522 self: object | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 523 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 524 y = check_array(y, accept_sparse=False, force_all_finite=True, | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 525 ensure_2d=False, dtype='numeric') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 526 y = column_or_1d(y) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 527 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 528 if self.value is None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 529 discretize_value = y.mean() + y.std() * self.z_score | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 530 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 531 discretize_value = self.Value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 532 self.discretize_value = discretize_value | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 533 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 534 self.regressor_ = clone(self.regressor) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 535 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 536 if sample_weight is not None: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 537 self.regressor_.fit(X, y, sample_weight=sample_weight) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 538 else: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 539 self.regressor_.fit(X, y) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 540 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 541 # attach classifier attributes | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 542 if hasattr(self.regressor_, 'feature_importances_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 543 self.feature_importances_ = self.regressor_.feature_importances_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 544 if hasattr(self.regressor_, 'coef_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 545 self.coef_ = self.regressor_.coef_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 546 if hasattr(self.regressor_, 'n_outputs_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 547 self.n_outputs_ = self.regressor_.n_outputs_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 548 if hasattr(self.regressor_, 'n_features_'): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 549 self.n_features_ = self.regressor_.n_features_ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 550 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 551 return self | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 552 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 553 def predict(self, X): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 554 """Predict target value of X | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 555 """ | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 556 check_is_fitted(self, 'regressor_') | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 557 y_pred = self.regressor_.predict(X) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 558 if not np.all((y_pred >= 0) & (y_pred <= 1)): | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 559 y_pred = (y_pred - y_pred.min()) / (y_pred.max() - y_pred.min()) | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 560 if self.less_is_positive: | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 561 y_pred = 1 - y_pred | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 562 return y_pred | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 563 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 564 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 565 # roc_auc_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 566 regression_auc_scorer = binarize_auc_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 567 | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 568 # average_precision_scorer | 
| 
1c4a241bef5c
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit c0a3a186966888e5787335a7628bf0a4382637e7
 bgruening parents: diff
changeset | 569 regression_average_precision_scorer = binarize_average_precision_scorer | 
