Rank: 127640 based on 0 downloads (last 30 days) and 0 file submitted
photo

AMB

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Comments and Ratings by AMB View all
Updated File Comments Rating
23 Jun 2013 setFigTransparency - set figure transparency / fading setFigTransparency sets the transparency/opacity of a figure window, with optional fading effect Author: Yair Altman

I think this function is fantastic and I want to keep it useful, I am on a MAC and Using Matlab 8.1.0.604 (R2013a), the line

figure(2);plot([0 0],[1 1]);shg;setFigTransparency(gcf)

works fine; however Using Matlab 8.2.0.89 (R2013b), with Java 1.7.0_11-b21 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode, the same line produces an error

figure(2);plot([0 0],[1 1]);shg;setFigTransparency(gcf)
Error using setFigTransparency (line 137)
Java exception occurred:
java.awt.IllegalComponentStateException: The frame is decorated
at java.awt.Frame.setOpacity(Frame.java:960)
at java.awt.Window$1.setOpacity(Window.java:4008)
at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174)

which prevents the figure from becoming transparent.

Below is some standalone code which when pasted in the commandwindow will quickly show the problem

figure(2);set(gcf,'color',[1 0 0]);
plot([0 0],[1 1]);
drawnow;
shg;

[lastWarnMsg lastWarnId] = lastwarn;
oldJFWarning=warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
jFigPeer=get(gcf,'JavaFrame');
warning(oldJFWarning.state, 'MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
lastwarn(lastWarnMsg, lastWarnId);
jWindow = jFigPeer.fHG1Client.getWindow;
newAlpha = .5;
com.sun.awt.AWTUtilities.setWindowOpacity(jWindow,newAlpha);

% throws the following exception in 8.2.0.89 (R2013b) and does not in 8.1.0.604 (R2013a)
% Java exception occurred:
% java.awt.IllegalComponentStateException: The frame is decorated
% at java.awt.Frame.setOpacity(Frame.java:960)
% at java.awt.Window$1.setOpacity(Window.java:4008)
% at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities.java:174)

jWindow.repaint;

Are there any workarounds?

20 Nov 2012 Random Points in an n-Dimensional Hypersphere Randomly and uniformly distributes points throughout a hypersphere. Author: Roger Stafford

Hi - This post is in reference to Laurent's comments.

Using this sample code, we see that Laurent's code substitution is faster, but the result is different from the original. Laurent's modification appears to produce data that spans a different radius than the original and is comprised of data which when viewed on the screen in a 2D projection appears more centrally clustered. The original code produces more defined boundaries.

Both ideas may have their own virtues depending on application.

