adding requests to conda install docs
[JPSSData.git] / plot_svm.m
blob26acdcb604875140f19d4ae30eac2c1a0654cfc1
1 function plot_svm(svm_file)
2 % Call:
3 % plot_results(svm_file)
5 % Description:
6 % Plots the results in the output file from Support Vector Machine
8 % Inputs:
9 %   svm_file     matlab output file from Support Vector Machine
11 % Developed in Matlab 9.2.0.556344 (R2017a) on MACINTOSH.
12 % Angel Farguell (angel.farguell@gmail.com), 2019-03-21
13 %-------------------------------------------------------------------------
15 r = load(svm_file);
16 if isfield(r,'U')
17     uu = r.U;
18     uu(uu==max(uu(:))) = nan;
19     ll = r.L;
20     ll(ll==min(ll(:))) = nan;
22     dd = .1;
23     bb = [min(r.dxlon(~isnan(uu)))-dd, max(r.dxlon(~isnan(uu)))+dd, min(r.dxlat(~isnan(uu)))-dd, max(r.dxlat(~isnan(uu)))+dd];
24     figure
25     S = repmat(5,sum(sum(~isnan(uu))),1);
26     C = repmat([1,0,0],sum(sum(~isnan(uu))),1);
27     h1 = scatter3(r.dxlon(~isnan(uu)), r.dxlat(~isnan(uu)), uu(~isnan(uu)), S, C, 'filled');
28     alpha = 0.7;
29     set(h1, 'MarkerEdgeAlpha', alpha, 'MarkerFaceAlpha', alpha)
30     hold on
31     ml = logical((r.dxlon >= bb(1)).*(r.dxlon <= bb(2)).*(r.dxlat >= bb(3)).*(r.dxlat <= bb(4)));
32     S = repmat(2,sum(sum(ml)),1);
33     C = repmat([0.2,0.7,0.2],sum(sum(ml)),1);
34     h2 = scatter3(r.dxlon(ml), r.dxlat(ml), ll(ml), S, C, 'filled');
35     alpha = 0.3;
36     set(h2, 'MarkerEdgeAlpha', alpha, 'MarkerFaceAlpha', alpha)
37     hold on
38     contour3(r.fxlon,r.fxlat,r.Z,100)
39     xlim([bb(1),bb(2)])
40     ylim([bb(3),bb(4)])
41     title('Support-vector machine: Satellite detections vs fire arrival time')
42     xlabel('Longitude')
43     ylabel('Latitude')
44     zlabel('Time (days)')
46     figure
47     scatter3(r.dxlon(~isnan(uu)), r.dxlat(~isnan(uu)), uu(~isnan(uu)), 'r.')
48     hold on
49     contour3(r.fxlon,r.fxlat,r.Z,100)
50     title('Support-vector machine: Fire detections vs fire arrival time')
51     xlabel('Longitude')
52     ylabel('Latitude')
53     zlabel('Time (days)')
54 else
55     ground = (r.y==-1);
56     fire = (r.y==1);
58     xmin = min(r.X(:,1));
59     xmax = max(r.X(:,1));
60     ymin = min(r.X(:,2));
61     ymax = max(r.X(:,2));
62     zmin = min(r.X(:,3));
63     zmax = max(r.X(:,3));
65     figure,
66     S = repmat(10,sum(fire),1);
67     C = repmat([1,0,0],sum(fire),1);
68     h1 = scatter3(r.X(fire,1),r.X(fire,2),r.X(fire,3),S,C,'filled');
69     alpha = 0.7;
70     set(h1, 'MarkerEdgeAlpha', alpha, 'MarkerFaceAlpha', alpha)
71     hold on
72     S = repmat(10,sum(ground),1);
73     C = repmat([0.2,0.7,0.2],sum(ground),1);
74     h2 = scatter3(r.X(ground,1),r.X(ground,2),r.X(ground,3),S,C,'filled');
75     alpha = 0.3;
76     set(h2, 'MarkerEdgeAlpha', alpha, 'MarkerFaceAlpha', alpha)
77     hold on
78     contour3(r.fxlon,r.fxlat,r.Z,100)
79     xlim([xmin,xmax]), ylim([ymin,ymax]), zlim([zmin,zmax]);
80     title('Support-vector machine: Satellite detections vs fire arrival time')
81     xlabel('Longitude')
82     ylabel('Latitude')
83     zlabel('Time (days)')
85     figure, 
86     scatter3(r.X(fire,1), r.X(fire,2), r.X(fire,3), 'r.')
87     hold on
88     contour3(r.fxlon,r.fxlat,r.Z,100)
89     xlim([xmin,xmax]), ylim([ymin,ymax]), zlim([zmin,zmax]);
90     title('Support-vector machine: Fire detections vs fire arrival time')
91     xlabel('Longitude')
92     ylabel('Latitude')
93     zlabel('Time (days)')
94 end
96 end