小编And*_*raD的帖子

R中的主成分分析(PCA):使用哪个函数?

谁能解释一下prcomp和princomp函数之间的主要区别是什么?

有什么特别的理由让我选择一个而不是另一个吗?如果这是相关的,我正在研究的应用类型是基因组(表达)数据集的质量控制分析.

谢谢!

r linear-algebra pca unsupervised-learning

6
推荐指数
1
解决办法
3128
查看次数

Conda环境中的Postgres(Ubuntu 14.04)

作为Anaconda的新手,我在正确设置conda环境方面遇到了一些麻烦。我感兴趣的是为带有postgres数据库的Django应用程序搭建环境。以下命令创建环境:

$ conda create -n django1.7-webdev python=3.4 django=1.7 postgresql=9.1
Run Code Online (Sandbox Code Playgroud)

第二条命令激活环境:

$ source activate django1.7-webdev
Run Code Online (Sandbox Code Playgroud)

但是,此时,当尝试运行psql时,出现以下错误:

$ psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

如何在conda环境中启动PostgreSQL?以下命令启动在激活的conda环境之外安装的PostgreSQL,这不是我想要的:

$ sudo service postgresql start
Run Code Online (Sandbox Code Playgroud)

postgresql anaconda conda

6
推荐指数
1
解决办法
4385
查看次数

允许用户仅编辑Ruby on Rails上的一些字段

如何才能实现用户只能编辑记录中的某些字段?

例如:

用户可以在系统上注册并选择并指定用户名,密码等.但是注册用户只能编辑他的姓名,电子邮件和密码,而不能编辑他的用户名.

我有一个部分_form,我用它来创建新的和编辑函数.部分看起来像这样:

    <% form_for @user do |f| %>
    <%= f.error_messages %>
    <p>
            <%= f.label :gruebl_employee_id %><br />
            <%= f.collection_select(:firma_employee_id, FirmaEmployee.find(:all).sort_by{|p| p.lastname.downcase},:id,:full_name, {  :include_blank => "---keine Mitarbeiter---", :prompt => "---Bitte auswählen---"}, { :style => "width: 332px;"}) %>
        </p>
         <%= observe_field(:user_firma_employee_id,
         :frequency => 0.25,
         :url => { :action => :retrieveinfo },
         :with => "'id='+value") %>

        <p>
          <%= f.label :username %><br />
          <%= f.text_field :username %>
        </p>

         <p>
          <%= f.label :admin, "Administrator ?" %><br />
          <%= f.check_box :admin %>
        </p>

        <p> …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails

5
推荐指数
1
解决办法
4800
查看次数

设置对话框的最大高度,然后允许滚动

我似乎无法理解如何正确设置jquery ui对话框的高度.

我希望它显示高度,无论多少内容存在,但如果它超过400像素,那么我想要一个滚动条.

因此,如果内容的高度为200像素,则对话框的高度应为200像素.

如果内容的高度大于400像素,则对话框不应超过400像素,并且应该可以看到滚动条.

到目前为止我有这个:

$("#popup").dialog({
            modal: true,
            autoOpen: false

});
Run Code Online (Sandbox Code Playgroud)

jquery jquery-ui jquery-ui-dialog

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

R中的PCA:prcomp和置信省略号

我最近在R中使用prcomp()函数运行PCA,现在我需要(客观地)决定来自我的两个不同组的哪些样本是异常值,并且应该从进一步分析中删除.

我之前已经看过PCA图,其中置信度/方差椭圆(不确定术语)放在样本周围,留在被认为是异常值的那些之外(例如,让我们说距离群集质心超过3个标准偏差).如何在R中实现这样的效果?

注意:我看了一下"car"包,但目前还不清楚data.ellipse如何用于PC1与PC2投影图.任何帮助/相关资源表示赞赏!

谢谢!

编辑:我正在使用的R对象以及我想用于异常值标记的其中一个图:

countsTable <- read.table('sample.txt', header=T)
transpose.counts.table <- t(countsTable)
input.for.pca <- transpose.counts.table[, colSums(abs(transpose.counts.table)) != 0]
my.prc <- prcomp(input.for.pca, center=T, scale=T)

pdf("PCA_Results_PC1_PC2_prcomp_counts.pdf")
plot(my.prc$x[,1], my.prc$x[,2], type='p', cex=0.0, pch=20, main="PCA: Samples' projection on PC1 and PC2 (raw counts)", xlab="PC1", ylab="PC2")
text(my.prc$x[,1], my.prc$x[,2], labels=rownames(my.prc$x), cex=1.2)
dev.off()
Run Code Online (Sandbox Code Playgroud)

更新了input.for.pca对象,其中包含分类"类型"列:

