如何进行K-means聚类时间序列数据?我理解当输入数据是一组点时它是如何工作的,但我不知道如何用1XM聚类时间序列,其中M是数据长度.特别是,我不确定如何更新时间序列数据的集群平均值.
我有一组标记时间序列的,我想用K-means算法来检查我是否会得到一个类似的标签或没有.我的X矩阵将是NXM,其中N是时间序列的数量,M是如上所述的数据长度.
有谁知道如何做到这一点?例如,我如何修改这个k-means MATLAB代码,以便它适用于时间序列数据?此外,我希望能够使用欧几里德距离以外的不同距离指标.
为了更好地说明我的疑虑,这里是我为时间序列数据修改的代码:
% Check if second input is centroids
if ~isscalar(k)
c=k;
k=size(c,1);
else
c=X(ceil(rand(k,1)*n),:); % assign centroid randomly at start
end
% allocating variables
g0=ones(n,1);
gIdx=zeros(n,1);
D=zeros(n,k);
% Main loop converge if previous partition is the same as current
while any(g0~=gIdx)
% disp(sum(g0~=gIdx))
g0=gIdx;
% Loop for each centroid
for t=1:k
% d=zeros(n,1);
% Loop for each dimension
for s=1:n
D(s,t) = sqrt(sum((X(s,:)-c(t,:)).^2));
end
end
% Partition data to closest centroids
[z,gIdx]=min(D,[],2);
% Update …
Run Code Online (Sandbox Code Playgroud) 有谁知道怎么看的过程中使用的所有用户top
在Cygwin中(部分指挥procps
系统下的库).
我知道这可以在*nix中完成,但我在Cygwin中苦苦挣扎.我尝试过使用pslist
但它不会在putty SSH控制台中运行.
我需要一个解决方案,我可以top
使用SSH 看到类似的对话框.我没有在所有这样的SSH是唯一的出路任何NTLM SSO访问WIN2K3客人.
我有一个看起来像这样的脚本:
export foo=/tmp/foo
export bar=/tmp/bar
Run Code Online (Sandbox Code Playgroud)
每次我构建时都运行'source init_env'(其中init_env是上面的脚本)来设置一些变量.
为了在Python中实现同样的目的,我运行了这个代码,
reg = re.compile('export (?P<name>\w+)(\=(?P<value>.+))*')
for line in open(file):
m = reg.match(line)
if m:
name = m.group('name')
value = ''
if m.group('value'):
value = m.group('value')
os.putenv(name, value)
Run Code Online (Sandbox Code Playgroud)
但后来有人决定在init_env
文件中添加如下行:
export PATH="/foo/bar:/bar/foo:$PATH"
Run Code Online (Sandbox Code Playgroud)
显然我的Python脚本崩溃了.我可以修改Python脚本来处理这一行,但是当有人想出一个在init_env
文件中使用的新功能时,它就会破坏.
问题是,是否有一种简单的方法来运行Bash命令并让它修改我的os.environ
?
是否有可能以某种方式以编程方式"压缩和修复"Access数据库(使用ADOX,使用OleDbConnection等)?
我需要一个脚本中的功能,使我能够在表中插入日期.
我需要什么SQL来插入格式的日期
01/08/2010 00:00:00
Run Code Online (Sandbox Code Playgroud)
其中日期是当月的第一天.我需要更改订单才能指定月份值?谢谢
我正在尝试一个基本的文件对话框示例,在这里,我收到一个关于'确定'的错误,我不知道为什么.
错误1'System.Nullable'不包含'OK'的定义,并且没有扩展方法'OK'可以找到接受类型'System.Nullable'的第一个参数(你是否缺少using指令或汇编引用?)
private void button1_Click(object sender, System.EventArgs e)
{
Stream myStream = null;
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "c:\\" ;
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
{
try
{
if ((myStream = openFileDialog1.OpenFile()) != null)
{
using (myStream)
{
// Insert code to read the stream here.
}
}
}
catch (Exception ex)
{
MessageBox.Show("Error: Could not read file from disk. Original error: …
Run Code Online (Sandbox Code Playgroud) 我在spring-mvc做了一个用户问题.
我的模型具有以下属性:
private Long id;
private String password;
private String username;
private Collection<Authority> myAuthorities;
private boolean isAccountNonExpired;
private boolean isAccountNonLocked;
private boolean isCredentialsNonExpired;
private boolean isEnabled;
Run Code Online (Sandbox Code Playgroud)
我解决了如何Authority
在这个问题中展示课程.
现在我愿意我的表单能够有第二个密码字段来确认用户是否正确输入了密码.
我不想confirmPassword
在模型中添加属性,所以我的问题是如何以最好的方式解决这个问题.
编辑:
一切都在使用axtavt的答案,但我错过了一种验证方法.我的控制器中有以下方法,但即使我放置了一个@Validate
ApplicationUserFormValidator
未调用的方法.
@RequestMapping(method = RequestMethod.POST)
public ModelAndView create(Model model,
@Valid @ModelAttribute ApplicationUserForm applicationUserFrom,
BindingResult result) {
ModelAndView modelAndView = new ModelAndView();
if (result.hasErrors()) {
modelAndView.setViewName(USER_CREATE_FORM);
} else {
modelAndView.setViewName(REDIRECT_TO_USER_LIST);
modelAndView.addObject(USER_FORM_MESSAGE, USER_FORM_ADD_SUCCESSFUL);
applicationUserService.save(applicationUserFrom.getUser);
}
return modelAndView;
}
Run Code Online (Sandbox Code Playgroud) 我已经建立了一个西班牙语和英语的应用程序.在我的控制台上,如果对象返回验证错误,我将收到英文错误消息.我想设置我的rails控制台,所以我将获得西班牙语验证错误消息.
我有一个问题,对你们来说似乎很简单,但不能真正得到它.遇到警告到现在为止.
我可以知道如何接受整数0-9和alpha a-zA-Z的字符串,但最少5个字符,最多15个字符preg_match
.谢谢
bash ×1
c# ×1
cygwin ×1
data-mining ×1
date ×1
datetime ×1
dialog ×1
file ×1
java ×1
k-means ×1
matlab ×1
ms-access ×1
php ×1
preg-match ×1
python ×1
r ×1
repair ×1
ruby ×1
spring ×1
spring-mvc ×1
sql ×1
sql-server ×1
time-series ×1
wpf ×1