m = 30000;n = 2; r = 2;
X = randn(m,n);
s2 = sum(X.^2,2);
tic
X = X.*repmat(r*(gammainc(s2/2,n/2).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,1);plot(X(:,1),X(:,2),'r.','markersize',1);
axis equal;zoom off; zoom on;drawnow;shg;
ax = axis;

tic
X = X.*repmat(r*(rand(m,1).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,2);plot(X(:,1),X(:,2),'r.','markersize',1);
axis equal;zoom off; zoom on;drawnow;shg;
axis(ax);

pause

m = 30000;n = 3; r = 2;
X = randn(m,n);
s2 = sum(X.^2,2);
tic
X = X.*repmat(r*(gammainc(s2/2,n/2).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,1);plot3(X(:,1),X(:,2),X(:,3),'r.','markersize',1);
axis equal;rotate3d off; rotate3d on;drawnow;shg;
ax = axis;

tic
X = X.*repmat(r*(rand(m,1).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,2);plot3(X(:,1),X(:,2),X(:,3),'r.','markersize',1);
axis equal;rotate3d off; rotate3d on;drawnow;shg;
axis(ax);

pause

m = 30000;n = 20; r = 2;
X = randn(m,n);
s2 = sum(X.^2,2);
tic
X = X.*repmat(r*(gammainc(s2/2,n/2).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,1);plot3(X(:,1),X(:,2),X(:,3),'r.','markersize',1);
axis equal;rotate3d off; rotate3d on;drawnow;shg;
ax = axis;

tic
X = X.*repmat(r*(rand(m,1).^(1/n))./sqrt(s2),1,n);
toc
subplot(1,2,2);plot3(X(:,1),X(:,2),X(:,3),'r.','markersize',1);
axis equal;rotate3d off; rotate3d on;drawnow;shg;
axis(ax);

12 Jun 2011 Random Forest Creates an ensemble of cart trees similar to the matlab TreeBagger class. Author: Leo

Hi - the zip file that I can download now has the same creation date as the old - requires all the changes I made in order to run it, and performs the same as well - please advise

03 Jun 2011 Random Forest Creates an ensemble of cart trees similar to the matlab TreeBagger class. Author: Leo

Hi - Will you be posting the new code? - I would like to try it out on regression - Right now, when I use the old code on the classic Boston Housing data set, I get all NaNs. I would like to see if this problem disappears in the code you fixed.

31 May 2011 Random Forest Creates an ensemble of cart trees similar to the matlab TreeBagger class. Author: Leo

Hi - I have followed your suggestion to compare the results of your code versus the "google code". This google code is at

http://code.google.com/p/randomforest-matlab/

This is a Matlab (and Standalone application) port for the excellent machine learning algorithm `Random Forests' - By Leo Breiman et al. from the R-source by Andy Liaw et al. http://cran.r-project.org/web/packages/randomForest/index.html ( Fortran original by Leo Breiman and Adele Cutler, R port by Andy Liaw and Matthew Wiener.) Current code version is based on 4.5-29 from source of randomForest package by Abhishek Jaiantilal.

Against the "glass" data set here are the statistics for 10 and 100 trees, withholding the 35% of the data as you had done.

For RandomBosque, the results were:

Elapsed time for 1000 runs: 1648.743 seconds
Average number correct with 35% samples held out: 0.636 for 10 trees 0.684 for 100 trees
Standard deviation correct with 35% samples held out: 0.076 for 10 trees 0.070 for 100 trees

For class_RFtrain and classRFpredict, the results were:

Elapsed time for 1000 runs: 88.021 seconds
Average number correct with 35% samples held out: 0.722 for 10 trees 0.758 for 100 trees
Standard deviation correct with 35% samples held out: 0.051 for 10 trees 0.048 for 100 trees

I use a MACAIR with MATLAB 2011a and OS 10.6.7.
I was surprised at the runtime differences and the differences in the statistics.

My calls to Randombosque look as follows:

tic;
correct = zeros(1000,2);
for i = 1:length(correct);

M = length(Labels);
m = round(.65*M);
intraining = randperm(M);
intraining = sort(intraining(1:m));
notintraining = setdiff([1:M],intraining);

Random_Forest = Stochastic_Bosque(Data(intraining,:),Labels(:,intraining),'ntrees',10);
[f_output f_votes] = eval_Stochastic_Bosque(Data(notintraining,:),Random_Forest);
error = Labels(:,notintraining)'-f_output;
correctlyclassified = numel(find(error == 0))/numel(error);
correct(i,1) = correctlyclassified;

Random_Forest = Stochastic_Bosque(Data(intraining,:),Labels(:,intraining),'ntrees',100);
[f_output f_votes] = eval_Stochastic_Bosque(Data(notintraining,:),Random_Forest);
error = Labels(:,notintraining)'-f_output;
correctlyclassified = numel(find(error == 0))/numel(error);
correct(i,2) = correctlyclassified;

if rem(i,25) == 1
fprintf('Iteration: %3.0f\n',i);
end
end
toc;

fprintf('Elapsed time for %3.0f runs: %5.3f seconds\n',length(correct),toc)
fprintf('Average number correct with 35%% samples held out: %5.3f for 10 trees %5.3f for 100 trees \n',mean(correct));
fprintf('Standard deviation correct with 35%% samples held out: %5.3f for 10 trees %5.3f for 100 trees\n',std(correct));

Contact us