query
stringlengths
9
60
language
stringclasses
1 value
code
stringlengths
105
25.7k
url
stringlengths
91
217
confusion matrix
python
def plot_confusion_matrix(self, normalised=True): """ Plots the confusion matrix. """ conf_matrix = self.confusion_matrix() if normalised: sns.heatmap(conf_matrix, annot=True, annot_kws={"size": 12}, fmt='2.1f', cmap='YlGnBu', vmin=0.0, ...
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L210-L227
confusion matrix
python
def plot_confusion_matrix(self, normalize:bool=False, title:str='Confusion matrix', cmap:Any="Blues", slice_size:int=1, norm_dec:int=2, plot_txt:bool=True, return_fig:bool=None, **kwargs)->Optional[plt.Figure]: "Plot the confusion matrix, with `title` and using `cmap`." # T...
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/train.py#L161-L184
confusion matrix
python
def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues): """ This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. """ i...
https://github.com/openmednlp/bedrock/blob/15796bd7837ddfe7ad5235fd188e5d7af8c0be49/bedrock/viz.py#L12-L44
confusion matrix
python
def confusion_matrix(self): """Confusion matrix plot """ return plot.confusion_matrix(self.y_true, self.y_pred, self.target_names, ax=_gen_ax())
https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/evaluator.py#L85-L89
confusion matrix
python
def confusion_matrix(predicted_essential, expected_essential, predicted_nonessential, expected_nonessential): """ Compute a representation of the confusion matrix. Parameters ---------- predicted_essential : set expected_essential : set predicted_nonessential : set ...
https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/essentiality.py#L29-L100
confusion matrix
python
def do_confusion_matrix(sorting1, sorting2, unit_map12, labels_st1, labels_st2): """ Compute the confusion matrix between two sorting. Parameters ---------- sorting1: SortingExtractor instance The ground truth sorting. sorting2: SortingExtractor instance The tested sort...
https://github.com/SpikeInterface/spiketoolkit/blob/f7c054383d1ebca640966b057c087fa187955d13/spiketoolkit/comparison/comparisontools.py#L319-L395
confusion matrix
python
def plot_confusion_matrix(cm, title="Confusion Matrix"): """Plots a confusion matrix for each subject """ import matplotlib.pyplot as plt import math plt.figure() subjects = len(cm) root_subjects = math.sqrt(subjects) cols = math.ceil(root_subjects) rows = math.ceil(subjects/cols) ...
https://github.com/brainiak/brainiak/blob/408f12dec2ff56559a26873a848a09e4c8facfeb/examples/funcalign/srm_image_prediction_example_distributed.py#L52-L75
confusion matrix
python
def calc_confusion_matrix(self, printout = False): """ Calculates number of TP, FP, TN, FN """ if self.labels is None: raise DataError("Cannot calculate confusion matrix before data " "has been read.") if self.preds is None: ra...
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/experiments.py#L216-L239
confusion matrix
python
def confusion_matrix(self, slice_size:int=1): "Confusion matrix as an `np.ndarray`." x=torch.arange(0,self.data.c) if slice_size is None: cm = ((self.pred_class==x[:,None]) & (self.y_true==x[:,None,None])).sum(2) else: cm = torch.zeros(self.data.c, self.data.c, dtype=x.dtype)...
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/train.py#L149-L159
confusion matrix
python
def plot_confusion_matrix(y_true, y_pred, labels=None, true_labels=None, pred_labels=None, title=None, normalize=False, hide_zeros=False, x_tick_rotation=0, ax=None, figsize=None, cmap='Blues', title_fontsize="large", ...
https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/plotters.py#L42-L181
confusion matrix
python
def plot(self, figsize=None, rotation=45): """Plot the confusion matrix. Args: figsize: tuple (x, y) of ints. Sets the size of the figure rotation: the rotation angle of the labels on the x-axis. """ fig, ax = plt.subplots(figsize=figsize) plt.imshow(self._cm, interpolation='nearest',...
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L129-L159
confusion matrix
python
def fmt_confusion_matrix(hyps: Sequence[Sequence[str]], refs: Sequence[Sequence[str]], label_set: Set[str] = None, max_width: int = 25) -> str: """ Formats a confusion matrix over substitutions, ignoring insertions and deletions. """ ...
https://github.com/persephone-tools/persephone/blob/f94c63e4d5fe719fb1deba449b177bb299d225fb/persephone/results.py#L132-L167
confusion matrix
python
def confusion(a, p): """Confusion Matrix - confusion matrix, error matrix, matching matrix (unsupervised) - is a special case: 2x2 contingency table (xtab, RxC table) - both dimensions are variables with the same classes/labels, i.e. actual and predicted variables are binary [0,1] Parameters...
https://github.com/kmedian/korr/blob/4eb86fc14b1fc1b69204069b7753d115b327c937/korr/confusion.py#L4-L49
confusion matrix
python
def plot_confusion_matrix_with_cv(clf, X, y, labels=None, true_labels=None, pred_labels=None, title=None, normalize=False, hide_zeros=False, x_tick_rotation=0, do_cv=True, cv=None, shu...
https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/classifiers.py#L70-L219
confusion matrix
python
def confusion_matrix( gold, pred, null_pred=False, null_gold=False, normalize=False, pretty_print=True ): """A shortcut method for building a confusion matrix all at once. Args: gold: an array-like of gold labels (ints) pred: an array-like of predictions (ints) null_pred: If True, i...
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/analysis.py#L217-L242
confusion matrix
python
def draw_confusion_matrix(matrix): '''Draw confusion matrix for MNIST.''' fig = tfmpl.create_figure(figsize=(7,7)) ax = fig.add_subplot(111) ax.set_title('Confusion matrix for MNIST classification') tfmpl.plots.confusion_matrix.draw( ax, matrix, axis_labels=['Digit ' + str(x) fo...
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/samples/mnist.py#L24-L36
confusion matrix
python
def confusion_matrix(self, metrics=None, thresholds=None): """ Get the confusion matrix for the specified metric :param metrics: A string (or list of strings) among metrics listed in :const:`max_metrics`. Defaults to 'f1'. :param thresholds: A value (or list of values) between 0 and 1. ...
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/metrics_base.py#L588-L653
confusion matrix
python
def confusion_matrix(self): """ Returns the normalised confusion matrix """ confusion_matrix = self.pixel_classification_sum.astype(np.float) confusion_matrix = np.divide(confusion_matrix.T, self.pixel_truth_sum.T).T return confusion_matrix * 100.0
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/ml_tools/eolearn/ml_tools/validator.py#L201-L208
confusion matrix
python
def confusion_matrix(links_true, links_pred, total=None): """Compute the confusion matrix. The confusion matrix is of the following form: +----------------------+-----------------------+----------------------+ | | Predicted Positives | Predicted Negatives | +===============...
https://github.com/J535D165/recordlinkage/blob/87a5f4af904e0834047cd07ff1c70146b1e6d693/recordlinkage/measures.py#L238-L292
confusion matrix
python
def confusion_matrix(exp, obs): """Create a confusion matrix In each axis of the resulting confusion matrix the negative case is 0-index and the positive case 1-index. The labels get sorted, in a True/False scenario true positives will occur at (1,1). The first dimension (rows) of the resulting...
https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/misc/performance_measures.py#L152-L173
confusion matrix
python
def _make_diffusion_matrix(K, weight1=None, weight2=None): """Builds the general diffusion matrix with dimension nxn. .. note:: :math:`n` = number of points of diffusion axis :math:`n+1` = number of bounts of diffusion axis **Function-all argument** \n :param array K: dime...
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L208-L300
confusion matrix
python
def most_confused(self, min_val:int=1, slice_size:int=1)->Collection[Tuple[str,str,int]]: "Sorted descending list of largest non-diagonal entries of confusion matrix, presented as actual, predicted, number of occurrences." cm = self.confusion_matrix(slice_size=slice_size) np.fill_diagonal(cm, 0)...
https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/train.py#L186-L192
confusion matrix
python
def load_audit_confusion_matrices(filename): """ Loads a confusion matrix in a two-level dictionary format. For example, the confusion matrix of a 75%-accurate model that predicted 15 values (and mis-classified 5) may look like: {"A": {"A":10, "B": 5}, "B": {"B":5}} Note that raw boolean values are transl...
https://github.com/algofairness/BlackBoxAuditing/blob/b06c4faed5591cd7088475b2a203127bc5820483/python2_source/BlackBoxAuditing/audit_reading.py#L11-L40
confusion matrix
python
def confusion_matrix(self, data): """ Returns a confusion matrix based of H2O's default prediction threshold for a dataset. :param data: metric for which the confusion matrix will be calculated. """ return {model.model_id: model.confusion_matrix(data) for model in self.models}
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/grid/metrics.py#L609-L615
confusion matrix
python
def confusion_matrix(rater_a, rater_b, min_rating=None, max_rating=None): """ Generates a confusion matrix between rater_a and rater_b A confusion matrix shows how often 2 values agree and disagree See quadratic_weighted_kappa for argument descriptions """ assert(len(rater_a) == len(rater_b)) ...
https://github.com/edx/ease/blob/a7890ed403da94d03726b0639cd8ebda45af6bbb/ease/util_functions.py#L387-L407
confusion matrix
python
def matrix(self, title=None): """ Generates the confusion matrix. :param title: optional title :type title: str :return: the matrix :rtype: str """ if title is None: return javabridge.call(self.jobject, "toMatrixString", "()Ljava/lang/String;"...
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/classifiers.py#L1255-L1267
confusion matrix
python
def from_bigquery(sql): """Create a ConfusionMatrix from a BigQuery table or query. Args: sql: Can be one of: A SQL query string. A Bigquery table string. A Query object defined with '%%bq query --name [query_name]'. The query results or table must include "target", "p...
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L80-L113
confusion matrix
python
def confusion_matrix(df, col_true=None, col_pred=None): """ Compute confusion matrix of a predicted DataFrame. Note that this method will trigger the defined flow to execute. :param df: predicted data frame :type df: DataFrame :param col_true: column name of true label :type col_true: str ...
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/ml/metrics/classification.py#L76-L97
confusion matrix
python
def diff_aff(self): """Symmetric diffusion affinity matrix Return or calculate the symmetric diffusion affinity matrix .. math:: A(x,y) = K(x,y) (d(x) d(y))^{-1/2} where :math:`d` is the degrees (row sums of the kernel.) Returns ------- diff_aff : array-like,...
https://github.com/KrishnaswamyLab/graphtools/blob/44685352be7df2005d44722903092207967457f2/graphtools/base.py#L513-L535
confusion matrix
python
def from_existing(cls, confusion, *args, **kwargs): """Creates a confusion matrix from a DataFrame that already contains confusion counts (but not meta stats) >>> df = pd.DataFrame(np.matrix([[0,1,2,0,1,2,1,2,2,1],[0,1,2,1,2,0,0,1,2,0]]).T, columns=['True', 'Pred']) >>> c = Confusion(df) ...
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/stats.py#L536-L562
confusion matrix
python
def _make_meridional_diffusion_matrix(K, lataxis): """Calls :func:`_make_diffusion_matrix` with appropriate weights for the meridional diffusion case. :param array K: dimensionless diffusivities at cell boundaries of diffusion axis ``lataxis`` :param axis lataxis: ...
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L303-L357
confusion matrix
python
def confusion_matrix(self, metrics=None, thresholds=None, train=False, valid=False, xval=False): """ Get the confusion matrix for the specified metrics/thresholds. If all are False (default), then return the training metric value. If more than one options is set to True, then return a d...
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/grid/metrics.py#L388-L407
confusion matrix
python
def cublasZgbmv(handle, trans, m, n, kl, ku, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex general banded matrix. """ status = _libcublas.cublasZgbmv_v2(handle, trans, m, n, kl, ku, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2163-L2178
confusion matrix
python
def confusion_to_mcc(*args): """Convert the confusion matrix to the Matthews correlation coefficient Parameters: ----------- cm : ndarray 2x2 confusion matrix with np.array([[tn, fp], [fn, tp]]) tn, fp, fn, tp : float four scalar variables - tn : number of true negatives ...
https://github.com/kmedian/korr/blob/4eb86fc14b1fc1b69204069b7753d115b327c937/korr/mcc.py#L6-L36
confusion matrix
python
def matrix_directed_unweighted(user): """ Returns a directed, unweighted matrix where an edge exists if there is at least one call or text. """ matrix = _interaction_matrix(user, interaction=None) for a in range(len(matrix)): for b in range(len(matrix)): if matrix[a][b] is no...
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L124-L135
confusion matrix
python
def cublasZsymv(handle, uplo, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex symmetric matrix. """ status = _libcublas.cublasZsymv_v2(handle, _CUBLAS_FILL_MODE[uplo], n, ctypes.byref(cud...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2788-L2802
confusion matrix
python
def confusion_matrix(self, data): """ Returns a confusion matrix based of H2O's default prediction threshold for a dataset. :param H2OFrame data: the frame with the prediction results for which the confusion matrix should be extracted. """ assert_is_type(data, H2OFrame) ...
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/multinomial.py#L18-L26
confusion matrix
python
def cublasZgemv(handle, trans, m, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex general matrix. """ status = _libcublas.cublasZgemv_v2(handle, _CUBLAS_OP[trans], m, n, ctypes.byref(cuda.cuD...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2335-L2349
confusion matrix
python
def from_csv(input_csv, headers=None, schema_file=None): """Create a ConfusionMatrix from a csv file. Args: input_csv: Path to a Csv file (with no header). Can be local or GCS path. headers: Csv headers. If present, it must include 'target' and 'predicted'. schema_file: Path to a JSON file co...
https://github.com/googledatalab/pydatalab/blob/d9031901d5bca22fe0d5925d204e6698df9852e1/google/datalab/ml/_confusion_matrix.py#L41-L77
confusion matrix
python
def cublasZgemm(handle, transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc): """ Matrix-matrix product for complex general matrix. """ status = _libcublas.cublasZgemm_v2(handle, _CUBLAS_OP[transa], _CUBLAS_OP[trans...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4010-L4025
confusion matrix
python
def flux_matrix(T, pi, qminus, qplus, netflux=True): r"""Compute the flux. Parameters ---------- T : (M, M) scipy.sparse matrix Transition matrix pi : (M,) ndarray Stationary distribution corresponding to T qminus : (M,) ndarray Backward comittor qplus : (M,) ndarray...
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/flux/sparse/tpt.py#L70-L105
confusion matrix
python
def cublasZtpmv(handle, uplo, trans, diag, n, AP, x, incx): """ Matrix-vector product for complex triangular-packed matrix. """ status = _libcublas.cublasZtpmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3260-L3271
confusion matrix
python
def matrix( m, n, lst, m_text: list=None, n_text: list=None): """ m: row n: column lst: items >>> print(_matrix(2, 3, [(1, 1), (2, 3)])) |x| | | | | |x| """ fmt = "" if n_text: fmt += " {}\n".format(" ".join(n_text)) for ...
https://github.com/PhilippeFerreiraDeSousa/bitext-matching/blob/195c3e98775cfa5e63e4bb0bb1da6f741880d980/lib/enpc_aligner/IBM2_func.py#L104-L131
confusion matrix
python
def diagonalize_collision_matrix(collision_matrices, i_sigma=None, i_temp=None, pinv_solver=0, log_level=0): """Diagonalize collision matrices. Note ---- collision_matrici...
https://github.com/atztogo/phono3py/blob/edfcf36cdc7c5392906a9df57d3ee0f3141404df/phono3py/phonon3/conductivity_LBTE.py#L609-L724
confusion matrix
python
def transitions(self): """Transition matrix (sparse matrix). Is conjugate to the symmetrized transition matrix via:: self.transitions = self.Z * self.transitions_sym / self.Z where ``self.Z`` is the diagonal matrix storing the normalization of the underlying kernel matrix...
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/neighbors/__init__.py#L512-L530
confusion matrix
python
def cublasCgbmv(handle, trans, m, n, kl, ku, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex general banded matrix. """ status = _libcublas.cublasCgbmv_v2(handle, trans, m, n, kl, ku, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2132-L2147
confusion matrix
python
def confusion_matrix(y_true, y_pred, target_names=None, normalize=False, cmap=None, ax=None): """ Plot confustion matrix. Parameters ---------- y_true : array-like, shape = [n_samples] Correct target values (ground truth). y_pred : array-like, shape = [n_samples] ...
https://github.com/edublancas/sklearn-evaluation/blob/79ee6e4dfe911b5a5a9b78a5caaed7c73eef6f39/sklearn_evaluation/plot/classification.py#L13-L105
confusion matrix
python
def cublasZgerc(handle, m, n, alpha, x, incx, y, incy, A, lda): """ Rank-1 operation on complex general matrix. """ status = _libcublas.cublasZgerc_v2(handle, m, n, ctypes.byref(cuda.cuDoubleComplex(alpha.real, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2457-L2467
confusion matrix
python
def confusion_matrix(expected: np.ndarray, predicted: np.ndarray, num_classes: int) -> np.ndarray: """ Calculate and return confusion matrix for the predicted and expected labels :param expected: array of expected classes (integers) with shape `[num_of_data]` :param predicted: array of predicted classe...
https://github.com/Cognexa/cxflow/blob/dd609e6b0bd854424a8f86781dd77801a13038f9/cxflow/utils/confusion_matrix.py#L4-L22
confusion matrix
python
def cublasCtpmv(handle, uplo, trans, diag, n, AP, x, incx): """ Matrix-vector product for complex triangular-packed matrix. """ status = _libcublas.cublasCtpmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3216-L3227
confusion matrix
python
def confusion_matrix_and_correct_series(self, y_info): ''' Generate confusion matrix from y_info ''' a = deepcopy(y_info['true']) true_count = dict((i, a.count(i)) for i in set(a)) a = deepcopy(y_info['pred']) pred_count = dict((i, a.count(i)) for i in set(a)) sorted_cats = sorte...
https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/clustergrammer2/clustergrammer_fun/__init__.py#L793-L825
confusion matrix
python
def cublasCsymm(handle, side, uplo, m, n, alpha, A, lda, B, ldb, beta, C, ldc): """ Matrix-matrix product for complex symmetric matrix. """ status = _libcublas.cublasCsymm_v2(handle, _CUBLAS_SIDE_MODE[side], _CUBLAS_FI...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4101-L4116
confusion matrix
python
def matrix_undirected_weighted(user, interaction=None): """ Returns an undirected, weighted matrix for call, text and call duration where an edge exists if the relationship is reciprocated. """ matrix = _interaction_matrix(user, interaction=interaction) result = [[0 for _ in range(len(matrix))] ...
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L138-L155
confusion matrix
python
def view_conflicts(L, normalize=True, colorbar=True): """Display an [m, m] matrix of conflicts""" L = L.todense() if sparse.issparse(L) else L C = _get_conflicts_matrix(L, normalize=normalize) plt.imshow(C, aspect="auto") plt.title("Conflicts") if colorbar: plt.colorbar() plt.show()
https://github.com/HazyResearch/metal/blob/c24e3772e25ac6d0917b8b7af4c1bcb92928f84a/metal/contrib/visualization/analysis.py#L35-L43
confusion matrix
python
def cublasCgemv(handle, trans, m, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex general matrix. """ status = _libcublas.cublasCgemv_v2(handle, _CUBLAS_OP[trans], m, n, ctypes.byref(cuda.cuF...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2306-L2320
confusion matrix
python
def confusion_performance(mat, fn): """Apply a performance function to a confusion matrix :param mat: confusion matrix :type mat: square matrix :param function fn: performance function """ if mat.shape[0] != mat.shape[1] or mat.shape < (2, 2): raise TypeError('{} is not a confusion ...
https://github.com/childsish/lhc-python/blob/0a669f46a40a39f24d28665e8b5b606dc7e86beb/lhc/misc/performance_measures.py#L176-L193
confusion matrix
python
def cublasCtrmv(handle, uplo, trans, diag, n, A, lda, x, incx): """ Matrix-vector product for complex triangular matrix. """ status = _libcublas.cublasCtrmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3397-L3408
confusion matrix
python
def draw(self): """ Renders the classification report; must be called after score. """ # Perform display related manipulations on the confusion matrix data cm_display = self.confusion_matrix_ # Convert confusion matrix to percent of each row, i.e. the # predicte...
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/classifier/confusion_matrix.py#L196-L271
confusion matrix
python
def _conditional(Xnew, feat, kern, f, *, full_cov=False, full_output_cov=False, q_sqrt=None, white=False): """ Most efficient routine to project L independent latent gps through a mixing matrix W. The mixing matrix is a member of the `SeparateMixedMok` and has shape P x L. The covariance matrices used ...
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/multioutput/conditionals.py#L214-L236
confusion matrix
python
def matrix(ctx, scenario_name, subcommand): # pragma: no cover """ List matrix of steps used to test instances. """ args = ctx.obj.get('args') command_args = { 'subcommand': subcommand, } s = scenarios.Scenarios( base.get_configs(args, command_args), scenario_name) s.p...
https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/matrix.py#L71-L83
confusion matrix
python
def cublasZtrmm(handle, side, uplo, trans, diag, m, n, alpha, A, lda, B, ldb, C, ldc): """ Matrix-matrix product for complex triangular matrix. """ status = _libcublas.cublasZtrmm_v2(handle, _CUBLAS_SIDE_MODE[side], _C...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4492-L4506
confusion matrix
python
def cublasCsymv(handle, uplo, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for complex symmetric matrix. """ status = _libcublas.cublasCsymv_v2(handle, _CUBLAS_FILL_MODE[uplo], n, ctypes.byref(cud...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2760-L2774
confusion matrix
python
def _implicit_solver(self): """Invertes and solves the matrix problem for diffusion matrix and temperature T. The method is called by the :func:`~climlab.process.implicit.ImplicitProcess._compute()` function of the :class:`~climlab.process.implicit.ImplicitProcess` class and ...
https://github.com/brian-rose/climlab/blob/eae188a2ae9308229b8cbb8fe0b65f51b50ee1e6/climlab/dynamics/diffusion.py#L143-L192
confusion matrix
python
def confusion_matrix(model, X, y, ax=None, classes=None, sample_weight=None, percent=False, label_encoder=None, cmap='YlOrRd', fontsize=None, random_state=None, **kwargs): """Quick method: Creates a heatmap visualization of the sklearn.metrics.confusion_matrix(). A...
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/classifier/confusion_matrix.py#L284-L374
confusion matrix
python
def concat(mats): """Concatenate Matrix objects. Tries either axis. Parameters ---------- mats: list list of Matrix objects Returns ------- Matrix : Matrix """ for mat in mats: if mat.isdiagonal: raise NotImplementedError("concat not supported for diago...
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/mat/mat_handler.py#L67-L119
confusion matrix
python
def matrix(self): """The current calibration matrix for this device. Returns: (bool, (float, float, float, float, float, float)): :obj:`False` if no calibration is set and the returned matrix is the identity matrix, :obj:`True` otherwise. :obj:`tuple` representing the first two rows of a 3x3 matrix ...
https://github.com/OzymandiasTheGreat/python-libinput/blob/1f477ee9f1d56b284b20e0317ea8967c64ef1218/libinput/device.py#L540-L554
confusion matrix
python
def cublasDtpmv(handle, uplo, trans, diag, n, AP, x, incx): """ Matrix-vector product for real triangular-packed matrix. """ status = _libcublas.cublasDtpmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3238-L3249
confusion matrix
python
def s2dctmat(nfilt,ncep,freqstep): """Return the 'legacy' not-quite-DCT matrix used by Sphinx""" melcos = numpy.empty((ncep, nfilt), 'double') for i in range(0,ncep): freq = numpy.pi * float(i) / nfilt melcos[i] = numpy.cos(freq * numpy.arange(0.5, float(nfilt)+0.5, 1.0, 'double')) melco...
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/thirdparty/mfcc.py#L146-L153
confusion matrix
python
def matrix(matrix, xlabel=None, ylabel=None, xticks=None, yticks=None, title=None, colorbar_shrink=0.5, color_map=None, show=None, save=None, ax=None): """Plot a matrix.""" if ax is None: ax = pl.gca() img = ax.imshow(matrix, cmap=color_map) if xlabel is not None: ax.set_xlabel(xla...
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_utils.py#L27-L41
confusion matrix
python
def freivalds(A, B, C): """Tests matrix product AB=C by Freivalds :param A: n by n numerical matrix :param B: same :param C: same :returns: False with high probability if AB != C :complexity: :math:`O(n^2)` """ n = len(A) x = [randint(0, 1000000) for j in range(n)] retu...
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/freivalds.py#L36-L49
confusion matrix
python
def conjugate(self): """The element-wise conjugate matrix This is defined only if all the entries in the matrix have a defined conjugate (i.e., they have a `conjugate` method). This is *not* the case for a matrix of operators. In such a case, only an :meth:`elementwise` :func:`a...
https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/matrix_algebra.py#L167-L184
confusion matrix
python
def refresh_meta(self): """Calculations that only depend on aggregate counts in Confusion Matrix go here""" # these calcs are duplicated in __init__() setattr(self, '_num_classes', len(self.index)) setattr(self, '_colnums', np.arange(0, self._num_classes)) try: setat...
https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/stats.py#L487-L529
confusion matrix
python
def _q_to_dcm(self, q): """ Create DCM (Matrix3) from q :param q: array q which represents a quaternion [w, x, y, z] :returns: Matrix3 """ assert(len(q) == 4) arr = super(Quaternion, self)._q_to_dcm(q) return self._dcm_array_to_matrix3(arr)
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L574-L582
confusion matrix
python
def _fusion_legacy_handler(_, __, tokens): """Handle a legacy fusion.""" if RANGE_5P not in tokens: tokens[RANGE_5P] = {FUSION_MISSING: '?'} if RANGE_3P not in tokens: tokens[RANGE_3P] = {FUSION_MISSING: '?'} return tokens
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/modifiers/fusion.py#L109-L115
confusion matrix
python
def cublasStpmv(handle, uplo, trans, diag, n, AP, x, incx): """ Matrix-vector product for real triangular-packed matrix. """ status = _libcublas.cublasStpmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3194-L3205
confusion matrix
python
def cublasDtrmv(handle, uplo, trans, diag, n, A, lda, x, inx): """ Matrix-vector product for real triangular matrix. """ status = _libcublas.cublasDtrmv_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3420-L3431
confusion matrix
python
def converged(matrix1, matrix2): """ Check for convergence by determining if matrix1 and matrix2 are approximately equal. :param matrix1: The matrix to compare with matrix2 :param matrix2: The matrix to compare with matrix1 :returns: True if matrix1 and matrix2 approximately equal """ ...
https://github.com/GuyAllard/markov_clustering/blob/28787cf64ef06bf024ff915246008c767ea830cf/markov_clustering/mcl.py#L108-L120
confusion matrix
python
def decomposed_diffusion_program(qubits: List[int]) -> Program: """ Constructs the diffusion operator used in Grover's Algorithm, acted on both sides by an a Hadamard gate on each qubit. Note that this means that the matrix representation of this operator is diag(1, -1, ..., -1). In particular, this dec...
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/amplification/amplification.py#L86-L118
confusion matrix
python
def matrix_undirected_unweighted(user): """ Returns an undirected, unweighted matrix where an edge exists if the relationship is reciprocated. """ matrix = matrix_undirected_weighted(user, interaction=None) for a, b in combinations(range(len(matrix)), 2): if matrix[a][b] is None or matri...
https://github.com/yvesalexandre/bandicoot/blob/73a658f6f17331541cf0b1547028db9b70e8d58a/bandicoot/network.py#L158-L171
confusion matrix
python
def cublasDgemm(handle, transa, transb, m, n, k, alpha, A, lda, B, ldb, beta, C, ldc): """ Matrix-matrix product for real general matrix. """ status = _libcublas.cublasDgemm_v2(handle, _CUBLAS_OP[transa], _CUBLAS_OP[transb],...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L3980-L3993
confusion matrix
python
def matrix_str(p, decimal_places=2, print_zero=True, label_columns=False): '''Pretty-print the matrix.''' return '[{0}]'.format("\n ".join([(str(i) if label_columns else '') + vector_str(a, decimal_places, print_zero) for i, a in enumerate(p)]))
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/utils.py#L156-L158
confusion matrix
python
def cublasSdgmm(handle, mode, m, n, A, lda, x, incx, C, ldc): """ Matrix-diagonal matrix product for real general matrix. """ status = _libcublas.cublasSdgmm(handle, _CUBLAS_SIDE[mode], m, n, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4819-L4831
confusion matrix
python
def cublasCgeru(handle, m, n, alpha, x, incx, y, incy, A, lda): """ Rank-1 operation on complex general matrix. """ status = _libcublas.cublasCgeru_v2(handle, m, n, ctypes.byref(cuda.cuFloatComplex(alpha.real, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2434-L2444
confusion matrix
python
def _matrix3_to_dcm_array(self, m): """ Converts Matrix3 in an array :param m: Matrix3 :returns: 3x3 array """ assert(isinstance(m, Matrix3)) return np.array([[m.a.x, m.a.y, m.a.z], [m.b.x, m.b.y, m.b.z], [m.c.x, m...
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L563-L572
confusion matrix
python
def cublasDspmv(handle, uplo, n, alpha, AP, x, incx, beta, y, incy): """ Matrix-vector product for real symmetric-packed matrix. """ status = _libcublas.cublasDspmv_v2(handle, _CUBLAS_FILL_MODE[uplo], n, ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2589-L2605
confusion matrix
python
def cublasDsymv(handle, uplo, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for real symmetric matrix. """ status = _libcublas.cublasDsymv_v2(handle, _CUBLAS_FILL_MODE[uplo], n, ctypes.byref(ctyp...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2734-L2746
confusion matrix
python
def cublasDsymm(handle, side, uplo, m, n, alpha, A, lda, B, ldb, beta, C, ldc): """ Matrix-matrix product for real symmetric matrix. """ status = _libcublas.cublasDsymm_v2(handle, _CUBLAS_SIDE_MODE[side], _CUBLAS_FILL_M...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4072-L4085
confusion matrix
python
def matrix_coords(rows, cols, rowh, colw, ox=0, oy=0): "Generate coords for a matrix of rects" for i, f, c in rowmajor(rows, cols): x = ox + c * colw y = oy + f * rowh x1 = x + colw y1 = y + rowh yield (i, x, y, x1, y1)
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/calendarframe.py#L40-L47
confusion matrix
python
def equation(self): """Mix-in class that returns matrix rows for zero normal flux condition. Using the control point on the outside Returns matrix part (nunknowns,neq) Returns rhs part nunknowns """ mat = np.empty((self.nunknowns, self.model.neq)) rhs = np.zeros(s...
https://github.com/mbakker7/timml/blob/91e99ad573cb8a9ad8ac1fa041c3ca44520c2390/timml/equation.py#L134-L154
confusion matrix
python
def matrix_exponent(M): """ The function computes matrix exponent and handles some special cases """ if (M.shape[0] == 1): # 1*1 matrix Mexp = np.array( ((np.exp(M[0,0]) ,),) ) else: # matrix is larger method = None try: Mexp = linalg.expm(M) method ...
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/models/state_space_main.py#L3448-L3474
confusion matrix
python
def cublasZsyrk(handle, uplo, trans, n, k, alpha, A, lda, beta, C, ldc): """ Rank-k operation on complex symmetric matrix. """ status = _libcublas.cublasZsyrk_v2(handle, _CUBLAS_FILL_MODE[uplo], _CUBLAS_OP[trans], ...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L4247-L4262
confusion matrix
python
def mixed_density(qubits: Union[int, Qubits]) -> Density: """Returns the completely mixed density matrix""" N, qubits = qubits_count_tuple(qubits) matrix = np.eye(2**N) / 2**N return Density(matrix, qubits)
https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/states.py#L322-L326
confusion matrix
python
def cublasDgemv(handle, trans, m, n, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for real general matrix. """ status = _libcublas.cublasDgemv_v2(handle, _CUBLAS_OP[trans], m, n, ctypes.byref(ctypes.c_do...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2279-L2291
confusion matrix
python
def _dcm_array_to_matrix3(self, dcm): """ Converts dcm array into Matrix3 :param dcm: 3x3 dcm array :returns: Matrix3 """ assert(dcm.shape == (3, 3)) a = Vector3(dcm[0][0], dcm[0][1], dcm[0][2]) b = Vector3(dcm[1][0], dcm[1][1], dcm[1][2]) c = Vect...
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L551-L561
confusion matrix
python
def multiply(self, matrix): """ Multiply this matrix by a local dense matrix on the right. :param matrix: a local dense matrix whose number of rows must match the number of columns of this matrix :returns: :py:class:`RowMatrix` >>> rm = RowMatrix(sc.paral...
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/linalg/distributed.py#L373-L389
confusion matrix
python
def matrix_from_basis_coefficients(expansion: value.LinearDict[str], basis: Dict[str, np.ndarray]) -> np.ndarray: """Computes linear combination of basis vectors with given coefficients.""" some_element = next(iter(basis.values())) result = np.zeros_like(some_element, dtyp...
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/linalg/operator_spaces.py#L69-L76
confusion matrix
python
def cublasDsbmv(handle, uplo, n, k, alpha, A, lda, x, incx, beta, y, incy): """ Matrix-vector product for real symmetric-banded matrix. """ status = _libcublas.cublasDsbmv_v2(handle, _CUBLAS_FILL_MODE[uplo], n, k, ctypes.byr...
https://github.com/hannes-brt/hebel/blob/1e2c3a9309c2646103901b26a55be4e312dd5005/hebel/pycuda_ops/cublas.py#L2534-L2546
confusion matrix
python
def matrix(self) -> np.ndarray: """Reconstructs matrix of self using unitaries of underlying gates. Raises: TypeError: if any of the gates in self does not provide a unitary. """ num_qubits = self.num_qubits() if num_qubits is None: raise ValueError('Unkn...
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/ops/linear_combinations.py#L94-L107
confusion matrix
python
def generate_mediation_matrix(dsm): """ Generate the mediation matrix of the given matrix. Rules for mediation matrix generation: Set -1 for items NOT to be considered Set 0 for items which MUST NOT be present Set 1 for items which MUST be present Each module h...
https://github.com/Genida/archan/blob/a026d3105c7e86f30e6c9507b93ceb736684bfdc/src/archan/plugins/checkers.py#L30-L127
confusion matrix
python
def cofactor_n(x, i, j): '''Return the cofactor of n matrices x[n,i,j] at position i,j The cofactor is the determinant of the matrix formed by removing row i and column j. ''' m = x.shape[1] mr = np.arange(m) i_idx = mr[mr != i] j_idx = mr[mr != j] return det_n(x[:, i_idx[:, np.newa...
https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/filter.py#L1374-L1385