虽然libsvm提供了用于扩展数据的工具,但是使用Scikit-Learn(它应该基于用于SVC分类器的libSVM),我发现无法扩展我的数据.
基本上我想使用4个功能,其中3个范围从0到1,最后一个是"大"高度可变数字.
如果我在libSVM中包含第四个功能(使用自动扩展我的数据的easy.py脚本),我会得到一些非常好的结果(准确率为96%).如果我在Scikit-Learn中包含第四个变量,精度下降到~78% - 但如果我将其排除,我得到的结果与排除该功能时的libSVM相同.因此,我很确定这是一个缺少扩展的问题.
如何以编程方式(即不调用svm-scale)复制SVM的缩放过程?
有谁能解释我这种奇怪的行为?我希望两种替换方法可以同时工作或不工作.它只是我还是有人没有发现这是连贯的?
>>> u'è'.replace("\xe0","")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)
>>> re.sub(u'è','\xe0','',flags=re.UNICODE)
''
Run Code Online (Sandbox Code Playgroud)
(请注意,我不是要求解释为什么u'è'.replace("\ xe0","")引发错误!)
我有一些问题使这个自定义损失函数(它检查y_pred数据是否与 提供的实际排序索引一致y_true)工作:
def custom_objective(y_true, y_pred):
y_true = tf.cast(y_true, tf.float32)
ordered_output = tf.cast(tf.nn.top_k(-y_pred, k=5)[1], tf.float32)
return tf.sqrt(tf.reduce_mean(tf.square(ordered_output - y_true), axis=-1))
Run Code Online (Sandbox Code Playgroud)
我可以使用示例数据正确运行它:
with tf.Session() as sess:
print(custom_objective(tf.constant([0, 1, 2, 3, 4, 5]),
tf.constant([0.0, 0.9, 0.2, 0.3, 0.5, 0.8])).eval()) # 1.82574
Run Code Online (Sandbox Code Playgroud)
但不知何故,如果我在 中使用它就不起作用model.compile,因为它引发了:
/Users/luca/.virtualenvs/python3/lib/python3.6/site-packages/tensorflow/python/framework/tensor_util.py in make_tensor_proto(values, dtype, shape, verify_shape)
358 else:
359 if values is None:
--> 360 raise ValueError("None values not supported.")
361 # if dtype is provided, forces numpy array to be the type
362 …Run Code Online (Sandbox Code Playgroud)