similar to: sum method

Displaying 20 results from an estimated 60000 matches similar to: "sum method"

2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
Hello Railists, I have a piece of Ruby on Rails code that has a complex SQL query (well, not that complex, but as far as I know beyond the ORM capabilities) and for my taste it has too many strings and harcoded values. I''d like to improve it as much as possible, so my question is open ended, what else can I do to improve it? Some particular issues I have - Is there a way to get a table
2007 Nov 30
2
find_by_sql preformance problems when ordering data
Hi, I am bumping into a small problem I was hoping someone could send me in the right direction on. I''m counting votes from a votes table to try to find the top ten videos. The following works really well, until I try to order it. It would seem that the order by is adding a 26 second delay, which surprised me since it was all done in sql. I revised the process to sort and publish on
2007 Aug 24
2
Variable Importance - Random Forest
Hello, I am trying to explore the use of random forests for classification and am certain about the interpretation of the importance measurements. When having the option "importance = T" in the randomForest call, the resulting 'importance' element matrix has four columns with the following headings: 0 - mean raw importance score of variable x for class 0 (where
2007 Oct 25
1
Appropriate measure of correlation with 'zero-inflated' data?
I have reached the correlation section in a course that I teach and I hit upon the idea of using data from the weekly Bowl Championship Series (BCS) rankings to illustrate different techniques for assessing correlation. For those not familiar with college football in the United States (where "football" refers to American football, not what is called soccer here and football in most
2009 Apr 20
1
Random Forests: Predictor importance for Regression Trees
Hello! I think I am relatively clear on how predictor importance (the first one) is calculated by Random Forests for a Classification tree: Importance of predictor P1 when the response variable is categorical: 1. For out-of-bag (oob) cases, randomly permute their values on predictor P1 and then put them down the tree 2. For a given tree, subtract the number of votes for the correct class in the
2005 Dec 29
3
globals, incremental voting, images
Can I define a global variable (in the ApplicationController perhaps) and give it a value that will be accessible in every controller and view? Would it add a lot of computational overhead to my site if the globals were arrays storing gigabytes of data)? I want to use a voting system in which the user can click and drag on an image to select a score between 0.0 and 5.0 - the number should be
2006 Jan 07
8
Using find_by_sql to get the sum of a column
Hello, I was wondering if there was a method in Rails that returns the sum of a column. For example, I have a column called ''score'' and writing a SQL statement such a ''select sum(score) from table_name'' does return the sum of the values in the column. In the past (not too long ago being a newbie), I defined all sorts of methods only to discover that Rails
2008 May 12
3
Enumeration sum
Any idees why I can do this: @sum = @selected.inject(0) { |sum, player| sum + player.value } but not this: @sum = @selected.sum { |player| player.value } @sum = @selected.sum(&:value) The last two give me following error: wrong number of arguments (1 for 2) /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_collection.rb:164:in `calculate''
2009 Feb 04
1
D'Hondt method
Is there a R function to calculate the seats in parliament given the total number of seats and the votes for each party -- for different methods including the method of D'Hont? http://en.wikipedia.org/wiki/D%27Hondt_method Thanks, thomas
2007 Dec 20
3
ActiveRecords Eager Loading
Hi, I am doing an eager loading in ruby on rails using below statement ------------------------ Article.find(:all, :include => [:asset, :vote], :conditions=>"assets.parent_id is null", :order=>"stat_final_ranking desc", :limit=>20) --------------------------------------- the above statement resulted in this expensive query.
2010 Feb 11
1
Rounding multinomial proportions
I present you with a function that solves a problem that has bugged me for many years. I think the problem may be general enough to at least consider adding this function, or a revamped version of it, to the 'stats' package, with the other multinomial functions reside. I'm using R to export data to text files, which are input data for an external model written in C++. Parts of the
2017 May 31
4
stats::line() does not produce correct Tukey line when n mod 6 is 2 or 3
Seriously, if a method gives a wrong result, it's wrong. line() does NOT implement the algorithm of Tukey, even not after the patch. We're not discussing Excel here, are we? The method of Tukey is rather clear, and it is NOT using the default quantile definition from the quantile function. Actually, it doesn't even use quantiles to define the groups. It just says that the groups
2010 Mar 24
3
mounting gfs partition hangs
Hi, I have configured two machines for testing gfs filesystems. They are attached to a iscsi device and centos versions are: CentOS release 5.4 (Final) Linux node1.fib.upc.es 2.6.18-164.el5 #1 SMP Thu Sep 3 03:33:56 EDT 2009 i686 i686 i386 GNU/Linux The problem is if I try to mount a gfs partition it hangs. [root at node2 ~]# cman_tool status Version: 6.2.0 Config Version: 29 Cluster Name:
2011 Jul 13
3
Sum weights of independent variables across models (AIC)
Hello, I'd like to sum the weights of each independent variable across linear models that have been evaluated using AIC. For example: > library(MuMIn) > data(Cement) > lm1 <- lm(y ~ ., data = Cement) > dd <- dredge(lm1, beta = TRUE, eval = TRUE, rank = "AICc") > get.models(dd, subset = delta <4) There are 5 models with a Delta AIC Score of
2007 Nov 18
1
validates_uniqueness_of question
Given three models: a design model, a votes model, and a users model the problem is a user can only vote for a design once. If I do a validates_uniqueness_of :user in the votes model that means a user can only vote once, period. What I want is to say a user can only vote for a single design once. Anyone know the best way to do this? Thanks. JB
2006 Aug 30
4
Users voting
I''m trying to work out the most reasonable way to keep track of users "voting" for or against a particular bit of data. Obviously, I don''t want them to be able to just bang on the link -- I''d prefer to limit it to one vote per day, for example. I could record the fact that they''ve voted in the session, but I''d really rather not have
2011 Apr 25
0
Need Help with Fence_xvm
Dear Xen Users, I am new to this technology and I''ve been reading all over the places about how to setup a cluster infrasctructre using Xen DOM0 and Xen DOMu Domains. So far I have quite a few parts running (cluster) but I am trying to add a (virtual) fencing method. I have read that I can use (Virtual Fencing) using the fence_xvmd-fence_xvm deamon and agents; that will allow me to
2008 Jun 17
3
rindex not working with objects from db model
I''m sorting a separate list that doesn''t contain a certain user''s attribute, but trying to but that certain user''s attribute on the separate percentile. test_scores = Testscore.find(:all, :conditions=> {...}) my_testscore = current_user.test_score my_ts = Testscore.new(:score => my_testscore) test_scores.push(ts) sorted_ts = test_scores.sort {|x,y|
2010 Jun 17
7
Why do rails calls a method when I'm calling a property?
Well, I''m starting on RoR, so I got a Book called simply rails...Following the steps in it sometimes when I try to call a property, the browser shows me the next exception: undefined method `name'' for nil:NilClass I don''t know why...here''s my controller: #Controller starts here class StoriesController < ApplicationController before_filter :login_required,
2008 Nov 10
2
Sort model based on max value of has_many field
Hi, I have models such as: class Team < ActiveRecord::Base has_many :games end class Game< ActiveRecord::Base belongs_to :team end So there are many (well, 0 to 6) games for each team. Team game has a "score". I would like to get a list of the teams, sorted by the highest scoring game - sort of a ranking based on highest score. I''ve tried several cominations of