> dput(input.for.pca)
structure(list(A1BG = c(190L, 125L, 95L, 115L, 483L, 94L, 87L, 
211L, 153L, 135L, 116L, 110L, 75L, 159L, 148L, 159L, 177L, 103L, 
103L, 88L, 112L, 87L, 272L, 100L, 313L, 169L, 130L, 164L, …
Run Code Online (Sandbox Code Playgroud)

r pca

5
推荐指数
1
解决办法
4769
查看次数

Rails反馈表单:如何获取当前页面的URL?

我正在使用David Francisco的rails反馈插件.该插件工作正常,除了一件事 - 我需要反馈表单向数据库提交使用反馈表单的页面的URL.有谁知道如何做到这一点?

除了当前发送的信息之外,需要发送当前URL的视图:

<h4>Feedback</h4>
<p>Please leave us feedback, it's really appreciated.</p>

<%= form_for @feedback, :as => :feedback, :url => feedback_index_path, :html => { :id => "feedback_form" } do |f| -%>
  <%= f.hidden_field 'user_id', :value => current_user.id %>
  <% unless @error_message.blank? %>
  <p class="error">
    <%=h @error_message %>
  </p>
  <% end %>
  <p>
    <%= f.label 'subject' %>
    <%= f.select 'subject', ['Problem', 'Suggestion', 'Question', 'Other'] %>
  </p>
  <p>
    <%= f.label 'comment' %><br />
    <%= f.text_area 'comment', :rows => 10, …
Run Code Online (Sandbox Code Playgroud)

forms feedback ruby-on-rails user-feedback ruby-on-rails-3

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

基本Python编程使用字典将月号转换为月份名

我是python的新手,只知道最基本的水平.我应该允许以dd/mm/yyyy的形式输入日期并将其转换为类似于1986年8月26日的日期.我被困在如何将我的月(mm)从数字转换为单词.以下是我目前的代码,希望你能帮助我.**请不要建议使用日历功能,我们应该用dict来解决这个问题.

谢谢 (:

#allow the user to input the date
date=raw_input("Please enter the date in the format of dd/mm/year: ")

#split the strings
date=date.split('/')

#day
day=date[:2]

#create a dictionary for the months
monthDict={1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'}
#month
month=date[3:5]
if month in monthDict:
    for key,value in monthDict:
        month=value

#year
year=date[4:]

#print the result in the required format
print day, month, "," , year 
Run Code Online (Sandbox Code Playgroud)

python python-2.7

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

无法正确显示Twitter Bootstrap glyphicons

我正在研究Angular.js Todo应用程序视频教程,我遇到了一个问题,包括index.html文件中的Twitter Bootstrap 3 glyphicons(这些图标在Chrome和Firefox中都显示为非描述性图像).

这就是我在index.html中添加bootstrap和bootstrap-glyphicons css文件的方法:

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
  <script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
  <script type="text/javascript" src="todo.js"></script>
  <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-glyphicons.css">
  <link rel="stylesheet" href="todo.css">
</head>
Run Code Online (Sandbox Code Playgroud)

这就是我稍后在文件中添加所需的glyphicon的方法:

<form class="form-horizontal">
  <input type="text" ng-model="formTodoText" ng-model-instant>
  <button class="btn"><i class="glyphicon glyphicon-plus"></i>Add</button>
</form>
Run Code Online (Sandbox Code Playgroud)

bootstrap-glyphicons字体文件位于bootstrap/css/fonts中.具体来说,文件是:

  1. glyphiconshalflings-regular.eot
  2. glyphiconshalflings-regular.otf
  3. glyphiconshalflings-regular.svg
  4. glyphiconshalflings-regular.ttf
  5. glyphiconshalflings-regular.woff

有关如何正确访问图标的任何想法?非常感谢你的帮助!

twitter-bootstrap angularjs glyphicons

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

PCA Biplot:一种隐藏向量以清楚地查看所有数据点的方法

我想用R做PCA

我的数据有10,000列和90行,我使用prcomp函数来执行PCA.试图用prcomp结果准备一个双标图,我遇到了10,000个绘制的向量覆盖我的数据点的问题.双标图是否有任何隐藏向量表示的选项?

要么

我可以用它plot来获得PCA结果.但我不确定如何根据我的数据点标记这些点,数据点编号为1到90.

Sample<-read.table(file.choose(),header=F,sep="\t")

Sample.scaled<-data.frame(apply(Sample_2XY,2,scale))

Sample_scaled.2<-data.frame(t(na.omit(t(Sample_2XY.scaled))))

pca.Sample<-prcomp(Sample_2XY.scaled.2,retx=TRUE)

pdf("Sample_plot.pdf")

plot(pca.Sample$x)

dev.off()
Run Code Online (Sandbox Code Playgroud)

r

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

jQuery Spinner:非数值

我正在使用jQuery Spinner,设置了min(0)和max(500)值.我该怎么做才能防止用户在输入框中直接输入非数值(或0-500范围之外的值)?当用户使用微调按钮时,最小值和最大值有效,但在输入表单中输入内容时则不起作用.

javascript jquery jquery-ui-spinner

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