本文整理汇总了Python中util.Util.strings_to_classes方法的典型用法代码示例。如果您正苦于以下问题:Python Util.strings_to_classes方法的具体用法?Python Util.strings_to_classes怎么用?Python Util.strings_to_classes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.strings_to_classes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: int
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import strings_to_classes [as 别名]
vectorizers = [tfidf1]
tfidf = vectorizers[0]
#comment = 'lsa = 1, tfidf2, 175000 -> 1000'
comment = 'tfidf1, transition 75'
y = np.array(t.ix[:,4:])#[:,9:]
y_original = np.array(t.ix[:,4:])#[:,9:]
cv_split = 0.2
n = int(np.round(len(t['tweet'].tolist())))
train_end = int(np.round(n*(1-cv_split)))
cv_beginning = int(np.round( n*(1-cv_split if cv_split > 0 else 0.8)))
train = t['tweet'].tolist()[0:train_end]
cv_X_original = np.array(t['tweet'].tolist()[cv_beginning:])
cv_y = np.array(y[cv_beginning:])
c = u.strings_to_classes(t['state'])
if cv_split == 0:
train = t['tweet'].tolist()
else:
y = y[0:int(np.round(len(t['tweet'].tolist())*(1-cv_split)))]
prediction_grand_all = 0
predict_cv_grand_all = 0
list_predictions = []
list_predictions_test = []
for tfidf in vectorizers:
print 'fitting vectorizer...'
tfidf.fit(t['tweet'].tolist() + t2['tweet'].tolist())
print 'transforming train set...'
#train = tfidf.transform(train)
示例2:
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import strings_to_classes [as 别名]
sales = dict_sales[key][0]
if repair_key not in dict_repair:
dict_repair[repair_key] = [entry[-1],timespan.days,entry[0],entry[1],entry[2],entry[3],sales]
else:
dict_repair[repair_key][0] += entry[-1]
else:
error_count += 1
data = []
for value in dict_repair.values():
data.append([ele for ele in value])
X = np.array(data)
X = X[:,[0,1,2,3,6]]
fac1 = u.strings_to_classes(X[:,2])
fac2 = u.strings_to_classes(X[:,3])
t1 = u.create_t_matrix(fac1)
t2 = u.create_t_matrix(fac2)
X = np.hstack([np.float32(X[:,[0,1,4]]),t1,t2])
print X.shape
np.save('/home/tim/Downloads/repair/train.npy',X)
print 'Saved!'
#TODO: use util to create categories
#print(t1.ix[0:5,:])
#print(t2.ix[0:5,:])