support/parse_data.py
def NoisyOpt_isoBig():
    '''
    Data preparation routine for "noisy optimization" demo,
    where inputs are generated from a linear model with
    additive noise, such that the expected value of the
    squared loss of each is a known (and thus computable) risk
    function. The "iso**Big**" part means that the sample is
    rather large (and likely will be sub-sampled in practice).
    
    '''
    dataset = "NoisyOpt_isoBig"
    dinfo = classes.DataInfo()

    dinfo.X_te = None # since have risk oracle, only use training data.
    dinfo.y_te = None

    n = 50 # training set size
    d = 2 # number of inputs
    sigma_X = 1 # magnitude of input stdev
    sigma_noise = 3 # magnitude of noise stdev
    delta = sigma_noise * 5 # the amount of displacement of initial value
    dinfo.mname = "NoisyOpt" # hard-coded model name.
    dinfo.misc["cov_X"] = (sigma_X**2) * np.eye(d) # cov mtx of inputs
    dinfo.misc["sigma_noise"] = sigma_noise
    dinfo.misc["nsub"] = 5 # the size of random sub-samples to be used.

    # Hand-prepared data, used below.
    w_true = np.array([3.141592, 1.414214]).reshape((d,1))
    X_tr = np.random.normal(loc=0.0,
                            scale=sigma_X,
                            size=n*d).reshape((n,d))
    noise_tr = np.random.normal(loc=0.0,
                                scale=sigma_noise,
                                size=n).reshape((n,1))
    dinfo.misc["w_true"] = w_true # store the true model paras.
    dinfo.misc["w_init"] = w_true + delta # store a fixed initial value

    # Inputs
    towrite = os.path.join("data", dataset, ("X_tr" + ".dat"))
    data_arr = X_tr
    dinfo.X_tr["shape"] = data_arr.shape
    dinfo.X_tr["path"] = towrite
    dinfo.X_tr["dtype"] = data_arr.dtype
    with open(towrite, mode="bw") as g_bin:
        data_arr.tofile(g_bin)

    # Outputs
    towrite = os.path.join("data", dataset, ("y_tr" + ".dat"))
    data_arr = (np.dot(X_tr,w_true)+noise_tr).reshape((X_tr.shape[0],1))
    dinfo.y_tr["shape"] = data_arr.shape
    dinfo.y_tr["path"] = towrite
    dinfo.y_tr["dtype"] = data_arr.dtype
    with open(towrite, mode="bw") as g_bin:
        data_arr.tofile(g_bin)

    # Save the dinfo dictionary for future use (so we don't have to read
    # the original data every time).
    towrite = os.path.join("data", dataset, "info.dat")
    with open(towrite, mode="wb") as f:
        pickle.dump(dinfo, f)

    # Finally, return the dinfo dict.
    return dinfo

    Data preparation routine for "noisy optimization" demo,
    where inputs are generated from a linear model with
    additive noise, such that the expected value of the
    squared loss of each is a known (and thus computable) risk
    function. The "iso**Big**" part means that the sample is
    rather large (and likely will be sub-sampled in practice).
    
    
Data preparation routine for "noisy optimization" demo,
where inputs are generated from a linear model with
additive noise, such that the expected value of the
squared loss of each is a known (and thus computable) risk
function. The "iso**Big**" part means that the sample is
rather large (and likely will be sub-sampled in practice).
Data preparation routine for " noisy optimization " demo where inputs are generated from a linear model with additive noise such that the expected value of the squared loss of each is a known ( and thus computable ) risk function . The " iso ** Big ** " part means that the sample is rather large ( and likely will be sub - sampled in practice ) .
def NoisyOpt_isoBig():
    dataset = "NoisyOpt_isoBig"
    dinfo = classes.DataInfo()
    dinfo.X_te = None 
    dinfo.y_te = None
    n = 50 
    d = 2 
    sigma_X = 1 
    sigma_noise = 3 
    delta = sigma_noise * 5 
    dinfo.mname = "NoisyOpt" 
    dinfo.misc["cov_X"] = (sigma_X**2) * np.eye(d) 
    dinfo.misc["sigma_noise"] = sigma_noise
    dinfo.misc["nsub"] = 5 
    w_true = np.array([3.141592, 1.414214]).reshape((d,1))
    X_tr = np.random.normal(loc=0.0,
                            scale=sigma_X,
                            size=n*d).reshape((n,d))
    noise_tr = np.random.normal(loc=0.0,
                                scale=sigma_noise,
                                size=n).reshape((n,1))
    dinfo.misc["w_true"] = w_true 
    dinfo.misc["w_init"] = w_true + delta 
    towrite = os.path.join("data", dataset, ("X_tr" + ".dat"))
    data_arr = X_tr
    dinfo.X_tr["shape"] = data_arr.shape
    dinfo.X_tr["path"] = towrite
    dinfo.X_tr["dtype"] = data_arr.dtype
    with open(towrite, mode="bw") as g_bin:
        data_arr.tofile(g_bin)
    towrite = os.path.join("data", dataset, ("y_tr" + ".dat"))
    data_arr = (np.dot(X_tr,w_true)+noise_tr).reshape((X_tr.shape[0],1))
    dinfo.y_tr["shape"] = data_arr.shape
    dinfo.y_tr["path"] = towrite
    dinfo.y_tr["dtype"] = data_arr.dtype
    with open(towrite, mode="bw") as g_bin:
        data_arr.tofile(g_bin)
    towrite = os.path.join("data", dataset, "info.dat")
    with open(towrite, mode="wb") as f:
        pickle.dump(dinfo, f)
    return dinfo
