小编use*_*737的帖子

如何在不使用CSS的情况下保留动态添加的javascript DOM元素中的空白?

当添加带有小空格的文本以进行对齐时,空白被修剪掉(空格被添加到c#中,所以当它到达前端时Javascript它无法编辑 - 只需使用一些CSS就可以了.这样做,但它不是一个选项).

这是我到目前为止尝试的内容:

<div id="testDiv"></div>
<script type="text/javascript">
 var zlp = document.getElementById("testDiv");
 zlp.innerHTML = "hello                hello";
 var zzz = document.createTextNode("hello                hello");
 zlp.appendChild(zzz);
</script>
Run Code Online (Sandbox Code Playgroud)

两者都产生hello hello.

javascript whitespace dom dynamic

4
推荐指数
1
解决办法
1万
查看次数

计算聚类的F度量

任何人都可以帮我集体计算F测量吗?我知道如何计算回忆和精度,但不知道给定算法如何计算一个F测量值.

作为一个例子,假设我的算法创建了m个集群,但我知道有相同数据的n个集群(由另一个基准算法创建).

我发现了一个pdf,但它没有用,因为我得到的集体值大于1. pdf的参考是F测量解释.具体来说,我已经阅读了一些研究论文,其中作者在F-measure的基础上比较了两种算法,如果你仔细阅读上面提到的pdf,它们的集合值在0和1之间,公式为F(C,K) =Σ| ci |/N*max {F(ci,kj)}
其中ci是参考簇&kj是由其他算法创建的簇,这里我从1运行到n&j从1运行到m.Let say | c1 | = 218这里按pdf N = m*n假设m = 12且n = 10,并且我们得到j = 2的最大F(c1,kj).绝对地,F(c1,k2)在0和1之间,但是通过上面的公式计算的结果值将得到高于1的值.

cluster-analysis data-mining precision-recall

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

使用 David J Bradshaw 的 iframe-resizer

我有一个 Teamspeak 状态查看脚本,托管在与我的 WordPress 不同的域上。因此,我尝试使用 iframe 在文本/html 小部件中显示脚本结果,但它不会自动调整高度。Wordpress 位于共享主机上,因此该脚本不会从那里与我的 teampeak 服务器进行通信。我找不到任何其他 ts3 查看器可以在自动隐藏空频道的同时工作并且不完全丑陋。经过一些研究后,我发现了似乎是最新、最好的解决方案,David J Bradshaw 的 iframe-resizer。现在我不是这个主题的专家,也不完全明白我应该如何正确设置它。

目前我的 WordPress 小部件如下所示:

<iframe src="http://66.172.12.238/ts3.php" width="100%" scrolling="no"></iframe>
Run Code Online (Sandbox Code Playgroud)

ts3.php 的内容如下:

<html>
<head>
<title>TSStatus</title>
<link rel="stylesheet" type="text/css" href="/ts3/tsstatus.css" />
<script type="text/javascript" src="/ts3/tsstatus.js"></script>
</head>
<body>
<?php
require_once("/var/www/ts3/tsstatus.php");
$tsstatus = new TSStatus("ts3.greatarchitect.us", 10011);
$tsstatus->useServerPort(9987);
$tsstatus->imagePath = "/ts3/img/";
$tsstatus->timeout = 2;
$tsstatus->hideEmptyChannels = true;
$tsstatus->hideParentChannels = true;
$tsstatus->showNicknameBox = false;
$tsstatus->showPasswordBox = false;
echo $tsstatus->render();
?>
</body>
</html> 
Run Code Online (Sandbox Code Playgroud)

这就是我现在所拥有的一切。我希望有人可以帮助我正确安装/设置这个 iframe-resizer。

谢谢。

javascript wordpress iframe jquery iframe-resizer

4
推荐指数
1
解决办法
9082
查看次数

python crontab和路径

我有一个兄弟姐妹的Python驱动程序和库脚本:

/home/mydir/pythonProjs/
Run Code Online (Sandbox Code Playgroud)
  • driver.py

  • lib.py

driver.py我有线:

from lib import method1

从Linux上的命令行获得以下成功:

python /home/mydir/pythonProjs/driver.py
Run Code Online (Sandbox Code Playgroud)

但是当我在crontab中尝试以下内容时:

10 1 * * * export PYTHONPATH=~/mydir/pythonProjs; python /home/mydir/pythonProjs/driver.py

我收到错误:

ImportError: No module named lib.method1
Run Code Online (Sandbox Code Playgroud)

我还尝试将crontab命令中的路径设置更改为完全限定的路径/home/mydir/pythonProjs,省略'export',并且还尝试编写.sh文件(使用必要的#!bin/bash ...)

我有一个主要问题和一个后续问题:主要:解决问题的最佳方法是什么?跟进:cron的路径访问背后的理念是什么?

在我投票过快之前,我会提到我已阅读但未成功(或正确解析)以下内容: - 我在哪里可以设置crontab将使用的环境变量? - 运行Python的Crontab问题 - http://pythonadventures.wordpress.com/2012/03/31/calling-a-python-script-from-crontab/

python cron environment-variables python-2.7

4
推荐指数
1
解决办法
6688
查看次数

从数组中提取单独的非零块

像这样的数组,例如:

[1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1]
Run Code Online (Sandbox Code Playgroud)

Python中最快的方法是在列表中组织非零元素,其中每个元素包含连续非零值块的索引?

这里的结果将是一个包含许多数组的列表:

([0, 1, 2, 3], [9, 10, 11], [14, 15], [20, 21])
Run Code Online (Sandbox Code Playgroud)

python numpy extract

4
推荐指数
1
解决办法
2700
查看次数

插件Android支持中的Android Studio异常

我有几个模块的Android Studio项目.现在,当我启动项目时,我收到了Gradle项目同步失败....

Failed to set up Android modules in project 'curiocity-app': [com.intellij.execution.application.ApplicationConfigurationType@9fbb092, com.intellij.execution.compound.CompoundRunConfigurationType@6b05465c, org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfigurationType@274e78e8, com.intellij.execution.jar.JarApplicationConfigurationType@10e3db81, com.intellij.execution.jar.JarApplicationConfigurationType@10e3db81, com.intellij.execution.junit.JUnitConfigurationType@5f5ffad0, com.intellij.execution.junit.JUnitConfigurationType@5f5ffad0, com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationType@164b9e9b, com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationType@164b9e9b, com.intellij.execution.scratch.JavaScratchConfigurationType@3e99dd8c, com.intellij.execution.scratch.JavaScratchConfigurationType@3e99dd8c, com.intellij.execution.remote.RemoteConfigurationType@67a0326f, com.intellij.execution.remote.RemoteConfigurationType@67a0326f, com.theoryinpractice.testng.configuration.TestNGConfigurationType@464f4a8f, com.theoryinpractice.testng.configuration.testDiscovery.TestNGTestDiscoveryConfigurationType@7fa81658] loader: PluginClassLoader[org.jetbrains.android, 10.2.1], class com.android.tools.idea.run.AndroidRunConfigurationType
java.lang.AssertionError: [com.intellij.execution.application.ApplicationConfigurationType@9fbb092, com.intellij.execution.compound.CompoundRunConfigurationType@6b05465c, org.jetbrains.plugins.groovy.runner.GroovyScriptRunConfigurationType@274e78e8, com.intellij.execution.jar.JarApplicationConfigurationType@10e3db81, com.intellij.execution.jar.JarApplicationConfigurationType@10e3db81, com.intellij.execution.junit.JUnitConfigurationType@5f5ffad0, com.intellij.execution.junit.JUnitConfigurationType@5f5ffad0, com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationType@164b9e9b, com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationType@164b9e9b, com.intellij.execution.scratch.JavaScratchConfigurationType@3e99dd8c, com.intellij.execution.scratch.JavaScratchConfigurationType@3e99dd8c, com.intellij.execution.remote.RemoteConfigurationType@67a0326f, com.intellij.execution.remote.RemoteConfigurationType@67a0326f, com.theoryinpractice.testng.configuration.TestNGConfigurationType@464f4a8f, com.theoryinpractice.testng.configuration.testDiscovery.TestNGTestDiscoveryConfigurationType@7fa81658] loader: PluginClassLoader[org.jetbrains.android, 10.2.1], class com.android.tools.idea.run.AndroidRunConfigurationType
    at com.intellij.execution.configurations.ConfigurationTypeUtil.findConfigurationType(ConfigurationTypeUtil.java:40)
    at com.android.tools.idea.run.AndroidRunConfigurationType.getInstance(AndroidRunConfigurationType.java:68)
    at com.android.tools.idea.gradle.customizer.android.RunConfigModuleCustomizer.customizeModule(RunConfigModuleCustomizer.java:52)
    at com.android.tools.idea.gradle.customizer.android.RunConfigModuleCustomizer.customizeModule(RunConfigModuleCustomizer.java:41)
    at com.android.tools.idea.gradle.service.AndroidGradleModelDataService.customizeModule(AndroidGradleModelDataService.java:322)
    at com.android.tools.idea.gradle.service.AndroidGradleModelDataService.access$100(AndroidGradleModelDataService.java:83)
    at com.android.tools.idea.gradle.service.AndroidGradleModelDataService$1.run(AndroidGradleModelDataService.java:157)
    at com.intellij.openapi.command.WriteCommandAction$Simple.run(WriteCommandAction.java:166)
    at com.intellij.openapi.application.RunResult.run(RunResult.java:35)
    at com.intellij.openapi.command.WriteCommandAction$2$1.run(WriteCommandAction.java:114)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1010)
    at com.intellij.openapi.command.WriteCommandAction$2.run(WriteCommandAction.java:111)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:124)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:99) …
