Misclassification in Binary SVM - java

Given a dataset
0 0 1
3 4 1
5 9 1
12 1 1
8 7 1
9 8 -1
6 12 -1
10 8 -1
8 5 -1
14 8 -1
When applied SVM on these train data,
3 4 1,8 7 1 and 6 12 -1 are missclassified.
What does it mean--
whether the datapoint 3 4 doesnot fall in class label 1 and but falls in -1.
Is it like that?

Yes, it means that the model you have calibrated yields :
3 4 => -1
8 7 => -1
6 12=> +1
You have an error rate of 30%.
Using linear discriminant analysis approach, you can have a 20% error rate.
But keep in mind that you do not have much elements in your population (only 10). This is relatively low for 2 descriptors.
Indeed, if you estimate the error rate with a bootstrap method, we find out :
A 60% error rate for discriminant analysis approach
A 55% error rate for SVM approach : SVM is often more robust to overfitting.
Cheers

Related

Give a part of chessboard of 15-puzzle, how to get all of the state of the the part chessboard using BFS?

the board is like this:
1 2 3 4
5 6 7 0
0 0 0 0
0 0 0 0
the '0' represents that is empty, we can move the non-zero number to the '0'.
so how to get all of the state of the board using BFS?
for example, there are two state of the board:
1 2 3 4
0 0 0 0
5 6 7 0
0 0 0 0
1 2 3 0
4 0 0 0
5 0 0 0
6 7 0 0
The reason I ask this question is that I need to process all of the 15-puzzle state using Disjoint pattern database to solve the nearly most difficult state of 15-puzzle in 1 minutes.
15 14 13 12
11 10 9 8
7 6 5 4
3 1 2 0
I need to process all of the 15-puzzle state [..] to solve the nearly most difficult state of 15-puzzle in 1 minutes
Approach 1 - using a database and storing all states
For reasons given by Henry as well, and also supported by [1], solving this problem using a database would require generating the entire A_15 , storing all of it and then finding the shortest path, or some path between a given state and the solved state. This would require a lot of space and a lot of time. See this discussion for an outline of this approach.
Approach 2 - using a specialized depth-first search algorithm
Here is an implementation of this search strategy that uses the IDA algorithm.
Approach 3 - using computational group theory
Yet another way to handle this in a much shorter amount of time is to use GAP (which implements a variant of Schreier-Sims) in order to decompose a given word into a product of generators. There is an example in the docs that shows how to use it to solve the Rubik's cube, and it can be adapted to the 15-puzzle too [2].
[1] Permutation Puzzles - A Mathematical Perspective by Jamie Mulholland - see page 103 and 104 for solvability criteria, and the state space being |A_15| ~ 653 billion
[2] link2 - page 37

Backtracking chopsticks in java

I have an exercise that is killing my brain; which is:
I have x sticks, and I break them into x chunks which I measure, they are a vector of numbers, the solution to the problem is to find the minimum number to create sticks of the same size:
Sample input
9
5 2 1 5 2 1 5 2 1
4
1 2 3 4
0 (this is the end of the input it have to be there)
Sample output
6
5

How to calculate time needed through multiple routes?

