小编mal*_*sit的帖子

PostgreSQL从过去12小时内获取物品

我有以下查询来获取我想要的PHP文件,它除了WHERE部分之外它的工作.我需要获取date_time1最近12小时列的项目.

SELECT p.*, t.* 
FROM posts AS p 
LEFT JOIN posted_tweets AS t 
ON p.a_id = t.p_id
WHERE p.date_time1 >= now() AND t.date_time =
( 
    SELECT MAX(date_time) 
    FROM posted_tweets AS t2 
    WHERE t2.p_id = t.p_id
)
    OR t.date_time IS NULL 
Run Code Online (Sandbox Code Playgroud)

我应该如何编辑p.date_time1 >= now()零件以实现我的目标?谢谢.

php postgresql

12
推荐指数
1
解决办法
6285
查看次数

Scikit-Learn:标签不是x出现在所有训练样例中

我正在尝试使用SVM进行多标记分类.我有近8k的功能,并且有长度接近400的y向量.我已经有了二进制化的Y向量,所以我没有使用MultiLabelBinarizer()但是当我使用它与我的Y数据的原始形式时,它仍然给出相同的东西.

我正在运行此代码:

X = np.genfromtxt('data_X', delimiter=";")
Y = np.genfromtxt('data_y', delimiter=";")
training_X = X[:2600,:]
training_y = Y[:2600,:]

test_sample = X[2600:2601,:]
test_result = Y[2600:2601,:]

classif = OneVsRestClassifier(SVC(kernel='rbf'))
classif.fit(training_X, training_y)
print(classif.predict(test_sample))
print(test_result)
Run Code Online (Sandbox Code Playgroud)

在完成预测部分的所有拟合过程之后,它说Label not x is present in all training examples(x是我的y向量长度范围内的几个不同的数字,即400).之后,它给出预测的y向量,该向量总是零向量,长度为400(向量长度).我是scikit-learn和机器学习的新手.我无法弄清楚这里的问题.有什么问题,我该怎么做才能解决它?谢谢.

python machine-learning scikit-learn

8
推荐指数
1
解决办法
3418
查看次数

numpy/scipy相当于MATLAB的稀疏函数

我正在使用numpy和scipy在Python中移植MATLAB代码,我需要在MATLAB中使用numpy/scipy等效的稀疏函数.

这是MATLAB中稀疏函数的用法,

sparse([3; 2], [2; 4], [3; 0])
Run Code Online (Sandbox Code Playgroud)

得到:

Trial>> m = sparse([3; 2], [2; 4], [3; 0])

    m =

       (3,2)        3

    Trial>> full(m)

    ans =

         0     0     0     0
         0     0     0     0
         0     3     0     0
Run Code Online (Sandbox Code Playgroud)

我有这些,但他们没有给出MATLAB版本的功能,

sps.csr_matrix([3, 2], [2, 4], [3, 0])
sps.csr_matrix(np.array([[3], [2]]), np.array([[2], [4]]), np.array([[3], [0]])) 
sps.csr_matrix([[3], [2]], [[2], [4]], [[3], [0]])  
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?谢谢.

python matlab numpy sparse-matrix

2
推荐指数
1
解决办法
3474
查看次数