pymks/tools.py
def draw_gridscores_matrix(grid_scores, params, score_label=None,
                           param_labels=None):
    """
    Visualize the score value matrix and standard deviation matrix from grids
    scores result from GridSearchCV while varying two parameters.

    Args:
        grid_scores (list): `grid_scores_` attribute from GridSearchCV
        params (list): two parameters used in grid_scores
        score_label (str): label for score value axis
        param_labels (list): parameter titles to appear on plot
    """
    plt.close('all')
    if score_label is None:
        score_label = 'R-Squared'
    if param_labels is None:
        param_labels = ['', '']
    tmp = [[params, mean_score, scores.std()]
           for parameters, mean_score, scores in grid_scores.grid_scores_]
    param, means, stddev = list(zip(*tmp))
    param_range_0 = grid_scores.param_grid[params[0]]
    param_range_1 = grid_scores.param_grid[params[1]]
    mat_size = (len(param_range_1), len(param_range_0))
    fig, axs = plt.subplots(1, 2, figsize=(10, 5))
    matrices = np.concatenate((np.array(means).reshape(mat_size)[None],
                               np.array(stddev).reshape(mat_size)[None]))
    X_cmap = _grid_matrix_cmap()
    x_label = param_labels[0]
    y_label = param_labels[1]
    plot_title = [score_label, 'Standard Deviation']
    for ax, label, matrix, title in zip(axs, param_labels,
                                        np.swapaxes(matrices, -1, -2),
                                        plot_title):
        ax.set_xticklabels(param_range_0, fontsize=12)
        ax.set_yticklabels(param_range_1, fontsize=12)
        ax.set_xticks(np.arange(len(param_range_0)))
        ax.set_yticks(np.arange(len(param_range_0)))
        ax.set_xlabel(x_label, fontsize=14)
        ax.set_ylabel(y_label, fontsize=14)
        ax.grid(False)
        im = ax.imshow(np.swapaxes(matrix, 0, 1),
                       cmap=X_cmap, interpolation='none')
        ax.set_title(title, fontsize=22)
        divider = make_axes_locatable(ax)
        cbar_ax = divider.append_axes("right", size="10%", pad=0.05)
        cbar = plt.colorbar(im, cax=cbar_ax)
        cbar.ax.tick_params(labelsize=12)
        fig.subplots_adjust(right=1.2)
    plt.show()

    Visualize the score value matrix and standard deviation matrix from grids
    scores result from GridSearchCV while varying two parameters.

    Args:
        grid_scores (list): `grid_scores_` attribute from GridSearchCV
        params (list): two parameters used in grid_scores
        score_label (str): label for score value axis
        param_labels (list): parameter titles to appear on plot
    
Visualize the score value matrix and standard deviation matrix from grids
scores result from GridSearchCV while varying two parameters.
Visualize the score value matrix and standard deviation matrix from grids scores result from GridSearchCV while varying two parameters .
def draw_gridscores_matrix(grid_scores, params, score_label=None,
                           param_labels=None):
    plt.close('all')
    if score_label is None:
        score_label = 'R-Squared'
    if param_labels is None:
        param_labels = ['', '']
    tmp = [[params, mean_score, scores.std()]
           for parameters, mean_score, scores in grid_scores.grid_scores_]
    param, means, stddev = list(zip(*tmp))
    param_range_0 = grid_scores.param_grid[params[0]]
    param_range_1 = grid_scores.param_grid[params[1]]
    mat_size = (len(param_range_1), len(param_range_0))
    fig, axs = plt.subplots(1, 2, figsize=(10, 5))
    matrices = np.concatenate((np.array(means).reshape(mat_size)[None],
                               np.array(stddev).reshape(mat_size)[None]))
    X_cmap = _grid_matrix_cmap()
    x_label = param_labels[0]
    y_label = param_labels[1]
    plot_title = [score_label, 'Standard Deviation']
    for ax, label, matrix, title in zip(axs, param_labels,
                                        np.swapaxes(matrices, -1, -2),
                                        plot_title):
        ax.set_xticklabels(param_range_0, fontsize=12)
        ax.set_yticklabels(param_range_1, fontsize=12)
        ax.set_xticks(np.arange(len(param_range_0)))
        ax.set_yticks(np.arange(len(param_range_0)))
        ax.set_xlabel(x_label, fontsize=14)
        ax.set_ylabel(y_label, fontsize=14)
        ax.grid(False)
        im = ax.imshow(np.swapaxes(matrix, 0, 1),
                       cmap=X_cmap, interpolation='none')
        ax.set_title(title, fontsize=22)
        divider = make_axes_locatable(ax)
        cbar_ax = divider.append_axes("right", size="10%", pad=0.05)
        cbar = plt.colorbar(im, cax=cbar_ax)
        cbar.ax.tick_params(labelsize=12)
        fig.subplots_adjust(right=1.2)
    plt.show()
