如果我们有一些数据点:
例如,我们使用 k-means 进行分割;所得到的线段是否不是每个点都最接近其各自簇的质心?如果是这样,当 Silhouette Score 比较 ai(到簇内点的平均距离)和 bi(到簇外点的平均距离)时,怎么会出现分数为负,或者 bi 小于 ai 的情况?
我可以看到,对于不同的分类算法,一些更复杂的算法可能会以不同的方式进行聚类,或者某些点分配不正确。但是 k 均值是如何发生这种情况的呢?
我们在Play Framework,Silhouette和Deadbolt 2中有两个着名的身份验证和授权插件.我的问题是这两个插件有什么区别?在什么情况下我们应该使用Silhouette或Deadbolt 2?
我想在脚本中使用轮廓分数,以自动计算来自sklearn的k均值聚类中的聚类数。
import numpy as np
import pandas as pd
import csv
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
filename = "CSV_BIG.csv"
# Read the CSV file with the Pandas lib.
path_dir = ".\\"
dataframe = pd.read_csv(path_dir + filename, encoding = "utf-8", sep = ';' ) # "ISO-8859-1")
df = dataframe.copy(deep=True)
#Use silhouette score
range_n_clusters = list (range(2,10))
print ("Number of clusters from 2 to 9: \n", range_n_clusters)
for n_clusters in range_n_clusters:
clusterer = KMeans (n_clusters=n_clusters).fit(?)
preds = clusterer.predict(?)
centers …Run Code Online (Sandbox Code Playgroud) 我是新来斯卡拉甚至我试图实现与Java太简单了,我感到困惑与斯卡拉.
我想要的是获得一个User,然后Permission使用另一个查询并根据他Role和他的个人填写他Permissions.
直到知道我有以下代码:
/**
* Finds a user by its loginInfo.
*
* @param loginInfo The loginInfo of the user to find.
* @return The found user or None if no user for the given login info could be found.
*/
def find(loginInfo: LoginInfo): Future[Option[models.admin.User]] = {
val userQuery = for {
dbLoginInfo <- loginInfoQuery(loginInfo)
dbUserLoginInfo <- Userlogininfo.filter(_.logininfoid === dbLoginInfo.id)
dbUser <- User.filter(_.userid === dbUserLoginInfo.userid)
user <- dbUser match {
case u …Run Code Online (Sandbox Code Playgroud) 每个人。我在 R 中绘制轮廓图时遇到问题。
这是我的代码。
#k-means clustering
#install.packages("cluster")
library(cluster)
kc <- kmeans(nsoap, centers=3)
dissE <- daisy(nsoap)
sk <- silhouette(kc$cl,dissE)
plot(sk)
dev.off()
Run Code Online (Sandbox Code Playgroud)
我刚得到这个结果。它没有内容......
我怎样才能克服这个问题?
谢谢:)
以下链接表示您可以将CookieAuthenticator用作无状态或有状态.
http://silhouette.mohiva.com/docs/authenticator
但我看不到任何选项可以在下面的链接做出选择.
http://silhouette.mohiva.com/v3.0/docs/config-authenticators#cookieauthenticator
我已经复制了以下示例的实现.这是无国籍还是有状态的?如果有状态我如何实现无状态身份验证?
Silhouette 在配置文件中的种子项目中有两行我不明白:
authenticator.cookie.signer.key = "[changeme]" // A unique encryption key
authenticator.crypter.key = "[changeme]" // A unique encryption key
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我这些用途是什么,如果我需要它们用于我的https网页以及如何生成这些密钥.文档中没有信息.
我使用了play-silhouette-seed作为我的应用程序的模板.所以在我的项目中,我使用基于cookie的authenticator(CookieAuthenticator).即使对于通过我的Twirl模板中嵌入的JavaScript的REST调用,这也非常好用.但是,现在我想在除浏览器之外的客户端中以编程方式进行REST调用.因此,我必须Set-Cookie: authenticator=...在每个响应上检索元素并将其设置为我的请求的一部分.在我的Twirl模板中嵌入并在浏览器中呈现的JavaScript代码段中,这没有问题,因为我不需要处理它,但对于其他客户端(服务器等),这会导致头痛.
我现在想要实现一个JWTAuthenticator除了我的CookieAuthenticator.这甚至是支持,还是我必须完全切换到JWTAuthenticator?此外,我是否需要单独的操作,即使除了验证器之外一切都应该是相同的实现?
我在用play silhouette 4.0.0-BETA4.除了存储密码外,一切似乎都能正常工作.每次我尝试签名新用户时,都会输入所有详细信息,但密码似乎存储在passwordinfo表中.
我正在使用MySQL数据库.
我花了几个小时试图找出问题所在,我无法弄明白.
build.sbt
"com.mohiva" %% "play-silhouette" % "4.0.0-BETA4",
"com.mohiva" %% "play-silhouette-persistence-memory" % "4.0.0-BETA4",
"com.mohiva" %% "play-silhouette-password-bcrypt" % "4.0.0-BETA4",
"com.mohiva" %% "play-silhouette-testkit" % "4.0.0-BETA4" % "test"
Run Code Online (Sandbox Code Playgroud)
SignUpController
val user = User(
None,
userID = UUID.randomUUID(),
loginInfo = loginInfo,
firstName = Some(data.firstName),
lastName = Some(data.lastName),
fullName = Some(data.firstName + " " + data.lastName),
email = Some(data.email),
avatarURL = None
)
for {
avatar <- avatarService.retrieveURL(data.email)
user <- userService.save(user.copy(avatarURL = avatar))
authInfo <- authInfoRepository.add(loginInfo, authInfo)
authenticator …Run Code Online (Sandbox Code Playgroud) 我想计算聚类评估的轮廓。R中有一些包,例如cluster和clValid。这是我使用 cluster 包的代码:
# load the data
# a data from the UCI website with 434874 obs. and 3 variables
data <- read.csv("./data/spatial_network.txt",sep="\t",header = F)
# apply kmeans
km_res <- kmeans(data,20,iter.max = 1000,
nstart=20,algorithm="MacQueen")
# calculate silhouette
library(cluster)
sil <- silhouette(km_res$cluster, dist(data))
# plot silhouette
library(factoextra)
fviz_silhouette(sil)
Run Code Online (Sandbox Code Playgroud)
该代码适用于较小的数据,例如具有 50,000 个 obs 的数据,但是当数据大小有点大时,我会收到类似“错误:无法分配大小为 704.5 Gb 的向量”的错误。对于 Dunn 索引和大型数据集的其他内部索引来说,这可能会出现问题。
我的电脑有 32GB RAM。问题来自于计算 dist(data)。我想知道是否可以不提前计算dist(data),并在轮廓公式需要时计算相应的距离。
我感谢您对这个问题以及如何计算大型和超大型数据集的轮廓的帮助。
我在一台新机器上导入了一个现有的工作项目,并试图让它编译。我收到以下错误
unresolved dependency: com.atlassian.jwt#jwt-core;1.6.1: not found
Run Code Online (Sandbox Code Playgroud)
我读到这个库用于Silhouette. 我Silhouette在我的项目中使用。
我的plugins.sbt是
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
resolvers += "Atlassian Releases" at "https://maven.atlassian.com/public/"
Run Code Online (Sandbox Code Playgroud)
我注意到 IntelliJ 试图在以下位置找到该库,但它无法找到。
==== local: tried
[warn] C:\Users\UserName\.ivy2\local\com.atlassian.jwt\jwt-core\1.6.1\ivys\ivy.xml
[warn] ==== public: tried
[warn] https://repo1.maven.org/maven2/com/atlassian/jwt/jwt-core/1.6.1/jwt-core-1.6.1.pom
[warn] ==== local-preloaded-ivy: tried
[warn] C:\Users\UserName\AppData\Local\Temp\sbt-global-pluginstub\preloaded\com.atlassian.jwt\jwt-core\1.6.1\ivys\ivy.xml
[warn] ==== local-preloaded: tried
[warn] file:/C:/Users/UserName/AppData/Local/Temp/sbt-global-pluginstub/preloaded/com/atlassian/jwt/jwt-core/1.6.1/jwt-core-1.6.1.pom
Run Code Online (Sandbox Code Playgroud) 切换到新的开发系统后出现依赖错误(使用轮廓播放应用程序)。
sbt.版本=1.3.3
在build.sbt中:
resolvers += Resolver.jcenterRepo
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
Run Code Online (Sandbox Code Playgroud)
[error] Error downloading com.atlassian.jwt:jwt-api:2.0.5
[error] Not found
[error] Not found
[error] not found: /Users/robert/.ivy2/local/com.atlassian.jwt/jwt-api/2.0.5/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/atlassian/jwt/jwt-api/2.0.5/jwt-api-2.0.5.pom
Run Code Online (Sandbox Code Playgroud) silhouette ×13
scala ×6
k-means ×3
jwt ×2
r ×2
sbt ×2
cookies ×1
deadbolt-2 ×1
memory ×1
python-2.7 ×1
scikit-learn ×1
slick ×1
slick-3.0 ×1
yellowbrick ×1