Esempio n. 1
0
def mlr_show( clf, RMv, yEv, disp = True, graph = True):
    yEv_calc = clf.predict( RMv)

    if len( np.shape(yEv)) == 2 and len( np.shape(yEv_calc)) == 1:
        yEv_calc = np.mat( yEv_calc).T

    r_sqr, RMSE = kchem.estimate_accuracy( yEv, yEv_calc, disp = disp)
    if graph:
        plt.figure()
        ms_sz = max(min( 4000 / yEv.shape[0], 8), 1)
        plt.plot( yEv.tolist(), yEv_calc.tolist(), '.', ms = ms_sz)
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color = 'pink')
        plt.xlabel('Experiment')
        plt.ylabel('Prediction')
        plt.title( '$r^2$ = {0:.2e}, RMSE = {1:.2e}'.format( r_sqr, RMSE))
        plt.show()

    return r_sqr, RMSE
Esempio n. 2
0
def cv_show( yEv, yEv_calc, disp = True, graph = True, grid_std = None):

    # if the output is a vector and the original is a metrix, 
    # the output is translated to a matrix. 
    if len( np.shape(yEv_calc)) == 1:   
        yEv_calc = np.mat( yEv_calc).T
    if len( np.shape(yEv)) == 1:
        yEv = np.mat( yEv).T

    r_sqr, RMSE = kchem.estimate_accuracy( yEv, yEv_calc, disp = disp)
    if graph:
        #plt.scatter( yEv.tolist(), yEv_calc.tolist())  
        plt.figure()    
        ms_sz = max(min( 4000 / yEv.shape[0], 8), 1)
        plt.plot( yEv.tolist(), yEv_calc.tolist(), '.', ms = ms_sz) # Change ms 
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color = 'pink')
        plt.xlabel('Experiment')
        plt.ylabel('Prediction')
        if grid_std:
            plt.title( '($r^2$, std) = ({0:.2e}, {1:.2e}), RMSE = {2:.2e}'.format( r_sqr, grid_std, RMSE))
        else:
            plt.title( '$r^2$ = {0:.2e}, RMSE = {1:.2e}'.format( r_sqr, RMSE))
        plt.show()
    return r_sqr, RMSE
Esempio n. 3
0
def mlr_show(clf, RMv, yEv, disp=True, graph=True):
    yEv_calc = clf.predict(RMv)

    if len(np.shape(yEv)) == 2 and len(np.shape(yEv_calc)) == 1:
        yEv_calc = np.mat(yEv_calc).T

    r_sqr, RMSE = kchem.estimate_accuracy(yEv, yEv_calc, disp=disp)
    if graph:
        plt.figure()
        ms_sz = max(min(4000 / yEv.shape[0], 8), 1)
        plt.plot(yEv.tolist(), yEv_calc.tolist(), '.', ms=ms_sz)
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color='pink')
        plt.xlabel('Experiment')
        plt.ylabel('Prediction')
        plt.title('$r^2$ = {0:.2e}, RMSE = {1:.2e}'.format(r_sqr, RMSE))
        plt.show()

    return r_sqr, RMSE
Esempio n. 4
0
def cv_show(yEv, yEv_calc, disp=True, graph=True, grid_std=None):

    # if the output is a vector and the original is a metrix,
    # the output is translated to a matrix.
    if len(np.shape(yEv_calc)) == 1:
        yEv_calc = np.mat(yEv_calc).T
    if len(np.shape(yEv)) == 1:
        yEv = np.mat(yEv).T

    r_sqr, RMSE = kchem.estimate_accuracy(yEv, yEv_calc, disp=disp)
    if graph:
        #plt.scatter( yEv.tolist(), yEv_calc.tolist())
        plt.figure()
        ms_sz = max(min(4000 / yEv.shape[0], 8), 1)
        plt.plot(yEv.tolist(), yEv_calc.tolist(), '.', ms=ms_sz)  # Change ms
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color='pink')
        plt.xlabel('Experiment')
        plt.ylabel('Prediction')
        if grid_std:
            plt.title(
                '($r^2$, std) = ({0:.2e}, {1:.2e}), RMSE = {2:.2e}'.format(
                    r_sqr, grid_std, RMSE))
        else:
            plt.title('$r^2$ = {0:.2e}, RMSE = {1:.2e}'.format(r_sqr, RMSE))
        plt.show()
    return r_sqr, RMSE
Esempio n. 5
0
def _regress_show_r0( yEv, yEv_calc, disp = True, graph = True, plt_title = None):

    # if the output is a vector and the original is a metrix, 
    # the output is translated to a matrix. 
    if len( np.shape(yEv)) == 2 and len( np.shape(yEv_calc)) == 1:
        yEv_calc = np.mat( yEv_calc).T

    r_sqr, RMSE = kchem.estimate_accuracy( yEv, yEv_calc, disp = disp)
    if graph:
        plt.scatter( yEv.tolist(), yEv_calc.tolist())
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color = 'pink')
        plt.xlabel('Target')
        plt.ylabel('Prediction')
        if plt_title:
            plt.title( plt_title)
        plt.show()
    return r_sqr, RMSE
Esempio n. 6
0
def _regress_show_r0(yEv, yEv_calc, disp=True, graph=True, plt_title=None):

    # if the output is a vector and the original is a metrix,
    # the output is translated to a matrix.
    if len(np.shape(yEv)) == 2 and len(np.shape(yEv_calc)) == 1:
        yEv_calc = np.mat(yEv_calc).T

    r_sqr, RMSE = kchem.estimate_accuracy(yEv, yEv_calc, disp=disp)
    if graph:
        plt.scatter(yEv.tolist(), yEv_calc.tolist())
        ax = plt.gca()
        lims = [
            np.min([ax.get_xlim(), ax.get_ylim()]),  # min of both axes
            np.max([ax.get_xlim(), ax.get_ylim()]),  # max of both axes
        ]
        # now plot both limits against eachother
        #ax.plot(lims, lims, 'k-', alpha=0.75, zorder=0)
        ax.plot(lims, lims, '-', color='pink')
        plt.xlabel('Target')
        plt.ylabel('Prediction')
        if plt_title:
            plt.title(plt_title)
        plt.show()
    return r_sqr, RMSE