def draw_gridscores_matrix ( grid_scores , params , score_label = None , param_labels = None ) : plt . close ( 'all' ) if score_label is None : score_label = 'R-Squared' if param_labels is None : param_labels = [ '' , '' ] tmp = [ [ params , mean_score , scores . std ( ) ] for parameters , mean_score , scores in grid_scores . grid_scores_ ] param , means , stddev = list ( zip ( * tmp ) ) param_range_0 = grid_scores . param_grid [ params [ 0 ] ] param_range_1 = grid_scores . param_grid [ params [ 1 ] ] mat_size = ( len ( param_range_1 ) , len ( param_range_0 ) ) fig , axs = plt . subplots ( 1 , 2 , figsize = ( 10 , 5 ) ) matrices = np . concatenate ( ( np . array ( means ) . reshape ( mat_size ) [ None ] , np . array ( stddev ) . reshape ( mat_size ) [ None ] ) ) X_cmap = _grid_matrix_cmap ( ) x_label = param_labels [ 0 ] y_label = param_labels [ 1 ] plot_title = [ score_label , 'Standard Deviation' ] for ax , label , matrix , title in zip ( axs , param_labels , np . swapaxes ( matrices , - 1 , - 2 ) , plot_title ) : ax . set_xticklabels ( param_range_0 , fontsize = 12 ) ax . set_yticklabels ( param_range_1 , fontsize = 12 ) ax . set_xticks ( np . arange ( len ( param_range_0 ) ) ) ax . set_yticks ( np . arange ( len ( param_range_0 ) ) ) ax . set_xlabel ( x_label , fontsize = 14 ) ax . set_ylabel ( y_label , fontsize = 14 ) ax . grid ( False ) im = ax . imshow ( np . swapaxes ( matrix , 0 , 1 ) , cmap = X_cmap , interpolation = 'none' ) ax . set_title ( title , fontsize = 22 ) divider = make_axes_locatable ( ax ) cbar_ax = divider . append_axes ( "right" , size = "10%" , pad = 0.05 ) cbar = plt . colorbar ( im , cax = cbar_ax ) cbar . ax . tick_params ( labelsize = 12 ) fig . subplots_adjust ( right = 1.2 ) plt . show ( )
Visualize the score value matrix and standard deviation matrix from grids
scores result from GridSearchCV while varying two parameters.
Visualize the score value matrix and standard deviation matrix from grids scores result from GridSearchCV while varying two parameters .
"""
    Visualize the score value matrix and standard deviation matrix from grids
    scores result from GridSearchCV while varying two parameters.

    Args:
        grid_scores (list): `grid_scores_` attribute from GridSearchCV
        params (list): two parameters used in grid_scores
        score_label (str): label for score value axis
        param_labels (list): parameter titles to appear on plot
    """
grid_scores
`grid_scores_` attribute from GridSearchCV
` grid_scores_ ` attribute from GridSearchCV
params
two parameters used in grid_scores
two parameters used in grid_scores
score_label
label for score value axis
label for score value axis
param_labels
parameter titles to appear on plot
parameter titles to appear on plot