For example, with input like:
4 6 7
1 2 6 2
......//more routes statement same format as second line
1 4
It means there are 4 places in total, and 6 routes in total, with 7cm convex hull of the ship(From the first line). The next 6 lines states where does the route connect, time needed and how many cm of the hull were worn down in the process. (In the second line, the route connects 1 and , takes 6 minutes, and wore down the hull by 2. The last line states where the starting point and destination are (1 and 4 in this case). The goal for this program is to get the minimum time used with the hull not completely worn down. I had tried using a
map(starting point of a route, end point);
but I can't really assign time used or the number of hull worn down this way, since multiple route can have the same starting point, meaning the two locations can't be used as a key like
map(starting point, time);
Also
Matrix[boolean][boolean]
doesn't seem to be an effective way to do this question. What technique should I use for this program and how do I do it?
Complete example with input:
10 4 7
1 2 4 4
1 3 7 2
3 1 8 1
3 2 2 2
4 2 1 6
3 4 1 1
1 4 6 12
1 4
output:
7
The routes can be used in two directions.

Limit Rows in Result Set By Column Values

This question deals with building a correct Criteria in Hibernate for the following case.
Suppose I start with a table like this:
id ts metric value carrier
1 1 distance 4 alice
2 1 count 2 alice
3 2 distance 3 alice
4 2 count 1 alice
5 1 distance 3 becky
6 1 count 2 becky
7 2 distance 4 becky
8 2 count 1 becky
9 1 distance 10 other
10 1 count 10 other
11 2 distance 10 other
12 2 distance 10 other
What this is is a time-bucketed set of metrics recording how far alice, becky and a general other carried some count of items some distance.
I'd like to roll it up in the following fashion: metrics with 'other' or the 'winner' as decided by distance for each time bucket are kept. Thus, the above table would yield the following result set:
id ts metric value carrier
1 1 distance 4 alice
2 1 count 2 alice
7 2 distance 4 becky
8 2 count 1 becky
9 1 distance 10 other
10 1 count 10 other
11 2 distance 10 other
12 2 distance 10 other
Ultimately this is translated to this:
ts carrier distance count
1 alice 4 2
1 other 10 10
2 becky 4 1
2 other 10 10
But this translation I already understand how to do. What I'm unclear on is how to build the criteria to keep the 'top n' metrics. Which brings us to the wrinkle: while this example is simplified, there would be a large number of 'carriers', and what I'm interested in is the top n such carriers, discarding the rest. Thus in the example above n = 1, but it's likely to be greater than 1 in most cases.
I know that I can use addOrder(Order.desc("value"), but that poses both a problem in that other is intermixed and distances and counts will be incorrectly intermingled. I'm looking for something that sorts 'blocks' of rows which are decided, in order by ts, then carrier, then using the metric = "distance" for the sort order.

How to create guitar chord variation?

I'm trying to create guitar chord application but the chord chart for a single chord is too many. Listing all would take time and not efficient. For example, C major chord has variation such as the chart below
x 3 2 0 1 0
x 3 2 0 1 3
x 3 5 5 5 0
8 10 10 9 8 8
Is there any way that the chart can be generated by with/without knowing the keys to create the chord? ie, CEG for chord C major.
Contrary to the comments I think this is possible. If you got all of the open chord shapes such as..
0 2 2 1 0 0 (open E)
0 0 2 2 2 0 (open A)
0 3 2 0 1 0 (open C)
X 0 0 2 3 2 (open D)
Then you can shift them up using bar chords and you should be able to write code to calculate all the permutations for a particular chord. For example if you wanted all the C major triads (as in your question) you know one is
0 3 2 0 1 0 (open C)
But you also know one of them is the open A shape above but shifted UP 3 frets...
3 3 5 5 5 3 (open A shifted up as a bar chord)
This is your third chord in your question. You can also calculate where to shift the open E shape, which would be...
8 10 10 7 8 8
Again, this is one of the chords in your question. This way you can calculate all the positions for any chord using code - providing you have a sufficient set of open chords that can be comfortably shifted up like this.
So your set of C chords using these initial open shapes would be...
C Chords...
8 10 10 7 8 8
3 3 5 5 5 3
0 3 2 0 1 0
X 10 10 12 14 12
Now if you wanted to know the set of D chords you can actually calculate these by adding 2 to all the numbers above (two of them wrap around an octave but you can work this into a calculation)
D Chords...
10 12 12 11 10 10
5 5 7 7 7 5
10 13 12 10 11 10
X 0 0 2 3 2
Have you ever seen the book called "Fret Logic"? It shows the mathematical logic of the guitar fretboard.
There are also shortcut versions of most chords, such as the nice 3 string version used a lot in cross picking:
x
x
x
x
5
5
3
This is a shortened version the C chord in the A position, but it is used a lot.

Categories

Resources