Run Code Online (Sandbox Code Playgroud)

module intellij-idea gradle

4
推荐指数
1
解决办法
6258
查看次数

过滤任意嵌套列表的函数

由于双重条件,我无法找到如何将此函数写为lambda:

def f(e):
    if not isinstance(e,list):
        if e >10:
            return e
    else:
        return filter(None,[f(y) for y in e])
my_list=[[1], [2,[3,12, [4,11,12]]], [5,6,13,14],[15]]

>>> f(my_list)
[[[12, [11, 12]]], [13, 14], [15]]
Run Code Online (Sandbox Code Playgroud)

另外,编写这样一个过滤任意嵌套列表的函数的pythonic方法是什么?

python lambda functional-programming list python-2.7

4
推荐指数
1
解决办法
452
查看次数

了解召回和精确度

我目前正在学习信息检索,我宁愿坚持召回和精确的例子

搜索者使用搜索引擎来查找信息.第一个结果屏幕上有10个文档,第二个屏幕上有10个文档.

假设在搜索引擎索引中已知有10个相关文档.

Soo ...共有20个搜索,其中10个是相关的.

任何人都可以帮我理解这个吗?

谢谢

information-retrieval search-engine precision-recall

3
推荐指数
1
解决办法
2996
查看次数

如何更改 python scikit-learn 中精度和召回率的阈值?

