How to add label on Distance File - Orange - cluster-analysis

How to add label to each object/ row in distance file in Orange?
I've tried as the example in this link
4
john 0.1
joe 0.5 0.3
jack 0.7 0.9 0.2
jane 0.2 0.8 0.6 0.5
but Orange give the following error:
Error while reading the file: 'invalid literal for int() with base 10:'john"

Example is broken. It should be like this:
4 labelled
john 0.1
joe 0.5 0.3
jack 0.7 0.9 0.2
jane 0.2 0.8 0.6 0.5

Related

How to put a border around a tikz figure with tcbox?

The following code produces the figure I want but only when I remove the \tcbox. I'd like a border around the figure. What I have done below works with other tikz figures. The problem seems to be with the table data. Can anyone please advise?
\begin{figure}
\tcbox{
\begin{tikzpicture}
\begin{axis}[
legend pos=south east,
xlabel=Variable 1, % label x axis
ylabel=Variable 2, % label y axis
]
\addplot[
scatter, only marks,
scatter/classes={
a={mark=square*,blue},
b={mark=triangle*,red}
}
]
table[x=x,y=y,meta=label]{
x y label
0.1 0.35 a
0.2 0.4 a
0.25 0.35 a
0.3 0.4 a
0.3 0.35 a
0.4 0.3 a
0.45 0.3 a
0.4 0.4 a
0.6 0.7 b
0.65 0.55 b
0.65 0.55 b
0.7 0.6 b
0.75 0.65 b
0.8 0.75 b
0.9 0.6 b
0.7 0.6 b
0.5 0.7 b
0.5 0.55 b
0.6 0.8 b
};
\legend{}
\end{axis}
\end{tikzpicture}
}
\caption{CAP HERE}
\label{statsexample}
\end{figure}
The issue is with your row separator. You can use row sep=crcr instead:
\begin{figure}
\tcbox{
\begin{tikzpicture}
\begin{axis}[
legend pos=south east,
xlabel=Variable 1, % label x axis
ylabel=Variable 2, % label y axis
]
\addplot[
scatter, only marks,
scatter/classes={
a={mark=square*,blue},
b={mark=triangle*,red}
}
]
table[x=x,y=y,meta=label,row sep=crcr]{
x y label\\
0.1 0.35 a\\
0.2 0.4 a\\
0.25 0.35 a\\
0.3 0.4 a\\
0.3 0.35 a\\
0.4 0.3 a\\
0.45 0.3 a\\
0.4 0.4 a\\
0.6 0.7 b\\
0.65 0.55 b\\
0.65 0.55 b\\
0.7 0.6 b\\
0.75 0.65 b\\
0.8 0.75 b\\
0.9 0.6 b\\
0.7 0.6 b\\
0.5 0.7 b\\
0.5 0.55 b\\
0.6 0.8 b\\
};
\end{axis}
\end{tikzpicture}
}
\caption{CAP HERE}
\label{statsexample}
\end{figure}

How to select the average value from 3 matrices

I am new to MATLAB and I need help. I have 3 matrices (A, B, and C) and I want to create a new matrix average_ABC that contains average values.
A = [ 0.3 0.5 0.9
0.14 0.36 0.1
0.9 0.5 0.14]
B = [ 0.8 0.9 0.14
0.1 0.25 0.4
0.8 0.14 0.25]
C = [0.25 0.3 0.47
0.12 0.3 0.2
0.14 0.56 0.9]
The resulting matrix will be
average_matrix = [ 0.3 0.5 0.47
0.12 0.25 0.2
0.8 0.5 0.25]
Please, any suggestion, how can I do it?
You can first concatenate your matrices along the third dimension (using cat) and then compute whatever you want using the dim parameter that is available for most functions to specify that you want to perform that operation along the third dimension.
Also you've stated that you want the average (mean), but based on your example you actually want the median. Either way, we can compute them using this method.
data = cat(3, A, B, C);
% Compute the mean
mean(data, 3)
% 0.45 0.56667 0.50333
% 0.12 0.30333 0.23333
% 0.61333 0.4 0.43
% Compute the median (which seems to be what you actually want)
median(data, 3)
% 0.3 0.5 0.47
% 0.12 0.3 0.2
% 0.8 0.5 0.25
I hope this will work
average_matrix=(A+B+C)/3.;

