当前位置: 首页 > news >正文

wordpress网站统计代码吴中seo页面优化推广

wordpress网站统计代码,吴中seo页面优化推广,谷歌推广开户多少费用,在哪下载.net网站作品主要借鉴此博客代码#xff1a;http://blog.csdn.net/sherry_gp/article/details/50560003 但是这个博主的代码达不到我想要的效果#xff0c;所以修改了一下 我想要实现的效果是#xff1a;给定一列的预测标签#xff0c;以及这一列标签的哪一部分理应属于哪一部分标签。…主要借鉴此博客代码http://blog.csdn.net/sherry_gp/article/details/50560003 但是这个博主的代码达不到我想要的效果所以修改了一下 我想要实现的效果是给定一列的预测标签以及这一列标签的哪一部分理应属于哪一部分标签。 此代码实现的功能是 给定条件给定预测标签为A[1 2 1 1 2 2 3 2 3 3 3 3 4 4 1 4]; 每一类标签总数为num[4 4 4 4]这里可以看出总共四类标签每类标签的样本数为4; 四个类名第一类、第二类、第三类、第四类 原始标签为A[1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4]; 实现结果每一类预测的准确率【也就是看A与B的差别在哪里】 代码【我修改的是compute_confusion_matrix.m其余和借鉴的博主提供的代码一样】 rotateXLabels.m function hh rotateXLabels( ax, angle, varargin ) %rotateXLabels: rotate any xticklabels % % hh rotateXLabels(ax,angle) rotates all XLabels on axes AX by an angle % ANGLE (in degrees). Handles to the resulting text objects are returned % in HH. % % hh rotateXLabels(ax,angle,param,value,...) also allows one or more % optional parameters to be specified. Possible parameters are: % MaxStringLength The maximum length of label to show (default inf) % % Examples: % bar( hsv(5)0.05 ) % days {Monday,Tuesday,Wednesday,Thursday,Friday}; % set( gca(), XTickLabel, days ) % rotateXLabels( gca(), 45 ) % % See also: GCA % BAR% Copyright 2006-2010 The MathWorks Ltd. % $Revision: 52 $ % $Date: 2010-09-30 11:19:49 0100 (Thu, 30 Sep 2010) $error( nargchk( 2, inf, nargin ) ); if ~isnumeric( angle ) || ~isscalar( angle )error( RotateXLabels:BadAngle, Parameter ANGLE must be a scalar angle in degrees ) end angle mod( angle, 360 );[maxStringLength] parseInputs( varargin{:} );% Get the existing label texts and clear them [vals, labels] findAndClearExistingLabels( ax, maxStringLength );% Create the new label texts h createNewLabels( ax, vals, labels, angle );% Reposition the axes itself to leave space for the new labelsrepositionAxes( ax );% If an X-label is present, move it too repositionXLabel( ax );% Store angle setappdata( ax, RotateXLabelsAngle, angle );% Only send outputs if requested if nargouthh h; end%-------------------------------------------------------------------------%function [maxStringLength] parseInputs( varargin )% Parse optional inputsmaxStringLength inf;if nargin 0params varargin(1:2:end);values varargin(2:2:end);if numel( params ) ~ numel( values )error( RotateXLabels:BadSyntax, Optional arguments must be specified as parameter-value pairs. );endif any( ~cellfun( isclass, params, char ) )error( RotateXLabels:BadSyntax, Optional argument names must be specified as strings. );endfor pp1:numel( params )switch upper( params{pp} )case MAXSTRINGLENGTHmaxStringLength values{pp};otherwiseerror( RotateXLabels:BadParam, Optional parameter %s not recognised., params{pp} );endendendend % parseInputs %-------------------------------------------------------------------------%function [vals,labels] findAndClearExistingLabels( ax, maxStringLength )% Get the current tick positions so that we can place our new labelsvals get( ax, XTick );% Now determine the labels. We look first at for previously rotated labels% since if there are some the actual labels will be empty.ex findall( ax, Tag, RotatedXTickLabel );if isempty( ex )% Store the positions and labelslabels get( ax, XTickLabel );if isempty( labels )% No labels!returnelseif ~iscell(labels)labels cellstr(labels);endend% Clear existing labels so that xlabel is in the right positionset( ax, XTickLabel, {}, XTickMode, Manual );setappdata( ax, OriginalXTickLabels, labels );else% Labels have already been rotated, so capture themlabels getappdata( ax, OriginalXTickLabels );delete(ex);end% Limit the length, if requestedif isfinite( maxStringLength )for ll1:numel( labels )if length( labels{ll} ) maxStringLengthlabels{ll} labels{ll}(1:maxStringLength);endendendend % findAndClearExistingLabels%-------------------------------------------------------------------------%function textLabels createNewLabels( ax, vals, labels, angle )% Work out the ticklabel positions % ylim get(ax,YLim); % y ylim(1);zlim get(ax,ZLim);z zlim(1);% We want to work% in normalised coords, but switch to normalised after setting% position causes positions to be rounded to the nearest pixel.% Instead we can do the calculation by hand.xlim get( ax, XLim );normVals (vals-xlim(1))/(xlim(2)-xlim(1));y 0;% Now create new text objects in similar positions. textLabels -1*ones( numel( vals ), 1 );for ll1:numel(vals)textLabels(ll) text( ...Units, Normalized, ...Position, [normVals(ll), y, z], ...String, labels{ll}, ...Parent, ax, ...Clipping, off, ...Rotation, angle, ...Tag, RotatedXTickLabel, ...UserData, vals(ll) );end% Now copy font properties into the textsupdateFont();% Depending on the angle, we may need to change the alignment. We change% alignments within 5 degrees of each 90 degree orientation.if 0 angle angle 5set( textLabels, HorizontalAlignment, Center, VerticalAlignment, Top );elseif 5 angle angle 85set( textLabels, HorizontalAlignment, Right, VerticalAlignment, Top );elseif 85 angle angle 95set( textLabels, HorizontalAlignment, Right, VerticalAlignment, Middle );elseif 95 angle angle 175set( textLabels, HorizontalAlignment, Right, VerticalAlignment, Bottom );elseif 175 angle angle 185set( textLabels, HorizontalAlignment, Center, VerticalAlignment, Bottom );elseif 185 angle angle 265set( textLabels, HorizontalAlignment, Left, VerticalAlignment, Bottom );elseif 265 angle angle 275set( textLabels, HorizontalAlignment, Left, VerticalAlignment, Middle );elseif 275 angle angle 355set( textLabels, HorizontalAlignment, Left, VerticalAlignment, Top );else % 355-360set( textLabels, HorizontalAlignment, Center, VerticalAlignment, Top );endend % createNewLabels%-------------------------------------------------------------------------%function repositionAxes( ax )% Reposition the axes so that theres room for the labels% Note that we only do this if the OuterPosition is the thing being% controlledif ~strcmpi( get( ax, ActivePositionProperty ), OuterPosition )return;end% Work out the maximum height required for the labelstextLabels findall( ax, Tag, RotatedXTickLabel );maxHeight 0;for ii1:numel(vals)ext get( textLabels(ii), Extent );if ext(4) maxHeightmaxHeight ext(4);endend% Remove listeners while we mess around with things, otherwise well% trigger redraws recursivelyremoveListeners( ax );% Change to normalized units for the position calculationoldUnits get( ax, Units );set( ax, Units, Normalized );% Not sure why, but the extent seems to be proportional to the height of the axes.% Correct that now.set( ax, ActivePositionProperty, Position );pos get( ax, Position );axesHeight pos(4);% Make sure we dont adjust away the axes entirely!heightAdjust min( (axesHeight*0.9), maxHeight*axesHeight );% Move the axesif isappdata( ax, OriginalAxesPosition )pos getappdata( ax, OriginalAxesPosition );elsepos get(ax,Position);setappdata( ax, OriginalAxesPosition, pos );endsetappdata( ax, PreviousYLim, get( ax, YLim ) );set( ax, Position, pos[0 heightAdjust 0 -heightAdjust] )set( ax, Units, oldUnits );set( ax, ActivePositionProperty, OuterPosition );% Make sure we find out if axes properties are changedaddListeners( ax );end % repositionAxes%-------------------------------------------------------------------------%function repositionXLabel( ax )% Try to work out where to put the xlabelremoveListeners( ax );textLabels findall( ax, Tag, RotatedXTickLabel );maxHeight 0;for ll1:numel(vals)ext get( textLabels(ll), Extent );if ext(4) maxHeightmaxHeight ext(4);endend% Use the new max extent to move the xlabelxlab get(ax,XLabel);set( xlab, Units, Normalized, Position, [0.5 -maxHeight 0] );addListeners( ax );end % repositionXLabel%-------------------------------------------------------------------------%function updateFont()% Update the rotated text fonts when the axes font changesproperties {FontNameFontSizeFontAngleFontWeightFontUnits};propertyValues get( ax, properties );textLabels findall( ax, Tag, RotatedXTickLabel );set( textLabels, properties, propertyValues );end % updateFont%-------------------------------------------------------------------------%function onAxesFontChanged()updateFont();repositionAxes( ax );repositionXLabel( ax );end % onAxesFontChanged%-------------------------------------------------------------------------%function onAxesPositionChanged()% We need to accept the new position, so remove the appdata before% redrawingif isappdata( ax, OriginalAxesPosition )rmappdata( ax, OriginalAxesPosition );endif isappdata( ax, OriginalXLabelPosition )rmappdata( ax, OriginalXLabelPosition );endrepositionAxes( ax );repositionXLabel( ax );end % onAxesPositionChanged%-------------------------------------------------------------------------%function onAxesLimitsChanged()% The limits have moved, so make sure the labels are still oktextLabels findall( ax, Tag, RotatedXTickLabel );xlim get( ax, XLim );for tt1:numel( textLabels )xval get( textLabels(tt), UserData );pos(1) (xval-xlim(1)) / (xlim(2)-xlim(1));pos(2) 0;% If the tick is off the edge, make it invisibleif xvalxlim(1) || xvalxlim(2)set( textLabels(tt), Visible, off, Position, pos )elseif ~strcmpi( get( textLabels(tt), Visible ), on )set( textLabels(tt), Visible, on, Position, pos )else% Just set the positionset( textLabels(tt), Position, pos );endendrepositionXLabel( ax );% xlab get(ax,XLabel); % if ~strcmpi( get( xlab, Units ), Data ) % set( xlab, Units, data ); % end % pos get( xlab, Position ); % orig_yrange diff( orig_ylim ); % new_yrange diff( ylim ); % offset (pos(2)-orig_ylim(1)) / orig_yrange; % pos(2) offset * new_yrange ylim(1); % pos(1) mean( xlim ); % set( xlab, Position, pos ); % setappdata( ax, PreviousYLim, ylim );end % onAxesPositionChanged%-------------------------------------------------------------------------%function addListeners( ax )% Create listeners. We store the array of listeners in the axes to make% sure that they have the same life-span as the axes they are listening to.axh handle( ax );listeners [handle.listener( axh, findprop( axh, FontName ), PropertyPostSet, onAxesFontChanged )handle.listener( axh, findprop( axh, FontSize ), PropertyPostSet, onAxesFontChanged )handle.listener( axh, findprop( axh, FontWeight ), PropertyPostSet, onAxesFontChanged )handle.listener( axh, findprop( axh, FontAngle ), PropertyPostSet, onAxesFontChanged )handle.listener( axh, findprop( axh, FontUnits ), PropertyPostSet, onAxesFontChanged )handle.listener( axh, findprop( axh, OuterPosition ), PropertyPostSet, onAxesPositionChanged )handle.listener( axh, findprop( axh, XLim ), PropertyPostSet, onAxesLimitsChanged )handle.listener( axh, findprop( axh, YLim ), PropertyPostSet, onAxesLimitsChanged )];setappdata( ax, RotateXLabelsListeners, listeners );end % addListeners%-------------------------------------------------------------------------%function removeListeners( ax )% Rempove any property listeners whilst we are fiddling with the axesif isappdata( ax, RotateXLabelsListeners )delete( getappdata( ax, RotateXLabelsListeners ) );rmappdata( ax, RotateXLabelsListeners );endend % removeListenersend % EOFdraw_cm.mfunction draw_cm(mat,tick,num_class) %% % Matlab code for visualization of confusion matrix; % Parametersmat: confusion matrix; % tick: name of each class, e.g. class_1 class_2... % num_class: number of class % % Author Page( 丕子) % Blog: www.shamoxia.com; % QQ:379115886; % Email: peegeeleegmail.com %% imagesc(1:num_class,1:num_class,mat); %# in color colormap(flipud(gray)); %# for gray; black for large value.textStrings num2str(mat(:),%0.2f); textStrings strtrim(cellstr(textStrings)); [x,y] meshgrid(1:num_class); hStrings text(x(:),y(:),textStrings(:), HorizontalAlignment,center); midValue mean(get(gca,CLim)); textColors repmat(mat(:) midValue,1,3); set(hStrings,{Color},num2cell(textColors,2)); %# Change the text colorsset(gca,xticklabel,tick,XAxisLocation,top); set(gca, XTick, 1:num_class, YTick, 1:num_class); set(gca,yticklabel,tick); rotateXLabels(gca, 315 );% rotate the x tickcompute_confusion_matrix.mfunction [confusion_matrix]compute_confusion_matrix(predict_label,num_in_class,name_class)%预测标签每一类的数目类别数目 %predict_label为一维行向量 %num_in_class代表每一类的个数 %name_class代表类名 num_classlength(num_in_class); num_in_class[0 num_in_class]; confusion_matrixsize(num_class,num_class);for ci1:num_classfor cj1:num_classsummer0;%统计对应标签个数c_startsum(num_in_class(1:ci))1;c_endsum(num_in_class(1:ci1));summersize(find(predict_label(c_start:c_end)cj),2);confusion_matrix(ci,cj)summer/num_in_class(ci1);end enddraw_cm(confusion_matrix,name_class,num_class);end测试代码testm.m addpath(./ConfusionMatrices) A[1 2 1 1 2 2 3 2 3 3 3 3 4 4 1 4]; num[4 4 4 4]; namecell(1,4); name{1}haha;name{2}hehe;name{3}nani;name{4}ok; compute_confusion_matrix(A,num,name)【附】直接用我借鉴的博客的代码得到的结果如下
http://www.pierceye.com/news/936770/

