本文整理汇总了Python中sklearn.preprocessing.normalize函数的典型用法代码示例。如果您正苦于以下问题:Python normalize函数的具体用法?Python normalize怎么用?Python normalize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了normalize函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, hps, example_list, dqn_batch_size, use_state_prime = False, max_art_oovs = 0):
"""
Args:
hps: seq2seq model parameters
example_list: list of experiences
dqn_batch_size: DDQN batch size
use_state_prime: whether to use the next decoder state to make the batch or the current one
max_art_oovs: number of OOV tokens in current batch
Properties:
_x: The input to DDQN model for training, this is basically the decoder output (dqn_batch_size, dqn_input_feature_len)
_y: The Q-estimation (dqn_batch_size, vocab_size)
_y_extended: The Q-estimation (dqn_batch_size, vocab_size + max_art_oovs)
"""
self._x = np.zeros((dqn_batch_size, hps.dqn_input_feature_len))
self._y = np.zeros((dqn_batch_size, hps.vocab_size))
self._y_extended = np.zeros((dqn_batch_size, hps.vocab_size + max_art_oovs))
for i,e in enumerate(example_list):
if use_state_prime:
self._x[i,:]=e.state_prime
else:
self._x[i,:]=e.state
self._y[i,:]=normalize([e.q_value[0:hps.vocab_size]], axis=1, norm='l1')
if max_art_oovs == 0:
self._y_extended[i,:] = normalize([e.q_value[0:hps.vocab_size]], axis=1, norm='l1')
else:
self._y_extended[i,:] = e.q_value
开发者ID:sra4077,项目名称:RLSeq2Seq,代码行数:27,代码来源:replay_buffer.py
示例2: split_and_build_class
def split_and_build_class(X, y):
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
print X_train.shape
print X_test.shape
# Normalize the input data.
imp = preprocessing.Imputer(missing_values='NaN', strategy='mean', axis=0)
fixed_X_train = X_train[:, 1:]
imp.fit(fixed_X_train)
fixed_X_train = imp.transform(fixed_X_train)
preprocessing.normalize(fixed_X_train, copy=False)
X_train[:, 1:] = fixed_X_train
fixed_X_test = X_test[:, 1:]
imp.fit(fixed_X_test)
fixed_X_test = imp.transform(fixed_X_test)
preprocessing.normalize(fixed_X_test, copy=False)
X_test[:, 1:] = fixed_X_test
train_data = read_dataset.microData()
train_data.get_data(X_train)
y_train = train_data.set_output(y_train)
test_data = read_dataset.microData()
test_data.get_data(X_test)
y_test = test_data.set_output(y_test)
return [X_train, X_test, y_train, y_test, train_data, test_data]
开发者ID:Shauro,项目名称:From-Fog-Nets-to-Neural-Nets,代码行数:27,代码来源:cross_validation_random_forest_regressor.py
示例3: func
def func(A, B): # comparematrices(A,B):
colA = A.shape[1]
colB = B.shape[1]
# method 1 - n is small dim, m is larger, matnew is new comparison matrix
if colA == colB and colA != 1:
Aprime = normalize(A, axis=1, norm='l2')
Bprime = normalize(B, axis=1, norm='l2')
if colA == 1:
dist = np.linalg.norm(Aprime - Bprime) # L2 norm (vectors)
else:
dist = np.linalg.norm(Aprime - Bprime, 2) # Frobenius norm (matrices)
else:
if colA < colB:
n = colA
m = colB
big = B
small = A
else:
n = colB
m = colA
big = A
small = B
matnew = np.identity(m)
matnew[0:n, 0:n] = small
bigprime = normalize(big, axis=1, norm='l2')
matnewprime = normalize(matnew, axis=1, norm='l2')
dist = np.linalg.norm(matnewprime - bigprime, 2)
print dist
开发者ID:ethman,项目名称:prediction,代码行数:30,代码来源:driver1.py
示例4: normalize
def normalize(self):
"""
impute
"""
print('Normalization')
self.tr = normalize(self.tr)
self.te = normalize(self.te)
开发者ID:Hossein-Noroozpour,项目名称:PyHDM,代码行数:7,代码来源:HDataManager.py
示例5: read_dataset
def read_dataset(train_size, scale=False, normalize=False):
logging.info('fetching the dataset')
#
d = sklearn.datasets.load_diabetes() # 糖尿病
#d = sklearn.datasets.load_boston() # ボストン住宅価格
#
data = d['data'].astype(np.float32)
target = d['target'].astype(np.float32).reshape(len(d['target']), 1)
#"Chainerのmnist.pyだと下記ののような書き方になっているが、ミニバッチの数が2以上だと動かない"らしい
#target = diabetes['target'].astype(np.float32)
# 本来訓練データで標準化・正規化して、そのパラメータをテストデータに適用すべき
if normalize and scale:
raise Exception('both normalize and scale can not be True')
if normalize:
data = preprocessing.normalize(data)
target = preprocessing.normalize(target)
if scale:
data = preprocessing.scale(data)
target = preprocessing.scale(target)
# 分割
x_train, x_test = np.split(data, [train_size])
y_train, y_test = np.split(target, [train_size])
assert len(x_train)==len(y_train)
assert len(x_test)==len(y_test)
return ((x_train, y_train), (x_test, y_test),
{"SHAPE_TRAIN_X":x_train.shape,
"SHAPE_TRAIN_Y":y_train.shape,
"SHAPE_TEST_X":x_test.shape,
"SHAPE_TEST_Y":y_test.shape,
})
开发者ID:fanannan,项目名称:chainer-regressor,代码行数:30,代码来源:reader.py
示例6: remove_outliers
def remove_outliers(image,mask):
#taking the mask part to image to check the presence of bee
im = cv2.bitwise_and(image,image,mask=mask);
ldp_image,_,_ = ldp.ldp(im);
test_Y = ldp_image.reshape((ldp_image.shape[0] * ldp_image.shape[1], ldp_image.shape[2]));
test_rgb = im.reshape((im.shape[0] * im.shape[1], im.shape[2]));
test = np.concatenate((test_Y,test_rgb),axis=1);
mask_not = cv2.bitwise_not(mask);
ret1, mask_not = cv2.threshold (mask_not,np.mean(mask_not), 255, cv2.THRESH_BINARY);
im = cv2.bitwise_and(image,image,mask=mask_not);
ldp_image,_,_ = ldp.ldp(im);
data_ldp = ldp_image.reshape((ldp_image.shape[0] * ldp_image.shape[1], ldp_image.shape[2]));
data_rgb = im.reshape((im.shape[0] * im.shape[1], im.shape[2]));
data = np.concatenate((data_rgb,data_ldp),axis=1);
data = data[np.any(data!=0,axis=1)];
print data.shape;
data = data.astype('float64');
data = preprocessing.normalize(data,axis=0);
ss = StandardScaler();
data = ss.fit_transform(data);
clf = svm.OneClassSVM(nu=0.8, kernel="rbf", gamma=0.1)
clf.fit(data);
test = test.astype('float64');
test = preprocessing.normalize(test,axis=0);
print test.shape;
test = ss.fit_transform(test);
test = clf.predict(test);
test = test.reshape((image.shape[0] , image.shape[1]));
test[test==-1] = 0;
test[test==1] = 255;
test = test.astype('uint8');
im = cv2.bitwise_and(image,image,mask=test);
im = cv2.bitwise_and(im,im,mask=mask);
#print test[:,0],test[:,1];
return(im,test);
开发者ID:sai19,项目名称:Bee_image_classification,代码行数:35,代码来源:bee_preprocess.py
示例7: normaliser
def normaliser(x, option):
# normalize by the norm
if option == 'norm':
# print 'normalize by the norm or the row'
from sklearn.preprocessing import normalize
x_norma = normalize(x, norm='l2')
# normalize by the sum of the row, ( normalized matrix sum to 1 )
elif option == 'sum': # normalize sum to 1:
#print('normalize by the sum of the row')
from sklearn.preprocessing import normalize
x_norma = normalize(x, norm='l1')
# normalize each row by z-score : (x-mean)/std
elif option == 'zscore':
from scipy import stats
x_norma = stats.zscore(x, axis=1)
# set the nan to 0
x_norma[np.isnan(x_norma)] = 0
elif option == 'none':
# print ('no normalization')
x_norma = x
return x_norma
开发者ID:chao11,项目名称:stageINT,代码行数:25,代码来源:LOSO_RL_loopsubject.py
示例8: getData_NEC
def getData_NEC():
reader = JobDBCorpus()
data = reader.read_sequence_list(target='TODO')
np.seterr(all='ignore')
train, test = reader.train_test_data(test_size=0.2)
print("Reading chunks...")
chunks_train = ChunkSet(dataset=train)
chunks_test = ChunkSet(dataset=test)
print("Building features...")
idf = featNEC.IDFeatures(dataset=train, chunkset=chunks_train)
idf.build_features()
###############################################################################
print("Standarizing dataset...")
X_train, Y_train = getStandart(chunks_train, idf)
X_test, Y_test = getStandart(chunks_test, idf)
# sparse representation and normalize
X_train = sparse.csr_matrix(X_train)
X_train = normalize(X_train, copy=False)
X_test = sparse.csr_matrix(X_test)
X_test = normalize(X_test, copy=False)
return X_train, Y_train, X_test, Y_test, chunks_train
开发者ID:ronaldahmed,项目名称:labor-market-demand-analysis,代码行数:28,代码来源:utils.py
示例9: rwr
def rwr(transition,PT,r=0.7):
"""
:param transition: Get the spare Transition matrix
:param PT: Intialization Vector
:param r: restart probability
:return: Numpy Matrix of predicted scores
"""
#Stop criteria
stop = 1e-07
PO = PT
Tr = transition
while True:
PX = (1-r)* Tr.T * PT + (r * PO)
delta = spnorm(PX) - spnorm(PT)
if delta < stop :
break
PT = PX
#fMat = normalize(PT, norm='l1', axis=0)
OM = PT[0:5080]
OM = normalize(OM, norm='l1', axis=0)
PP = PT[5080:15078]
PP = normalize(PP, norm='l1', axis=0)
CP = PT[15078:16904]
CP = normalize(CP, norm='l1', axis=0)
PAT = PT[16904:19435]
PAT = normalize(PAT, norm='l1', axis=0)
P = np.concatenate((OM,PP,CP,PAT),axis=0)
return P
开发者ID:abhik1368,项目名称:diseasepathway_prediction,代码行数:34,代码来源:computeRwr.py
示例10: SVM_vary_train
def SVM_vary_train(train_images, train_labels, test_images, test_labels, kernel_type, tune1, tune2, tune3, train_amm):
# reshape the training/testing data into a classifiable form
train_data_mat = np.reshape(train_images, (train_images.shape[0]*train_images.shape[1],train_images.shape[3]))
test_data_mat = np.reshape(test_images, (test_images.shape[0]*test_images.shape[1],test_images.shape[3]))
train_data_mat = 1.0*np.array(np.mat(train_data_mat).transpose())
test_data_mat = 1.0*np.array(np.mat(test_data_mat).transpose())
# normalize the data
train_data_mat = preprocessing.normalize(train_data_mat, norm='l2')
test_data_mat = preprocessing.normalize(test_data_mat, norm='l2')
if kernel_type is "linear":
classif_1vr = svm.SVC(kernel=kernel_type, C=tune1)
elif kernel_type is "rbf":
classif_1vr = svm.SVC(kernel=kernel_type, gamma=tune1)
elif kernel_type is "sigmoid":
classif_1vr = svm.SVC(kernel=kernel_type, gamma=tune1, coef0=tune2)
elif kernel_type is "poly":
classif_1vr = svm.SVC(kernel=kernel_type, gamma=tune1, coef0=tune2, degree=tune3)
# fit the SVM to the training set
classif_1vr.fit(train_data_mat[0:train_amm,:], train_labels[0][0:train_amm])
targets = test_labels[0]
# make prediction on the test data set
predict = classif_1vr.predict(test_data_mat)
# calculate the accuracy
acc = calc_acc(targets, predict)
return "kernel=" + str(kernel_type) + ", tune1=" + str(tune1) + ", tune2=" + str(tune2) + ", tune3=" + str(tune3) + ", train_amm=" + str(train_amm) + ", acc: " + str(acc) + "\n"
开发者ID:SiaJAT,项目名称:cs391L,代码行数:34,代码来源:pca_svm.py
示例11: classify
def classify(data_trn,lbl_trn,data_vld,lbl_vld,data_tst,lbl_tst):
data_trn = normalize(data_trn,copy=False)
data_vld = normalize(data_vld,copy=False)
data_tst = normalize(data_tst,copy=False)
# accuracy metric
metric_obj = mean_squared_error
'''
Train our model to predict labels for the dataset #1
'''
parameters = {'svr__gamma': 1.5, 'svr__probability': False, 'svr__epsilon': 0.4, 'svr__C': 1, 'svr__kernel': 'rbf'}
cls = Pipeline([
#('feature_selection',LinearSVC()),
('svr', SVR())
])
cls.set_params(**parameters)
cls.fit(data_trn, lbl_trn)
pred_vld = cls.predict(data_vld)
pred_tst = cls.predict(data_tst)
print ("Score for vld: %.6f" % (metric_obj(lbl_vld, pred_vld),))
print ("Score for tst: %.6f" % (metric_obj(lbl_tst, pred_tst),))
return pred_vld,pred_tst
开发者ID:brat000012001,项目名称:DUMLS14,代码行数:28,代码来源:pred_final_ds3.py
示例12: PCA_SVM
def PCA_SVM(train_images, train_labels, test_images, test_labels, kernel_type, do_PCA, comps):
# reshape the training/testing data into a classifiable form
train_data_mat = np.reshape(train_images, (train_images.shape[0]*train_images.shape[1],train_images.shape[3]))
test_data_mat = np.reshape(test_images, (test_images.shape[0]*test_images.shape[1],test_images.shape[3]))
train_data_mat = np.array(np.mat(train_data_mat).transpose())
test_data_mat = np.array(np.mat(test_data_mat).transpose())
# normalize the data
train_data_mat = preprocessing.normalize(train_data_mat, norm='l2')
test_data_mat = preprocessing.normalize(test_data_mat, norm='l2')
# do PCA if necessary
if do_PCA:
# learn the covariance
pca = PCA(n_components=comps, whiten=True)
pca.fit(train_data_mat)
# use pca to reduce dimensionality of training data
train_data_mat = pca.transform(train_data_mat)
test_data_mat = pca.transform(test_data_mat)
# fit svm to pca-reduced
classif_1vr = svm.SVC(kernel=kernel_type)
classif_1vr.fit(train_data_mat, train_labels[0])
targets = test_labels[0]
# make prediction on the test data set
predict = classif_1vr.predict(test_data_mat)
# calculate the accuracy
acc = calc_acc(targets, predict)
return "PCA=" + str(do_PCA) + ", num_comps= " + str(comps) + ", kernel=" + str(kernel_type) + ", acc: " + str(acc) + "\n"
开发者ID:SiaJAT,项目名称:cs391L,代码行数:35,代码来源:pca_svm.py
示例13: get_vector_sp
def get_vector_sp(model, x_data, x_test):
tmp_x = x_data[:, x_data.shape[1]-16:x_data.shape[1]-1]
tmp_x = tmp_x.reshape(tmp_x.shape[0], tmp_x.shape[1])
tmp_x = tmp_x/tmp_x[:,0].reshape(tmp_x.shape[0],1)
#tmp_x[:,1:] = tmp_x[:,1:] / tmp_x[:,0:tmp_x.shape[1]-1]
tmp_x = preprocessing.normalize(tmp_x, norm='l2')
preds = model.predict_proba(tmp_x.reshape(x_data.shape[0],15,1))
test_x = x_test[:, x_test.shape[1]-16:x_test.shape[1]-1]
test_x = test_x.reshape(test_x.shape[0], test_x.shape[1])
test_x = test_x/test_x[0][0]
test_x = preprocessing.normalize(test_x, norm='l2')
pred_test = model.predict_proba(test_x.reshape(test_x.shape[0],15,1))
x_result = numpy.hstack((x_data.reshape(x_data.shape[0], x_data.shape[1]), preds))
x_result_test = numpy.hstack((x_test.reshape(x_test.shape[0], x_test.shape[1]), pred_test))
test_bdate = x_test[0][1]
tmp_list = []
tmp_vec = x_result_test[0][x_result_test.shape[1]-20:]
i = 0
for m in x_result:
i = i + 1
dist = numpy.sqrt(numpy.sum(numpy.square(m[m.shape[0]-20:]- pred_test[0])))
tmp_list.append((m[1], dist))
sort_list = sorted(tmp_list, key = lambda x:x[1], reverse =False)
return sort_list, test_bdate
开发者ID:hongbin0908,项目名称:pytrade,代码行数:27,代码来源:process_rnn_with_select.py
示例14: getData_NEC
def getData_NEC(test=0.2, val=0.2, mode='by_sent',target='TODO'):
print("Reading data...")
train,test,val = getData(test=test, val=val, mode=mode,target=target)
print("Reading chunks...")
chunks_train = ChunkSet(dataset=train)
chunks_test = ChunkSet(dataset=test)
print("Building features...")
idf = featNEC.IDFeatures(dataset = train, chunkset = chunks_train)
idf.build_features()
###############################################################################
print("Standarizing dataset...")
X_train,Y_train = getStandart(chunks_train, idf)
X_test,Y_test = getStandart(chunks_test, idf)
# sparse representation and normalize
X_train = sparse.csr_matrix(X_train)
X_train = normalize(X_train, copy = False)
X_test = sparse.csr_matrix(X_test)
X_test = normalize(X_test, copy = False)
return X_train,Y_train,X_test,Y_test, chunks_train
开发者ID:ronaldahmed,项目名称:labor-market-demand-analysis,代码行数:25,代码来源:utils_new.py
示例15: rw_overlap_kernel
def rw_overlap_kernel(C1, C2):
#l = 1.0/np.exp(1.0)
l = 0.5
k = 0
c = 0
# reshape rows into kernel matrices
M1 = np.reshape(C1, (90, 90))
M2 = np.reshape(C2, (90, 90))
# normalise so rows sum to 1
M1_norm = normalize(M1, axis=1, norm='l1')
M2_norm = normalize(M2, axis=1, norm='l1')
for i in range(1, 101) :
M1_exp = np.linalg.matrix_power(M1_norm, i)
M2_exp = np.linalg.matrix_power(M2_norm, i)
#overlap = np.sum(np.minimum(M1_exp, M2_exp))
overlap = np.sum(np.sqrt(np.multiply(M1_exp, M2_exp)))
#k = k + ((np.exp(-i) ) * overlap)
#c = c + ((np.exp(-i)) * 90)
k = k + ((l ** i) * overlap)
c = c + ((l ** i) * 90)
return k/c
开发者ID:jmyoung36,项目名称:basic_connectivity,代码行数:31,代码来源:make_rw_overlap_kernel.py
示例16: difference_vectors
def difference_vectors(X, cluster_predictions, clusters_centers):
PC = X.shape[1]
K = len(clusters_centers)
u_k = {}
num_frms = X.shape[0]
for frm in range(num_frms):
frm_NN_cluster = cluster_predictions[frm]
c = clusters_centers[frm_NN_cluster]
diff = X[frm] - c
if frm_NN_cluster not in u_k:
u_k[frm_NN_cluster] = diff
else:
sum_k = u_k[frm_NN_cluster]
sum_k += diff
u_k[frm_NN_cluster] = sum_k
vlad = u_k[0]
vlad = vlad.reshape(1, vlad.shape[0])
for k in range(1, K):
K_cluster = u_k[k]
K_cluster = K_cluster.reshape(1, K_cluster.shape[0])
# Intra Normalization
K_cluster = preprocessing.normalize(K_cluster, norm = 'l2')
vlad = np.concatenate((vlad, K_cluster), axis = 1)
# L2 Normalization
vlad = preprocessing.normalize(vlad, norm = 'l2')
return vlad
开发者ID:BerkeleyAutomation,项目名称:tsc-dl,代码行数:28,代码来源:encoding.py
示例17: relational_retrofit
def relational_retrofit(word_vecs, sparse_relations, iterations=5, verbose=True, orig_weight=1):
orig_vecs = normalize(word_vecs, norm='l2', copy=False)
orig_vecs *= orig_weight
arbitrary_value = next(iter(sparse_relations.values()))
M, k = orig_vecs.shape
N = arbitrary_value.shape[0]
vecs = np.zeros(shape=(N, k), dtype='f')
vecs[:M] = orig_vecs
sparse_list = sorted(sparse_relations.items(), key=itemgetter(0))
for iteration in range(iterations):
rel_array = dense_relation_array(word_vecs, sparse_relations)
next_vecs = np.zeros(shape=vecs.shape, dtype='f')
for i in range(len(sparse_list)):
name = sparse_list[i][0]
if verbose:
print('Iteration %d of %d: %s' % (iteration + 1, iterations, name))
sparse = sparse_list[i][1]
dense = rel_array[i]
next_vecs += sparse.dot(vecs.dot(dense.T))
normalize(next_vecs, norm='l2', copy=False)
next_vecs[:M] += orig_vecs
next_vecs[:M] /= 1+orig_weight
vecs = next_vecs
del next_vecs
return vecs
开发者ID:AmitShah,项目名称:conceptnet-numberbatch,代码行数:30,代码来源:retrofit.py
示例18: classify
def classify(df):
print type(df)
df = preprocessing.normalize(df.ix[:,[1,2,3]], norm="l2")
print df
print type(df)
#load dataset
dataset_train = pd.read_csv("training.csv",delimiter=",")
X = dataset_train.ix[:,[0,1,2]]
X = X.as_matrix()
X = preprocessing.normalize(X,norm="l2")
print X
print type(X)
#X_normalised = preprocessing.normalize(X,norm="l2")
#ground truth
y = dataset_train.ix[:,[3]]
y = y.as_matrix()
y = y.ravel()
print y
print type(y)
#y = y.reshape((len(y),))
n_neighbors = 3
#create an instance of Neighbours Classifier and fit the data.
knn = neighbors.KNeighborsClassifier(n_neighbors)
knn.fit(X, y)
#print df[:,0:4]
return knn.predict(df[:,0:4])
开发者ID:sb1989,项目名称:fyp,代码行数:27,代码来源:ClassifierCountNormalized2.py
示例19: make_clouds
def make_clouds(files, n_words=20):
# set locations
base_model_name = os.path.splitext(os.path.basename(files.model))[0]
output_d = '../browser/clouds/' + base_model_name + '/'
if not os.path.exists(output_d):
os.makedirs(output_d)
# create wordcloud generator
wc = WordCloud(width=1000, height=500, background_color='white')
print('Loading model')
model = LdaModel.load(files.model)
beta = model.expElogbeta
print('Normalizing by topics, and by words')
pTW = normalize(beta, axis=0)
pWT = normalize(beta, axis=1)
# load bug<->id map, then invert to id<-> bug
bug_to_id = json.loads(open(files.replacements).read())
id_to_bug = {v: k for k, v in bug_to_id.items() if "." not in k}
for i in range(len(beta)):
# compute RAR
t_rar = np.sqrt(pTW[i] * pWT[i])
top_word_ids = t_rar.argsort()[:-1 - n_words:-1]
top_words = [model.id2word.id2token[wordid] for wordid in top_word_ids]
top_words = [id_to_bug[word] if word in id_to_bug else word for word in top_words]
wc.fit_words(zip(top_words, t_rar[top_word_ids]))
wc.to_file(output_d + str(i) + '.png')
开发者ID:knights-lab,项目名称:bugbrowser,代码行数:29,代码来源:make_clouds.py
示例20: _construct_edge_pairs
def _construct_edge_pairs(data, norm='l2', power_norm=True, dtype=np.float32):
"""
A tree is a list of edges, with each edge as the concatenation of the repr. of parent and child nodes.
:param data:
:return root, edges:
"""
r = data['tree'][1].astype(dtype=dtype)
if power_norm:
r = np.sign(r) * np.sqrt(np.abs(r))
r = preprocessing.normalize(r[np.newaxis,:], norm=norm)
root = [np.squeeze(r), ]
edges = []
for id in data['tree'].keys():
if id > 1:
x_left = data['tree'][id].astype('float32')
x_right = data['tree'][int(id/2.)].astype('float32')
e = np.concatenate([x_left,x_right])
if power_norm:
e = np.sign(e) * np.sqrt(np.abs(e))
e = preprocessing.normalize(e[np.newaxis,:], norm=norm)
# if power_norm:
# x_left = np.sign(x_left) * np.sqrt(np.abs(x_left))
# x_right = np.sign(x_right) * np.sqrt(np.abs(x_right))
#
# e = (preprocessing.normalize(x_left[np.newaxis,:], norm=norm), preprocessing.normalize(x_right[np.newaxis,:], norm=norm) )
e = np.hstack(e)
edges.append([np.squeeze(e),])
return root, edges
开发者ID:aclapes,项目名称:darwintree,代码行数:34,代码来源:kernels.py
注:本文中的sklearn.preprocessing.normalize函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论