One of my upper classmates has given me a data set for experimenting with vlfeat's SIFT, however, her extracted SIFT data for the frame part contains 5 dimensions. An example is given below:
192
9494
262.08 749.211 0.00295391 -0.00030945 0.00583025 0 0 0 45 84 107 86 8 10 49 31 21 32 37 46 50 11 23 49 60 29 30 24 17 4 15 67 25 28 47 13 11 27 9 0 40 117 99 27 3 117 117 39 19 11 18 16 32 8 27 50 117 102 20 23 18 2 10 36 45 47 84 37 16 36 31 9 50 112 52 12 9 117 36 6 4 3 15 54 117 9 3 2 31 94 101 92 23 0 20 47 36 38 14 1 0 34 19 39 52 27 0 0 31 6 14 18 29 24 13 11 11 12 10 3 1 4 25 29 5 0 5 6 3 12 29 35 2 93 73 61 50 123 118 100 109 58 44 79 122 120 108 103 87 92 61 28 33 55 107 123 123 37 73 60 32 93 123 123 89 118 118 77 66 118 118 63 96 118 94 60 27 41 74 108 118 107 81 107 118 118 43 73 64 118 118 118 56 45 38 27 58
432.424 57.2287 0.00285143 -0.00048992 0.00292525 10 12 19 26 88 43 14 10 3 4 44 50 125 74 0 1 2 4 47 34 17 3 0 0 3 3 8 6 1 0 0 1 11 12 14 17 43 37 10 6 35 36 125 77 47 10 5 13 2 7 125 125 125 29 0 2 1 3 11 15 33 5 1 0 36 14 7 8 102 64 37 27 41 8 2 2 55 53 103 125 4 2 2 5 125 125 41 28 1 3 4 7 32 11 3 1 46 29 6 7 125 57 3 3 49 11 0 1 90 34 19 31 10 3 3 6 122 33 10 9 0 2 11 10 7 2 2 1 35 64 129 129 129 93 48 44 24 55 129 117 129 71 41 19 44 65 76 58 129 129 129 89 42 48 57 96 129 129 90 55 133 118 58 42 58 42 133 133 133 62 24 17 18 12 133 133 133 133 133 125 78 33 17 29 133 133 82 45 23 11 13 44
... // the list keeps on going for all keypoints.
This file is simply descriptors' data of an image. There are a few things I need to know:
what are the first two values '192' and '9494'?
what is the 5th value for the keypoint? vlfeat's sift normally gives out 4 values for key point's frame.
So I asked her what is this 5th dimension, and she pointed me to search for "standard oxford format" for sift feature.
The thing is I tried to search around regarding this standard oxford format and sift feature, but I got no luck in finding it at all. If somebody knows anything regarding this, could he please point me to the right direction?
192 represents the descriptor length ,9494 represent the Number of key-points you have in the file.
The other line consists of [WORD_ID] [X] [Y] [A] [B] [C]
X and Y is the feature centroid and A, B, C define the parameters of
the ellipse in the following equation A*(x-X)^2 + 2*B*(x-X)(y-Y) + C(y-Y)^2 = 1
You can check the official website for the formate Here
If you are using VLfeat package you can read here how to read the file in Oxford format.
If you are very curious how the file formate is read in VLfeat vl_ubcread function. Here is the code.
Related
I would like to calculate the Year to date (YTD) value for this year and compare it to the same period last year in Pandas. My df looks like this:
Month Product A Product B
2015-01-01 24 62
2015-02-01 46 24
2015-03-01 30 70
2015-04-01 26 51
2015-05-01 34 42
2015-06-01 45 35
2015-07-01 25 13
2015-08-01 98 95
2015-09-01 6 81
2015-10-01 93 38
2015-11-01 98 59
2015-12-01 98 1
2016-01-01 67 42
2016-02-01 72 34
2016-03-01 7 6
2016-04-01 19 24
2016-05-01 82 38
2016-06-01 15 79
2016-07-01 49 83
2016-08-01 97 56
The two values i am after for product A are
YTD = 408 and YTD SPLY = 328 (Sum Jan-Aug 2016, Sum Jan-Aug 2015).
When a new month is added to the df, i would like the formula to calculate Jan-Sep and so on.
Any ideas how to proceed?
Not exactly sure what you want but it looks like you want to take the cumulative sum for each year.
df[['A_cumsum', 'B_cumsum']] = df.resample('A', on='Month').transform('cumsum')
Month Product A Product B A_cumsum B_cumsum
0 2015-01-01 24 62 24 62
1 2015-02-01 46 24 70 86
2 2015-03-01 30 70 100 156
3 2015-04-01 26 51 126 207
4 2015-05-01 34 42 160 249
5 2015-06-01 45 35 205 284
6 2015-07-01 25 13 230 297
7 2015-08-01 98 95 328 392
8 2015-09-01 6 81 334 473
9 2015-10-01 93 38 427 511
10 2015-11-01 98 59 525 570
11 2015-12-01 98 1 623 571
12 2016-01-01 67 42 67 42
13 2016-02-01 72 34 139 76
14 2016-03-01 7 6 146 82
15 2016-04-01 19 24 165 106
16 2016-05-01 82 38 247 144
17 2016-06-01 15 79 262 223
18 2016-07-01 49 83 311 306
19 2016-08-01 97 56 408 362
I have a pandas dataframe:
import numpy
import pandas
df1 = abs((pandas.DataFrame(numpy.random.randn(20, 8))*100).astype(int))
df1.columns = list('abcdefgh')
df1.index = pandas.date_range('1/1/2014', periods=20)
How would I create a new column that will give me the minimum value of the first half of the current row and the last 3 values in the previous row?
For example, the first five rows in the created column would be:
Nan
12
4
14
21
Here is one way to do it. Basically, you need to first shift last three columns and then combine with the first 4 columns, and finally calculate the min.
import numpy
import pandas
# your data
# ===================================
numpy.random.seed(0)
df1 = abs((pandas.DataFrame(numpy.random.randn(20, 8))*100).astype(int))
df1.columns = list('abcdefgh')
df1.index = pandas.date_range('1/1/2014', periods=20)
# processing
# ===================================
df1['custom_min'] = pandas.concat([df1[df1.columns[:5]], df1[df1.columns[-3:]].shift(1)], axis=1).min(axis=1)
print(df1)
a b c d e f g h custom_min
2014-01-01 176 40 97 224 186 97 95 15 40
2014-01-02 10 41 14 145 76 12 44 33 10
2014-01-03 149 20 31 85 255 65 86 74 12
2014-01-04 226 145 4 18 153 146 15 37 4
2014-01-05 88 198 34 15 123 120 38 30 15
2014-01-06 104 142 170 195 50 43 125 77 30
2014-01-07 161 21 89 38 51 118 2 42 21
2014-01-08 6 30 63 36 67 35 81 172 2
2014-01-09 17 40 163 46 90 5 72 12 17
2014-01-10 113 123 40 68 87 57 31 5 5
2014-01-11 116 90 46 153 148 189 117 17 5
2014-01-12 107 105 40 122 20 97 35 70 17
2014-01-13 1 178 12 40 188 134 127 96 1
2014-01-14 117 194 41 74 192 148 186 90 41
2014-01-15 86 191 26 80 94 15 61 92 26
2014-01-16 37 109 29 132 69 14 43 184 15
2014-01-17 67 40 76 53 67 3 63 67 14
2014-01-18 57 20 39 109 149 43 16 63 3
2014-01-19 238 94 91 111 131 46 6 171 16
2014-01-20 74 82 9 66 112 107 114 43 6
I am Getting WA in the Question GCD Condition from Codechef March Long Contest.
Kindly tell me what I've done wrong or some test case where the code produces Wrong answer.
Link for the Question
I Have used RMQ(Range maximum Query) for every prime number
for(i=0;i<limit;i++)
{
int sz=b[i].size();
if(!sz)continue;
int level=0;
cc[i].resize(sz);
for(j=0;j<sz;j++)cc[i][j].push_back(b[i][j]);//level 0
for(level=1;(1<<level)<=sz;level++)
{
for(j=0;j+(1<<level)<=sz;j++)
{
int c1=cc[i][j][level-1];
int c2=cc[i][j+(1<<(level-1))][level-1];
int mx=(a[c1]<a[c2])?c2:c1;
cc[i][j].push_back(mx);
}
}
}
firstly i have converted to a structure like the following:-
Example input:- 10 6 20 15 8
(b[i]-->stores the indices of factors of i)
b[2]--> 1,2,3,5
b[3]--> 2,4
b[5]--> 1,3,4
Now after implementing RMQ, it will be as follow:-
(cc[i][j][k] stores index of the largest element between b[i][j] and b[i][j+(2^k)-1])
cc[2][0]-->1,2,3,5
cc[2][1]-->1,3,3
cc[2][2]-->3
cc[3][0]-->2,4
cc[3][1]-->4
cc[5][0]-->1,3,4
cc[5][1]-->3
My Code
100 1
88 33 23 56 97 54 8 74 43 95 91 63 38 13 7 7 52 29 6 85 70 15 52 18 78 9 85 51 28 43 4 68 75 78 75 23 32 34 48 74 28 90 36 66 2 95 24 54 23 29 90 45 96 93 14 73 2 99 75 81 93 31 100 19 8 75 93 39 60 41 64 88 30 100 5 84 46 28 89 20 56 30 64 3 22 78 75 75 76 2 8 20 32 7 38 39 33 82 30 93
95 95 97
The output is -1 -1, but gcd(38, 95) = 19, so ans should be 38 1.
Replacing 'break' by 'continue' on line 75 gave AC :)
When I try to print a really long array, it gets cut off at a certain length
[-1 -40 -1 -32 0 16 74 70 73 70 0 1 1 0 0 1 0 1 0 0 -1
-37 0 67 0 8 6 6 7 6 5 8 7 7 7 9 9 8 10 12 20 13 12 11
11 12 25 18 19 15 20 29 26 31 30 29 26 28 28 32 36 46 39
32 34 44 35 28 28 40 55 41 44 48 49 52 52 52 31 39 57 61
56 50 60 46 51 52 50 -1 -37 0 67 1 9 9 9 12 11 12 ...]
I would like it not to do that if I'm persisting a data structure to file. How can this be done?
The special variable *print-length* determines how much of a given structure is printed. Like any other dynamic var, you can use binding to set its value in a block.
user> (binding [*print-length* 2] (prn (range 200)))
(0 1 ...)
nil
user> (binding [*print-length* nil] (prn (range 200)))
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199)
nil
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
im trying to fill an array with random 200 numbers that can very from 0-100. I get it populated except the last couple number are very odd.
here my code.
for (int i = 0; i < NUM_LIST_ELEMENTS; i++)
{
int j = rand() % 100;
list[i] = j;
}
my output comes out at follows
Original Arrays:
41 67 34 0 69 24 78 58 62 64 5 45 81 27 61 91 95 42 27 36 91 4 2 53 92 82 21 16 18
95 47 26 71 38 69 12 67 99 35 94 3 11 22 33 73 64 41 11 53 68 47 44 62 57 37 59 23 41
29 78 16 35 90 42 88 6 40 42 64 48 46 5 90 29 70 50 6 1 93 48 29 23 84 54 56 40 66
76 31 8 44 39 26 23 37 38 18 82 29 41 33 15 39 58 4 30 77 6 73 86 21 45 24 72 70 29
77 73 97 12 86 90 61 36 55 67 55 74 31 52 50 50 41 24 66 30 7 91 7 37 57 87 53 83 45
9 9 58 21 88 22 46 6 30 13 68 0 91 62 55 10 59 24 37 48 83 95 41 2 50 91 36 74 20
96 21 48 99 68 84 81 34 53 99 18 38 0 88 27 67 28 93 48 83 7 21 10 17 13 14-858993460
9 16 35 51 0 49 19 56 98 3 24 8 44 9 89 2 95 85 93 43 23 87 14 3 48 0 58 18 80
96 98 81 89 98 9 57 72 22 38 92 38 79 90 57 58 91 15 88 56 11 2 34 72 55 28 46 62 86
75 33 69 42 44 16 81 98 22 51 21 99 57 76 92 89 75 12 0 10 3 69 61 88 1 89 55 23 2
85 82 85 88 26 17 57 32 32 69 54 21 89 76 29 68 92 25 55 34 49 41 12 45 60 18 53 39 23
79 96 87 29 49 37 66 49 93 95 97 16 86 5 88 82 55 34 14 1 16 71 86 63 13 55 85 53 12
8 32 45 13 56 21 58 46 82 81 44 96 22 29 61 35 50 73 66 44 59 92 39 53 24 54 10 45 49
86 13 74 22 68 18 87 5 58 91 2 25 77 14 14 24 34 74 72 59 33 70 87 97 18 77-33686019
notice that last number in each array is really weird. Is there anything I can do to avoid this? btw this is two different arrays.
Thanks everyone that posted! I got it working!
You are reading one beyond the end of the array.
e.g. if you populate an array with 200 elements, you should write to and read from 0 to 199 not 0 to 200 or 1 to 200.
By the way - rand() % 100 will not make numbers from 0 to 100. It will make numbers from 0 to 99 only.
Also, as Randy Howard says (thanks), you can get a more even random generation by following the advice at http://www.azillionmonkeys.com/qed/random.html .
This is probably because there is something wrong with your code that prints the result. You might be looping from index 0 to 200, which has 201 items.
I counted your outputs and found there is 201 items, if the last 77-33686019 are actually 2 separate numbers.
If it's not that, you might have some printf/cout somewhere further down your code that actually prints some other value. To confirm this you can probably try printf ("\n"); right after your loop that outputs the array. If your negative number ends up on a different line, you'll know it's some other printf further down your code.
You might want to use int j = rand() % 101; instead so that you get 0 to 100. Your original code gives you the random range from 0 to 99.