相关文章:

  • 做定制网站怎么样原创网站设计
  • 淮安网站建设 淮安网站制作反向代理wordpress
  • 七台河北京网站建设深圳营销策划
  • 陕西西乡网站建设如何做网站效果图
  • 三门峡高端网站建设临安建设规划局网站
  • 可信网站认证哪里有网站建设分金手指排名一
  • 十大品牌网站建设专业网站的利弊
  • 如何查看网站域名360seo
  • 苏州网站设计kgwl手机网站全屏代码
  • 网站开发工程师就业前景免费企业网站模板
  • 网站建设额企业建设网站对客户的好处
  • 济南网站制作设计公司WordPress文章相册修改
  • 购物网站建设思维导构图电商平台建设方案
  • 一个网站一年的费用多少惠州网站制作哪里好
  • 网站界面设计材料收集国内外包网站
  • 自如网站做的好 服务网站开发实训
  • 档案网站建设的意义网页制作工具可以分为
  • 网站建设价格是哪些方面决定的wordpress32m
  • 建设公司网站哪家好网站建设 中企动力洛阳分公司
  • 如何做自己的大淘客网站开公司建网站
  • 在线网站设计工具腾讯做的电子商务网站
  • 重庆建设工程证照查询网站东莞松山湖
  • 唐山市政建设总公司网站南阳网站推广招聘
  • wordpress搭建网站网站建立网络优化
  • 杭州住房和城乡建设部网站东莞常平粤海水务
  • 网站设计方案案例yw55516can优物入口
  • 重庆有哪些做网站公司好丹东 建设集团 招聘信息网站
  • 深圳高端网站建设建设凡科网站
  • 类似织梦的建站cms百度广州分公司待遇
  • 仿qq商城版淘宝客网站源码模板+带程序后台文章dede织梦企业程序上海专业制作网页