当前位置: 首页>>代码示例>>Python>>正文


Python Data.partition方法代码示例

本文整理汇总了Python中Data.partition方法的典型用法代码示例。如果您正苦于以下问题:Python Data.partition方法的具体用法?Python Data.partition怎么用?Python Data.partition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data的用法示例。


在下文中一共展示了Data.partition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: hyper_search

# 需要导入模块: import Data [as 别名]
# 或者: from Data import partition [as 别名]
def hyper_search(X, y, X_dev=None, y_dev=None, ccc=False):
    if X_dev == None:
        dataset = Data.partition(X, y)
        X_train = dataset["X_train"]
        y_train = dataset["y_train"]
        X_dev = dataset["X_dev"]
        y_dev = dataset["y_dev"]
    else:
        X_train = X
        y_train = y
    # Find Optimal Hyperparameter Setting
    lam_arr = [0.01, 0.05, 0.1, 1, 10]
    a_arr = [0, 0.001, 0.01, 0.1, 0.5, 1]
    eta_arr = [0.01, 0.1, 0.3, 0.5, 0.7, 0.9, 1, 1.1]
    n_arr = [10, 20, 30, 50]
    var_prior_arr = [0.1, 0.5, 0.7, 1, 1.1, 1.5, 2]

    # lam_arr = [0.02,0.03,0.04]
    # a_arr = [0,0.01]
    # eta_arr = [0.0001]
    # n_arr = [50,100,150]
    # var_prior_arr = [0.1,3]

    best_ep = 1e6
    best_em = 1e6
    if ccc:
        best_ep = -1e6
        best_em = -1e6
    params = {}
    for lam in lam_arr:
        for n in n_arr:
            ###############################FOR EP################################################
            for var_prior in var_prior_arr:
                err = ep_run(X_train, y_train, X_dev, y_dev, n, lam=lam, var_prior=var_prior, ccc=ccc)

                if (ccc and err > best_ep) or (not ccc and err < best_ep):
                    best_ep = err
                    params["lam"] = lam
                    params["n"] = n
                    params["var_prior"] = var_prior
            ###############################FOR EM################################################
            for eta in eta_arr:
                for a in a_arr:
                    err = em_run(X_train, y_train, X_dev, y_dev, n, lam=lam, eta=eta, a=a, ccc=ccc)
                    if (ccc and err > best_em) or (not ccc and err < best_em):
                        best_em = err
                        params["lam_em"] = lam
                        params["n_em"] = n
                        params["eta"] = eta
                        params["a"] = a
            # print params
    print "best EP error: " + str(best_ep)
    print "best EM error: " + str(best_em)
    print "best params"
    print params
开发者ID:jshe857,项目名称:thesis-rbfnn,代码行数:57,代码来源:hyperparameter.py

示例2: range

# 需要导入模块: import Data [as 别名]
# 或者: from Data import partition [as 别名]
###################### We load the word music dataset ###############################
# csv = np.genfromtxt ('music.csv', delimiter=",",skip_header=1)
# X = csv[ :, range(csv.shape[ 1 ] - 2) ]
# y = csv[ :, csv.shape[ 1 ] - 1 ]

#config.profile=True

################### We load power dataset ######################################
csv = np.genfromtxt ('power.csv', delimiter=",",skip_header=1)
X = csv[ 1:100, range(csv.shape[ 1 ] - 1) ]
y = csv[ 1:100, csv.shape[ 1 ] - 1 ]




dataset = Data.partition(X,y)
X_train = np.append(dataset['X_train'],dataset['X_dev'],axis=0)
y_train = np.append(dataset['y_train'],dataset['y_dev'],axis=0)
X_test = dataset['X_test']
y_test = dataset['y_test']
result = {'ep_train':0,'ep_test':0,
        'em_train':0,'em_test':0,'svr':0}

for s in range(9):
# Find Optimal Hyperparameter Setting
    np.random.seed(s)
    r = EP_run.ep_run(X_train,y_train,X_test,y_test,n,lam=lam,var_prior=var_prior) 
    result['ep_train'] += r['train']
    result['ep_test'] += r['test']
    r = EM_run.em_run(X_train,y_train,X_test,y_test,n,lam=lam_em,eta=eta,a=a) 
    result['em_train'] += r['train']
开发者ID:jshe857,项目名称:thesis-rbfnn,代码行数:33,代码来源:test_runner.py


注:本文中的Data.partition方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。