def NoisyOpt_isoBig ( ) : dataset = "NoisyOpt_isoBig" dinfo = classes . DataInfo ( ) dinfo . X_te = None dinfo . y_te = None n = 50 d = 2 sigma_X = 1 sigma_noise = 3 delta = sigma_noise * 5 dinfo . mname = "NoisyOpt" dinfo . misc [ "cov_X" ] = ( sigma_X ** 2 ) * np . eye ( d ) dinfo . misc [ "sigma_noise" ] = sigma_noise dinfo . misc [ "nsub" ] = 5 w_true = np . array ( [ 3.141592 , 1.414214 ] ) . reshape ( ( d , 1 ) ) X_tr = np . random . normal ( loc = 0.0 , scale = sigma_X , size = n * d ) . reshape ( ( n , d ) ) noise_tr = np . random . normal ( loc = 0.0 , scale = sigma_noise , size = n ) . reshape ( ( n , 1 ) ) dinfo . misc [ "w_true" ] = w_true dinfo . misc [ "w_init" ] = w_true + delta towrite = os . path . join ( "data" , dataset , ( "X_tr" + ".dat" ) ) data_arr = X_tr dinfo . X_tr [ "shape" ] = data_arr . shape dinfo . X_tr [ "path" ] = towrite dinfo . X_tr [ "dtype" ] = data_arr . dtype with open ( towrite , mode = "bw" ) as g_bin : data_arr . tofile ( g_bin ) towrite = os . path . join ( "data" , dataset , ( "y_tr" + ".dat" ) ) data_arr = ( np . dot ( X_tr , w_true ) + noise_tr ) . reshape ( ( X_tr . shape [ 0 ] , 1 ) ) dinfo . y_tr [ "shape" ] = data_arr . shape dinfo . y_tr [ "path" ] = towrite dinfo . y_tr [ "dtype" ] = data_arr . dtype with open ( towrite , mode = "bw" ) as g_bin : data_arr . tofile ( g_bin ) towrite = os . path . join ( "data" , dataset , "info.dat" ) with open ( towrite , mode = "wb" ) as f : pickle . dump ( dinfo , f ) return dinfo
Data preparation routine for "noisy optimization" demo,
where inputs are generated from a linear model with
additive noise, such that the expected value of the
squared loss of each is a known (and thus computable) risk
function.
Data preparation routine for " noisy optimization " demo where inputs are generated from a linear model with additive noise such that the expected value of the squared loss of each is a known ( and thus computable ) risk function .
'''
    Data preparation routine for "noisy optimization" demo,
    where inputs are generated from a linear model with
    additive noise, such that the expected value of the
    squared loss of each is a known (and thus computable) risk
    function. The "iso**Big**" part means that the sample is
    rather large (and likely will be sub-sampled in practice).
    
    ''' # since have risk oracle, only use training data. # training set size # number of inputs # magnitude of input stdev # magnitude of noise stdev # the amount of displacement of initial value # hard-coded model name. # cov mtx of inputs # the size of random sub-samples to be used. # Hand-prepared data, used below. # store the true model paras. # store a fixed initial value # Inputs # Outputs # Save the dinfo dictionary for future use (so we don't have to read # the original data every time). # Finally, return the dinfo dict.