Example #1
0
def _pdi_gs_full_r1(method,
                    xM_l,
                    yV,
                    X_concat=None,
                    mode="Ridge",
                    expension=False,
                    n_folds=20,
                    alphas_log=(-3, 2, (2 - (-3)) * 2 + 1)):
    if mode == "Ridge":
        xM = np.concatenate(xM_l, axis=1)
        gs = jgrid.gs_Ridge(xM, yV, alphas_log, n_folds=n_folds)
    elif mode == "BIKE_Ridge":
        # print "BIKE_Ridge mode is working now."
        A_l = xM_l
        gs = jgrid.gs_BIKE_Ridge(A_l,
                                 yV,
                                 alphas_log=alphas_log,
                                 X_concat=X_concat,
                                 n_folds=n_folds)
    else:
        print("Mode {} is not supported.".format(mode))
    # gs.grid_scores_

    if expension:
        pdi = pdi_gs(method, gs.grid_scores_, expension=expension)
    else:
        pdi = pdi_gs(method, gs.grid_scores_)
        pdi.plot(kind='line',
                 x='alpha',
                 y='mean(r2)',
                 yerr='std(r2)',
                 logx=True)
        plt.ylabel(r"E[$r^2$]")

    return pdi
Example #2
0
def grid_BIKE2(pdr, alphas_log, y_id = 'Solubility_log_mol_l'):
	print "BIKE with (A+B)+W"

	xM1 = jpd.pd_get_xM( pdr, radius=6, nBits=4096)
	xM2 = jpd.pd_get_xM_MACCSkeys( pdr)

	yV = jpd.pd_get_yV( pdr, y_id = y_id)

	#A1 = jpyx.calc_tm_sim_M( xM1)
	#A2 = jpyx.calc_tm_sim_M( xM2)
	#A = np.concatenate( ( A1, A2), axis = 1)
	xM = np.concatenate( ( xM1, xM2), axis = 1)
	A = jpyx.calc_tm_sim_M( xM1)
	print A.shape

	molw_l = jchem.rdkit_molwt( pdr.SMILES.tolist())
	print np.shape( molw_l)
	A_molw = jchem.add_new_descriptor( A, molw_l)
	print A_molw.shape

	gs = jgrid.gs_Ridge( A_molw, yV, alphas_log=alphas_log)
	jutil.show_gs_alpha( gs.grid_scores_)
	
	jgrid.cv( 'Ridge', A_molw, yV, alpha = gs.best_params_['alpha'])
	
	return gs
Example #3
0
def set_pdi_d_full(pdi_d, method, xM_l, yV):
    xM = np.concatenate(xM_l, axis = 1)
    gs = jgrid.gs_Ridge(xM, yV, (-3, 2, 10), n_folds=20)
    # gs.grid_scores_

    set_pdi_d(pdi_d, method, gs.grid_scores_)
    pdi_d[ method].plot(kind ='line', x='alpha', y='mean(r2)', yerr='std(r2)', logx=True)
    plt.ylabel(r"E[$r^2$]")

    return pdi_d[method]
Example #4
0
def _pdi_gs_full_r0( method, xM_l, yV, expension = False):
    xM = np.concatenate( xM_l, axis = 1)
    gs = jgrid.gs_Ridge( xM, yV, (-3, 2, 10), n_folds=20)
    # gs.grid_scores_

    if expension:
        pdi = pdi_gs( method, gs.grid_scores_, expension = expension)
    else:
        pdi = pdi_gs( pdi_d, method, gs.grid_scores_)
        pdi.plot( kind ='line', x = 'alpha', y = 'mean(r2)', yerr = 'std(r2)', logx = True)
        plt.ylabel( r"E[$r^2$]")

    return pdi
Example #5
0
def grid_MLR_B(pdr, alphas_log, y_id = 'Solubility_log_mol_l'):
	print "MLR with B"

	xM2 = jpd.pd_get_xM_MACCSkeys( pdr)

	xM_molw = xM2
	yV = jpd.pd_get_yV( pdr, y_id = y_id)

	gs = jgrid.gs_Ridge( xM_molw, yV, alphas_log=alphas_log)
	jutil.show_gs_alpha( gs.grid_scores_)
	
	jgrid.cv( 'Ridge', xM_molw, yV, alpha = gs.best_params_['alpha'])
	
	return gs
Example #6
0
def grid_MLR_A(pdr, alphas_log, y_id = 'Solubility_log_mol_l'):
	print "MLR with A"

	xM1 = jpd.pd_get_xM( pdr, radius=6, nBits=4096)

	xM_molw = xM1
	yV = jpd.pd_get_yV( pdr, y_id = y_id)

	gs = jgrid.gs_Ridge( xM_molw, yV, alphas_log=alphas_log)
	jutil.show_gs_alpha( gs.grid_scores_)
	
	jgrid.cv( 'Ridge', xM_molw, yV, alpha = gs.best_params_['alpha'])
	
	return gs
Example #7
0
def set_pdi_d_full(pdi_d, method, xM_l, yV):
    xM = np.concatenate(xM_l, axis=1)
    gs = jgrid.gs_Ridge(xM, yV, (-3, 2, 10), n_folds=20)
    # gs.grid_scores_

    set_pdi_d(pdi_d, method, gs.grid_scores_)
    pdi_d[method].plot(kind='line',
                       x='alpha',
                       y='mean(r2)',
                       yerr='std(r2)',
                       logx=True)
    plt.ylabel(r"E[$r^2$]")

    return pdi_d[method]
Example #8
0
def _pdi_gs_full_r0(method, xM_l, yV, expension=False):
    xM = np.concatenate(xM_l, axis=1)
    gs = jgrid.gs_Ridge(xM, yV, (-3, 2, 10), n_folds=20)
    # gs.grid_scores_

    if expension:
        pdi = pdi_gs(method, gs.grid_scores_, expension=expension)
    else:
        pdi = pdi_gs(pdi_d, method, gs.grid_scores_)
        pdi.plot(kind='line',
                 x='alpha',
                 y='mean(r2)',
                 yerr='std(r2)',
                 logx=True)
        plt.ylabel(r"E[$r^2$]")

    return pdi
Example #9
0
def _pdi_gs_full_r0( method, xM_l, yV, X_concat = None, mode = "Ridge", expension = False, n_folds=20):
    if mode == "Ridge":
        xM = np.concatenate( xM_l, axis = 1)
        gs = jgrid.gs_Ridge( xM, yV, (-3, 2, 12), n_folds=n_folds)
    elif mode == "BIKE_Ridge":
        # print "BIKE_Ridge mode is working now."
        A_l = xM_l
        gs = jgrid.gs_BIKE_Ridge( A_l, yV, alphas_log=(-3, 2, 12), X_concat = X_concat, n_folds=n_folds)
    else:
        print("Mode {} is not supported.".format( mode))
    # gs.grid_scores_

    if expension:
        pdi = pdi_gs( method, gs.grid_scores_, expension = expension)
    else:
        pdi = pdi_gs( method, gs.grid_scores_)
        pdi.plot( kind ='line', x = 'alpha', y = 'mean(r2)', yerr = 'std(r2)', logx = True)
        plt.ylabel( r"E[$r^2$]")

    return pdi