Questions tagged [weighted]

questions about problems that use a weight function, e.g. weighted mean, weighted sampling

A weight function is a mathematical device used when performing a sum, integral, or average to give some elements more "weight" or influence on the result than other elements in the same set. The result of this application of a weight function is a weighted sum or weighted average.

Weight functions occur frequently in statistics and analysis, and are closely related to the concept of a measure. Weight functions can be employed in both discrete and continuous settings.

615 questions
2
votes
2 answers

Predictions become irrational after adding weights to the fit

I have a model with several dense layers that behaves normally in all aspects. Then, I add weights to the training events (their values are between 0 and 1): w = mydata.Weight #... kfold = GroupKFold(n_splits=num_folds) for train, test in…
Helen
  • 316
  • 3
  • 16
2
votes
2 answers

Calculate Weights of a Column in Pandas

this is a basic quesiton and easy to do in excel but have not an idea in python and every example online uses groupby with multiple names in the name column. So, all I need is a row value of weights from a single column. Suppose I have data that…
user2100039
  • 1,280
  • 2
  • 16
  • 31
2
votes
2 answers

Dijkstra's Algorithm negative edge

Can someone help me with this question I am still confused weather Dijkstra's algorithm works with negative edges or not this question is from Grokking Algorithms book and in its errata it is said that this question has a possible answer how does…
YusufEmad04
  • 55
  • 1
  • 4
2
votes
0 answers

Azure autoML weight columns

I am using autoML for training purposes, however my dataset is very imbalanced. It is a multiclass task with 5 classes and I want to minimize this effect when training. I have verified the documentation and it seems autoML support the creation of a…
2
votes
1 answer

Is there public data for OCR-based character distance?

I am looking for "character visual similarity" weighted data (not an algorithm) to plug into a weighted-Damerau-Levenshtein algorithm. The Problem Currently, I am using Google's Vision AI (a paid OCR service) to perform the OCR conversion of an…
Andy R
  • 21
  • 1
2
votes
1 answer

Postgres: How can I include weights in a generated column?

I have following schema: CREATE TABLE books ( title VARCHAR(255), subtitle TEXT ); Adding a generated column without weights is working fine: ALTER TABLE books ADD COLUMN full_text_search TSVECTOR GENERATED ALWAYS AS (to_tsvector('english', …
ruslansteiger
  • 462
  • 1
  • 8
  • 21
2
votes
1 answer

Algorithm to do efficient weighted ranking?

I need an algorithm to do fast weighted ranking of Twitter posts. Each post has a number of ranking scores (like age, author follower count, keyword mentions, etc.). I'm looking for algorithm that can quickly find the top N Tweets, given the weights…
HetMes
  • 400
  • 2
  • 9
2
votes
1 answer

¿How do apply weights to my data frame in r?

So I want is to apply weights to my observations from my data frame, also I already have an entire column with the weights that I want to apply to my data. So this how my data frame looks like. weight count 3 67 7 355 8 25 7 2 And…
2
votes
1 answer

Is there a way in R for doing a pairwise-weighted correlation matrix?

I have a survey with a lot of numeric variables (both continuous and dummy-binary) and more than 800 observations. Of course, there is missing data for most of the variables (at a different rate). I need to use a weighted correlation table because…
2
votes
1 answer

How to weight data using R for dhs domestic violence data (Cote d'Ivoire 2011-2012)

I would like to set up the survey design for Cote d'Ivoire DHS using R (2011-2012). I am focused on domestic violence. I used this code: wt <- ipv_studyf$d005/1000000 # creating the variable weight ipvdesign <- svydesign(ids = ipv_studyf$v021, …
bakani1
  • 21
  • 1
2
votes
4 answers

Table in r to be weighted

I'm trying to run a crosstab/contingency table, but need it weighted by a weighting variable. Here is some sample data. set.seed(123) sex <- sample(c("Male", "Female"), 100, replace = TRUE) age <- sample(c("0-15", "16-29", "30-44", "45+"), 100,…
H.Cheung
  • 855
  • 5
  • 12
2
votes
2 answers

Use of data with negative weights in unbinned maximum likelihood fit in zfit

I am trying to perform an unbinned 3D angular fit in zfit, where the input data is a sample with per-event sWeights assigned from a separate invariant mass peak fit. I think I'm running into issues of negatively weighted events in some regions of…
dhill89
  • 61
  • 4
2
votes
1 answer

weighted numpy bincount for 2D IDs array and 1D weights

I am using numpy_indexed for applying a vectorized numpy bincount, as follows: import numpy as np import numpy_indexed as npi rowidx, colidx = np.indices(index_tri.shape) (cols, rows), B = npi.count((index_tri.flatten(), rowidx.flatten())) where…
ttsesm
  • 917
  • 5
  • 14
  • 28
2
votes
1 answer

Weighted randomness based on current values (Not sure how else to explain it)

Need some help with some code (Java) I have a script which runs every few mins This script creates and deletes objects For the sake of this example I want to have an average of 10 objects at any time But a random probability of it creating and…
2
votes
1 answer

How to use class weights for GaussianNB and KNeighborsRegressor in sklearn?

I have a highly imbalanced data set from which I want to get both classification (binary) as well as probabilities. I have managed to use logistic regression as well as random forest to obtain results from cross_val_predict using class weights. I…