我听人们说你可以调整阈值来调整精确度和召回率之间的权衡,但我找不到如何做到这一点的实际示例。

我的代码:

for i in mass[k]:
    df = df_temp # reset df before each loop
    #$$
    #$$ 
    if 1==1:
    ###if i == singleEthnic:
        count+=1
        ethnicity_tar = str(i) # fr, en, ir, sc, others, ab, rus, ch, it, jp
        # fn, metis, inuit; algonquian, iroquoian, athapaskan, wakashan, siouan, salish, tsimshian, kootenay
        ############################################
        ############################################

        def ethnicity_target(row):
            try:
                if row[ethnicity_var] == ethnicity_tar:
                    return 1
                else:
                    return 0
            except: return None
        df['ethnicity_scan'] = df.apply(ethnicity_target, axis=1)
        print '1=', ethnicity_tar
        print '0=', 'non-'+ethnicity_tar

        # Random sampling …
Run Code Online (Sandbox Code Playgroud)

machine-learning python-2.7 threshold scikit-learn precision-recall

3
推荐指数
1
解决办法
7677
查看次数

如何垂直拆分数据帧,在每个生成的 DF 中有 N 列

我有下面的数据框

Date     2017-12-05 2017-12-06 2017-12-15 2017-12-19 2017-12-20  2017-12-21   ....
time                                                                         
00:00:00      19.94      21.19      21.88      20.76      21.26      21.26   
00:15:00      20.29      21.07      21.71      21.79      21.95      21.52   
00:30:00      21.03      21.25      21.80      22.15      22.26      21.62   
00:45:00      22.20      21.56      22.77      22.20      22.33      21.91   
01:00:00      23.25      22.15      23.71      22.31      22.69      21.99   
01:15:00      23.78      23.33      24.53      22.29      22.82      22.58
Run Code Online (Sandbox Code Playgroud)

列是日期,我想将数据帧拆分为每 3 个日期列。我该怎么做 ?

例如,像下面想要每 3 列生成一个日期框(下面是第一个数据框...每 3 个日期列生成一个数据框

Date      2017-12-05 2017-12-06 2017-12-15 2
     time                                                                         
     00:00:00      19.94      21.19      21.88      
     00:15:00      20.29      21.07      21.71      
     00:30:00      21.03      21.25      21.80      
     00:45:00 …
Run Code Online (Sandbox Code Playgroud)

python split date pandas

3
推荐指数
1
解决办法
1731
查看次数