combining for loops in Matlab

I am trying to make a program in matlab to get this numbers:
0 1 0
0 0.8 0.2
0 0.6 0.4
0 0.4 0.6
0 0.2 0.8
0 0 1
0.1 0.9 0
0.1 0.7 0.2
0.1 0.5 0.4
0.1 0.3 0.6
0.1 0.1 0.8
0.1 0 0.9
and so on but I cant make the program to reduce the values of the second and third column when the first column increases. This is my code. Thanks
lai=0:0.1:1;
laj=1:-0.2:0;
lat=0:0.2:1;
for i=1,length(lai)
for j=1,i
for t=1,j
j
lam1(1,:)=lai;
lam2(1,:)=laj;
lam3(1,:)=lat;
end
end
end
Try this and do some thinking for what you require.
for i=0:0.1:0.1
for j=0:0.2:1
disp([i,j,1-j])
end
end

reshape matrix in matlab

I don't see the bug anymore...maybe (very probably :-) ) there's even a much more easier and faster way of doing it...
I summarized the important columns of my huge data frame in a little expData (see below).
The problem is actually quite easy, but I'm just blind for the easy idea of solving it..
My objective is to reshape columns b,c,d into one column that expData afterwards looks like expData2.
I would be really happy, if someone could help me out.
My code so far:
a = [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5]';
b = [0.3 0.3 0.3 0.3 0.3 0.4 0.4 0.4 0.4 0.4 0.5 0.5 0.5 0.5 0.5 0.8 0.8 0.8 0.8 0.8 0.9 0.9 0.9 0.9 0.9]';
c = [0.4 0.4 0.4 0.4 0.4 0.6 0.6 0.6 0.6 0.6 0.8 0.8 0.8 0.8 0.8 0.9 0.9 0.9 0.9 0.9 0.1 0.1 0.1 0.1 0.1]';
d = [0.5 0.5 0.5 0.5 0.5 0.1 0.1 0.1 0.1 0.1 0.7 0.7 0.7 0.7 0.7 0.2 0.2 0.2 0.2 0.2 0.3 0.3 0.3 0.3 0.3]';
e = rand(25,1);
f = rand(25,1);
a2 = [2 3 4 2 3 4 2 3 4 2 3 4 2 3 4]';
b2 = [0.3 0.4 0.5 0.4 0.6 0.1 0.5 0.8 0.7 0.8 0.9 0.2 0.9 0.1 0.3]';
c2 = rand(15,1);
d2 = rand(15,1);
expData = horzcat(a,b,c,d,e,f);
expData2 = horzcat(a2,b2,c2,d2); % for explanation of my objective
k = horzcat(expData(:,2),expData(:,3),expData(:,4))'; % How I wanted to do it
expData(:,2:4) = [];
k = reshape(k,[],1);
for index = 1:size(expData,1)
if expData(index,1) == 1
expData(index,:) = [];
end
if expData(index,1) == 5
expData(index,:) = [];
end
end
k = k(1:size(expData,1),:);
expData2 = [expData k];
Your current code throws an error, since the number of loop iterations gets determined at the beginning of the loop. As you are removing rows of expData, you run out of rows to index at some point.
The quick fix would be to start looping from the back, i.e. use for index = size(expData,1):-1:1. This way, you can safely remove rows without running into indexing problems.
The elegant fix is to use ismember to identify rows to remove:
rows2remove = ismember(expData(:,1),[1 5]);
expDate(rows2remove,:) = [];

Estimating two matrix using Hidden markov model toolbox in MATLAB

I am trying to apply Hidden Markov Model to improve my detection accuracy.
In my program, there are two states, 1 and 0. I used Bayes detector to generate the probability for each instance to be in class 1 and 0. For example, I have a sequence Actual states: 1 1 1 1 1 0 0 0 0 0
probability in class 1: 0.5 0.6 0.7 0.8 0.9 0.2 0.3 0.4 0.5 0.5
probability in class 0: 0.5 0.4 0.3 0.2 0.1 0.8 0.7 0.6 0.5 0.5
I tried to "use probability in class 1" as the "seq" and "Actual states" as "states" in function hmmestimate ([estimateTR, estimateE] = hmmestimate(seq,states);)
But it seems that "seq" must be integers, and I do not understand what is the requirement for the input arguments.
Thanks in advance!