scmags.ScMags.knn_classifier¶
- ScMags.knn_classifier(test_ratio=0.3, nof_neighbors=3, log_norm=True, conf_normalize='true', rand_state=None, main_title='Confusion Matrix', figsize=None, cmap=<matplotlib.colors.LinearSegmentedColormap object>, plot_name='scmags_knn_result', save_plot=False, plot_dpi=300)¶
This function performs k-NN classification with selected markers. Visualizes the results with a normalized confusion matrix.
- Parameters
test_ratio (
Optional[float]) – Test data rate. Should be between 0-1.nof_neighbors (
Optional[int]) – Number of neighbors to use.log_norm (
Optional[bool]) – Performs log normalization before k-NN.conf_normalize (
Optional[Literal[‘true’, ‘pred’, ‘all’]]) – Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be normalized.rand_state (
Optional[int]) – Controls the shuffling applied to the data before applying the split.main_title (
Optional[str]) – Main title for confusion matrix.figsize (
Optional[Tuple[int,int]]) – Figure size. If not given its own settings.cmap (Optional[str], optional) – A Colormap instance or registered colormap name. (matplotlib cmap)
plot_name (
Optional[str]) – Name of plot to savesave_plot (
bool) – If True, the plot is saved in the working directory.plot_dpi (
int) – The dpi value of the figure to be saved
Examples
>>> import scmags as mg >>> li = mg.datasets.li() >>> li.filter_genes() >>> li.sel_clust_marker() >>> li.knn_classifier()