applying_mda第二章
- 格式:pdf
- 大小:1.92 MB
- 文档页数:34
Package‘multiApply’March28,2023Title Apply Functions to Multiple Multidimensional Arrays or VectorsVersion2.1.4Description The base apply function and its variants,as well as the related functions in the'plyr'package,typically apply user-defined functions to asingle argument(or a list of vectorized arguments in the case of mapply).The'multiApply'package extends this paradigm with its only function,Apply,which efficiently applies functions taking one or a list of multiple unidimensionalor multidimensional arrays(or combinations thereof)as input.The inputarrays can have different numbers of dimensions as well as different dimensionlengths,and the applied function can return one or a list of unidimensional ormultidimensional arrays as output.This saves development time by preventing the R user from writing often error-prone and memory-inefficient loops dealing with multiple complex arrays.Also,a remarkable feature of Apply is the transparentuse of multi-core through its parameter'ncores'.In contrast to the base applyfunction,this package suggests the use of'target dimensions'as oppositeto the'margins'for specifying the dimensions relevant to the function to beapplied.Depends R(>=3.2.0)Imports doParallel,foreach,plyrSuggests testthatLicense GPL-3URL https://earth.bsc.es/gitlab/ces/multiApplyBugReports https://earth.bsc.es/gitlab/ces/multiApply/-/issues Encoding UTF-8RoxygenNote7.2.0NeedsCompilation noAuthor BSC-CNS[aut,cph],Nicolau Manubens[aut],Alasdair Hunter[aut],An-Chi Ho[ctb,cre],Nuria Perez[ctb]Maintainer An-Chi Ho<************>1Repository CRANDate/Publication2023-03-2813:10:08UTCR topics documented:Apply (2)Index6 Apply Apply Functions to Multiple Multidimensional Arrays or VectorsDescriptionThis function efficiently applies a given function,which takes N vectors or multi-dimensional arrays as inputs(which may have different numbers of dimensions and dimension lengths),and applies it to a list of N vectors or multi-dimensional arrays with at least as many dimensions as expected by the given function.The user can specify which dimensions of each array the function is to be applied over with the margins or target_dims parameters.The function to be applied can receive other helper parameters and return any number of vectors or multidimensional arrays.The target dimensions or margins can be specified by their names,as long as the inputs are provided with dimension names(recommended).This function can also use multi-core in a transparent way if requested via the ncores parameter.The following steps help to understand how Apply works:-The function receives N arrays with Dn dimensions each.-The user specifies,for each of the arrays,which of its dimensions are’target’dimensions(dimen-sions which the function provided in’fun’operates with)and which are’margins’(dimensions to be looped over).-Apply will generate an array with as many dimensions as margins in all of the input arrays.If a margin is repeated across different inputs,it will appear only once in the resulting array.-For each element of this resulting array,the function provided in the parameter’fun’is applied to the corresponding sub-arrays in’data’.-If the function returns a vector or a multidimensional array,the additional dimensions will be prepended to the resulting array(in left-most positions).-If the provided function returns more than one vector or array,the process above is carried out for each of the outputs,resulting in a list with multiple arrays,each with the combination of all target dimensions(at the right-most positions)and resulting dimensions(at the left-most positions). UsageApply(data,target_dims=NULL,fun,...,output_dims=NULL,margins=NULL,use_attributes=NULL,extra_info=NULL,guess_dim_names=TRUE,ncores=NULL,split_factor=1)Argumentsdata One or a list of vectors,matrices or arrays.They must be in the same order as expected by the function provided in the parameter’fun’.The dimensions donot necessarily have to be ordered.If the’target_dims’require a different orderthan the provided,Apply will automatically reorder the dimensions as needed.target_dims One or a list of vectors(or NULLs)containing the dimensions to be input into fun for each of the objects in the data.If a single vector of target dimensionsis specified and multiple inputs are provided in’data,then the single set of tar-get dimensions is re-used for all of the inputs.These vectors can contain eitherintegers specifying the position of the dimensions,or character strings corre-sponding to the dimension names.This parameter is mandatory if’margins’arenot specified.If both’margins’and’target_dims’are specified,’margins’takespriority.fun Function to be applied to the arrays.Must receive as many inputs as provided in’data’,each with as many dimensions as specified in’target_dims’or as thetotal number of dimensions in’data’minus the ones specified in’margins’.Thefunction can receive other additionalfixed parameters(see parameter’...’ofApply).The function can return one or a list of vectors or multidimensionalarrays,optionally with dimension names which will be propagated to thefinalresult.The returned list can optionally be named,with a name for each output,which will be propagated to the resulting array.The function can optionally beprovided with the attributes’target_dims’and’output_dims’.In that case,thecorresponding parameters of Apply do not need to be provided.The function canexpect named dimensions for each of its inputs,in the same order as specifiedin’target_dims’or,if no’target_dims’have been provided,in the same order asprovided in’data’.The function can access the variable.margin_indices,anamed numeric vector that provides the indices of the current iteration over themargins,as well as any other variables specified in the parameter extra_infoor input attributes specified in the parameter use_attributes....Additionalfixed arguments expected by the function provided in the parameter ’fun’.output_dims Optional list of vectors containing the names of the dimensions to be output from the fun for each of the objects it returns(or a single vector if the functionhas only one output).margins One or a list of vectors(or NULLs)containing the’margin’dimensions to be looped over for each input in’data’.If a single vector of margins is specified andmultiple inputs are provided in’data’,then the single set of margins is re-used forall of the inputs.These vectors can contain either integers specifying the positionof the margins,or character strings corresponding to the dimension names.Ifboth’margins’and’target_dims’are specified,’margins’takes priority.use_attributes List of vectors of character strings with names of attributes of each object in ’data’to be propagated to the subsets of data sent as inputs to the function speci-fied in’fun’.If this parameter is not specified(NULL),all attributes are dropped.This parameter can be specified as a named list(then the names of this list mustmatch those of the names of parameter’data’),or as an unnamed list(then thevectors of attribute names will be assigned in order to the input arrays in’data’).extra_info Named list of extra variables to be defined for them to be accessible from within the function specified in’fun’.The variable names will automatically be prependeda heading dot(’.’).So,if the variable’name="Tony"’is sent through this pa-rameter,it will be accessible from within’fun’via’.name’.guess_dim_namesWhether to automatically guess missing dimension names for dimensions ofequal length across different inputs in’data’with a warning(TRUE;default),or to crash whenever unnamed dimensions of equa length are identified acrossdifferent inputs(FALSE).ncores The number of parallel processes to spawn for the use for parallel computation in multiple cores.split_factor Factor telling to which degree the input data should be split into smaller pieces to be processed by the available cores.By default(split_factor=1)the data issplit into4pieces for each of the cores(as specified in ncores).A split_factorof2will result in8pieces for each of the cores,and so on.The special value’greatest’will split the input data into as many pieces as possible.DetailsWhen using a single object as input,Apply is almost identical to the apply function(as fast or slightly slower in some cases;with equal or improved-smaller-memory footprint).ValueList of arrays or matrices or vectors resulting from applying’fun’to’data’.ReferencesWickham,H(2011),The Split-Apply-Combine Strategy for Data Analysis,Journal of Statistical Software.Examples#Change in the rate of exceedance for two arrays,with different#dimensions,for some matrix of exceedances.data<-list(array(rnorm(1000),c(5,10,20)),array(rnorm(500),c(5,10,10)),array(rnorm(50),c(5,10)))test_fun<-function(x,y,z){((sum(x>z)/(length(x)))/(sum(y>z)/(length(y))))*100}test<-Apply(data,target=list(3,3,NULL),test_fun)IndexApply,26。
基于角色模型的MDA开发何成万【摘要】讨论了已有的一些角色模型在重用性和动态性方面的不足,提出了一个适合于MDA开发的层次化的角色模型以及相应的映射规则,给出了该模型的实现方法,并介绍了一个该模型在银行范例系统中的应用.该层次化的角色模型对应于MDA的PIM,它的实现模型对应于MDA的PSM.使用该方法不仅可提高角色模型的重用性,而且在设计层可实现角色的动态特性,有助于实现从PIM到PSM的变换.【期刊名称】《武汉工程大学学报》【年(卷),期】2004(026)002【总页数】4页(P53-55,58)【关键词】MDA;映射;角色模型;角色约束【作者】何成万【作者单位】武汉化工学院计算机科学与工程学院,湖北,武汉,430073【正文语种】中文【中图分类】TP3110 引言MDA是OMG提出的一种基于模型的体系结构,它的主要目的是实现系统的可移植性、互操作性和可重用性[1,2].MDA把模型分为平台无关模型PIM和平台相关模型PSM,通过模型的相互转换达到以上目的.MDA体系结构实现了不同平台之间模型的可重用性,但由于它是基于对象模型的,降低了不同应用软件系统之间模型的可重用性.与基于对象的建模方法相比,角色模型[3,4]更能反映对象间的协作关系.角色可以分配给不同的对象来完成,从这个意义上来说,角色模型是可重用的.因此,提出一个适合于MDA开发的层次化的角色模型以及相应的映射规则,并给出一个该模型的应用实例.1 层次化的角色模型层次化的角色模型如图1所示.最上层是角色模型层,包含角色约束,该层的角色模型及角色约束独立于应用系统,是可重用的;中间层是角色组合及绑定操作层,在该层中定义组合角色以及角色和对象的绑定操作,组合角色和绑定操作要分别根据角色约束中的组合规则和分配规则(见后述)来定义,通过这些绑定操作来表现角色的动态性;最下层是应用系统的对象结构,称为应用程序层.该模型对应于MDA中的PIM,其中的每一层又都是一个PIM.从上到下是PIM的细化.为了实现该模型中的PIM间的变换,提出了用于变换的映射机制----角色约束模型,以及角色约束和绑定操作的形式化描述方法,下面分别对它们进行说明.图1 层次化的角色模型Fig.1 Layered role model1.1 角色约束的描述最上层的角色约束是独立于应用系统的.由于角色还没有分配到对象,约束中不包括任何具体的对象,所以角色约束也是可以重用的.以下定义这两类角色约束,即组合约束、分配约束.1.1.1 组合约束把两个角色组合成一个新的角色时,使用组合约束.包括蕴涵规则,综合规则及并列规则.如果对象执行了R1,它总能执行R2,称R1蕴涵R2.把具有蕴涵关系的两个角色进行组合时使用蕴涵规则.设R1蕴涵R2,则组合后的新角色R中的方法和R1中的方法相同,可用下式表示.{m|m∈R}={m1|m1 ∈R1}综合规则表示把角色R1和R2组合成一个新角色R时,R继承R1和R2中的同名的方法,并且把指定的R1和R2中的不同名的方法进行合并.设M0={(m1,m2) | m1∈R1, m2∈R2,m1≠m2}M1= {m|m∈R1, m ∈R2}M2={m`|m`=m1+m2,m`∉R1,m`∉R2,m1 ∈R1,m2 ∈R2,m1≠m2,(m1,m2) (M0}M3={m1,m2 | m1 ∈R1, m2 ∈R2,m1≠m2,(m1,m2) (M0}M0表示需要综合的方法对的集合,M1表示R1和R2中相同方法的集合,M2表示R中新出现的方法的集合,M3表示R1和R2中其它方法的集合.则有{m|m∈R}=M1∪M2∪M3并列规则表示把角色R1和R2组合成一个新角色R时,R包含R1和R2的方法.可以用下式表示.{m|m∈R}={m1,m2 | m1∈R1,m2∈R2,m1≠m2}∪{m3|m3∈R1,m3 ∈R2}1.1.2 分配约束在进行角色的分配和组合时,两个角色或者共存于同一个对象,或者存在于不同的对象,或者没有约束关系.分配约束是共存规则,相容规则和排斥规则的集合.共存规则表示角色R1和R2必须存在于同一对象中;相容规则表示角色R1和R2可以存在于同一对象中;排斥规则表示角色R1和R2不能存在于同一对象中.1.2 绑定操作的描述绑定操作定义了角色和对象的映射规则及条件,可以表示角色和对象的动态绑定和分离.用以下的文法定义绑定操作.具体化的角色约束::={绑定条件}对象名绑定操作角色绑定操作::=≪|≫其中:[]表示可选项;| 表示n中选一;≪表示把角色分配给对象;≫表示角色从对象分离.例:{角色R1完成}Object1≪R2 表示角色R1完成后把角色R2分配给Object1对象.Object1≫R1 表示Object1对象和角色R1的分离.2 模型的实现方法由于现在的主流面向对象语言(如Java,C++)都不直接支持角色的概念,要实现角色模型需要利用一些设计模式.要实现本文提出的层次化的角色模型,主要需要考虑角色和对象的动态绑定和分离.采用Gamma等人的Mediator模式[5]来实现该模型. 把每个角色分别定义为一个独立的类,另外定义一个协作管理对象COManager,相当于Mediator模式中的anager功能包括:角色和对象的映射关系的检查;角色的管理(生成,绑定和分离).因此,COManager包含以下属性:两个数据链表,一个用来保存已绑定的<对象,角色>对(称为绑定链表),一个用来保存所有对象和角色的可能的绑定关系(称为绑定规则链表);取得某个对象的角色的方法(getRole(Object obj,Object Role)),该方法有两个参数,第一个参数是对象名,第二个参数是角色名,都用字符串来表示.如果绑定链表中已存在该<对象,角色>对,就返回该角色,否则生成该角色,并返回;把角色追加到绑定链表中的方法(bind(Object obj,Object role));从绑定链表中删除<对象,角色>对的方法(detach(Objectobj,Object Role));检查对象是否已绑定到角色的方法(checkBindedRole(Object obj,Object Role));检查绑定链表规则的方法(checkBindingRule(Objectobj,Object Role)).3 基于角色模型的MDA开发基于角色模型的MDA开发方法如图2所示.图2 基于角色模型的MDA模型变换方法Fig.2 MDA model transformation based on role model层次化的角色模型构成了PIM.该模型包括三个层次的PIM以及由上层模型到下层模型的映射机制,该映射由一些角色约束组成.在PIM中追加管理对象Mediator及其关联后形成的模型构成PSM.由于要保存两组数据(绑定连表和绑定规则连表),它依赖于具体的实现语言.该模型的实现代码构成最底层的PSM.4 层次化角色模型的应用实例在文献中,介绍了一个银行系统的范例分析.使用本文提出的层次化的角色模型可描述该系统的PIM(见图3). 其中,最上层是角色模型和角色约束,最下层为对象模型,中间为角色和对象的绑定操作.角色约束表明顾客既可以是贷款者,也可是投资者.角色的绑定操作描述了贷款者角色和投资者角色到顾客对象的动态绑定过程.图3 银行系统的层次化角色模型Fig.3 Layered role model(PIM) of bank system5 结语以上提出了一个适合于MDA开发的层次化的角色模型以及相应的映射规则.层次化的角色模型对应于PIM:角色模型独立于应用系统,位于最上层;通过中间层的绑定操作实现角色的动态特性;最下层是应用程序层(Application层).层次化角色模型的实现模型对应于PSM.介绍了该模型在银行范例系统中的应用.基于角色模型的MDA方法不仅可实现不同平台间模型的重用,而且可实现不同应用软件系统间模型的重用.今后的工作重点包括基于角色模型的MDA开发方法的进一步完善;PIM到PSM的自动转换等.参考文献:[1] David Frankel. Model Driven Architecture: Applying MDA to Enterprise Computing. Indianapolis:John Wiley&Sons,2003.[2] Marc J Balcer, Stephen J Mellor. Executable UML: A Foundation for Model DrivenArchitecture. Boston:Addison-Wesley Pub Co,2002.[3] Kristensen B B, Osterbye K. Roles: Conceptual Abstraction Theory and Practical Language Issues[J]. Theory and Practice of ObjectSystems,1996,2(3): 143-160.[4] Trygve Reenskaug,Wold P,Lehne O A. Working with objects-The OOram Software Engineering Method. Greenwich:Manning Publications Co,1995.[5] Gamma E, Helm R, Johnson R,et al. Design Patterns: Elements of Reusable Design. Tokyo:Soft-Bank Publishers, 2000.[6] Dirk Bumer, Dirk Riehle, Wolf Siberski,et al. Role Object.In: Neil Harrison, Brian Foote, Hans Rohnert. Pattern Languages of Program Design 4. Boston:Addison-Wesley,2000.15-32.。
丙二醛MDA的测定(1)0.05-0.1g叶片液氮研磨后,加入1mL 0.1%TCA,摇晃均匀,加入100μL 5mg/mL的丁羟甲苯(已有),在95度水浴中温浴30分钟。
然后15000g离心10min, 0.55mL的上清液中加入0.55mL TBA(25%的硫代巴比土酸),然后再在95度水浴中温浴30分钟,在冰上冷却,10000g离心5min,将上清液在532nm 测定吸光度,通过扣除600nm下吸收值进行矫正,根据MDA标准曲线定其含量。
The level of lipid peroxidation in leaf tissues was determined in terms of the peroxidation byproduct MDA in the samples. Briefly, 50 to 100 mg leaf tissuewas shock frozen in liquid nitrogen and ground in 1mL of 0.1% TCA. To the homogenized samples, 0.1 mL butylated hydroxytoluene (5 mg/mL) was added and the homogenates were incubated at 95_C for 30 min, centrifuged at 15,000g for 10 min, and 0.55 mL of the supernatant fraction was mixed with0.55 mL of TBA solution (25% thiobarbituric acid). The mixture was heated at 95_C for 30 min, chilled on ice, and then centrifuged at 10,000g for 5 min. The absorbance of the supernatant was measured at 532 nm and corrected by subtracting nonspecific absorption at 600 nm. The amountof MDA was calculated according to an MDA standard curve. From: Specific Roles of a- and g-Tocopherol in Abiotic Stress responses of Transgenic Tobacco(2)0.1g组织浸在2mL 0.1%TCA(三氯乙酸)中,匀浆10400rpm 离心5min, 每200μL上清液加入800μL 20%的TCA(包含5% TBA),混合物在95度温浴30min,迅速在冰上冷却,然后混合物在10400rpm 离心15min,上清液在532nm 测定吸光度。
2007年9月September 2007—100— 计 算 机 工 程Computer Engineering 第33 第18期Vol 卷.33 No.18 ·软件技术与数据库·文章编号:1000—3428(2007)18—0100—03文献标识码:A中图分类号:TP393模型驱动的Web 服务合成季 磊(解放军总医院计算机室,北京 100853)摘 要:随着已有Web 服务数量的不断增加,如何利用现有的Web 服务创建新的更复杂的Web 服务成为一项新的研究课题。
该文提出了MDA 模型转换驱动的合成Web 服务开发方法,针对Web 合成的静态建模部分,提出了建立Web 服务静态结构平台无关和平台相关模型的方法,给出了二者之间的转换规则。
关键词:Web 服务合成;MDA ;静态结构模型Model-driven Web Services CompositionJI Lei(Department of Computer, PLA General Hospital, Beijing 100853)【Abstract 】A number of Web services are available and it therefore seems natural to reuse existing Web services to create composite Web services.This paper gives a method of model-driven Web services composition and a PIM and PSM of Web services composition to solve the problem above static modeling of Web services composition. The translation rules between these models are given. 【Key words 】Web services composition; model-driven architecture (MDA); static structure model1 概述Web 服务[1]是自包含、自描述的模块化应用,它使用标准的XML 消息传递技术封装信息,并可经由网络访问这些接口以完成特定的任务。
mdadm命令详解创建阵列(-C或--create)--raid-devices(-n)功能:指定阵列中成员盘个数。
举例:mdadm --create /dev/md0 -l5 -n2 /dev/sdb /dev/sdc -x1 /dev/sdd备注:当创建linear, multipath, raid0和raid1时,允许指定成员盘个数为1,但要使⽤--force参数。
raid4与raid5不允许指定成员盘个数为1。
成员盘个数可以通过--grow参数来修改,只有RAID1、RAID5 和RAID6阵列⽀持。
--spare-devices (-x)功能:指定阵列中热备盘个数。
举例:mdadm --create /dev/md0 -l5 -n2 /dev/sdb /dev/sdc -x1 /dev/sdd备注:⽆--size (-z)功能:创建阵列时,指定每个成员盘使⽤多⼤的空间。
单位KB。
举例:mdadm --create /dev/md0 -l5 -n3 /dev/sd[b-d] -z 4194304备注:当创建RAID1/4/5/6时,可以指定每个成员盘使⽤多⼤的空间。
同时磁盘最后要留下128Kb⼤⼩空间,⽤于存放RAID的superblock。
如果没有指定该参数,mdadm将使⽤最⼩成员盘的⼤⼩指定该值。
如果某个成员盘的⼤⼩⼤于最⼩成员盘1%,将会有警告信息,提⽰有部分空间没有被使⽤。
创建阵列时,如果RAID中所有成员盘使⽤了的空间都⼩于其本⾝的⼤⼩,那么它们剩余的空间可以通过--grow来扩容。
--size=max,mdadm将⾃动选择⼀个适合的最⼤值,来创建阵列。
--chunk (-c)功能:指定条带⼤⼩。
单位KB,默认值64KB。
举例:mdadm --create /dev/md0 -l5 -n2 /dev/sdb /dev/sdc -x1 /dev/sdd -c 128备注:测试过指定4、8、16、32、64、128、256、1024、2048、4096、8192、16384、32768、65536、131072。
面向方面MDA的实时系统开发方法刘敬勇1,2 , 张立臣1 , 陈成1(1广东工业大学计算机学院,广东广州510006 )(2中国科学院成都计算机应用研究所,四川成都 610041 )摘要:实时系统有许多横切整个系统的非功能需求,如果不能很好的处理,它将使系统的开发复杂化。
仅采用面向对象的方法不能很好的处理这些横切关注点,要处理好这些横切关注点需要将面向方面编程技术与MDA结合起来。
本文提出了在实时系统开发中使用面向方面MDA的方法,这种方法在设计阶段将系统的非功能需求从功能需求中分离出来,降低了实时系统开发的复杂性,提高了系统的可重用性、可维护性和横切关注点的模块化程度。
最后给出了应用实例。
关键词:面向方面,模型驱动架构,实时系统,非功能需求中图法分类号: TP311.52 文献标识码: AApplying Aspect-oriented MDA to Development of Real-time SystemsLIU Jing-Yong1,2, ZHANG Li-Chen1, CHEN-Cheng1(1.College of Computer , Guangdong University of Technology, Guangzhou 510006, China)(2.Chengdu Institute of Computer Application Academia sinica, Chengdu 610041, China) Abstract:Real-time systems have some non-functional requirements, which crosscut entire system that can complicate the development if they are not properly handled. Pure object-oriented methods do not address successfully those crosscutting concerns, so handling these crosscutting concerns of Real-time systems requires integrating the principles of Aspect-Oriented programming with MDA. This paper presents a proposal to use Aspect-oriented MDA in the development of the Real-time Systems, which uses MDA and concepts of the aspect-oriented paradigm to separate the handing of non-functional requirements from the functional ones since earlier design phases, in order to reduce the complexity of Real-time systems development and improve reusability and maintainability of real-time systems, and modularization of crosscutting concerns. At last, the paper presents the use of Aspect-oriented MDA on a case study.Keywords: aspect-oriented; MDA; Real-time systems; Non-Functional Requirements1引言随着信息技术的发展,实时系统的应用领域越来越广泛,像家用电器、通信、交通运输以及军事领域都大量采用实时系统。
mean decrease accuracy methodMean decrease accuracy method (MDA) is a powerful technique used in machine learning and data analysis to assess the importance of variables and features in a predictive model. By quantifying the impact of each variable on the overall accuracy of the model, MDA helps in identifying the key factors driving the predictions. In this article, we will explore the steps involved in applying the MDA method and understand its significance in the field of data analysis.Step 1: Building the predictive modelThe first step in implementing the MDA method is to construct a predictive model using machine learning algorithms. This model serves as the basis for evaluating the importance of variables. Depending on the nature of the problem, various algorithms such as decision trees, random forests, or gradient boosting can be used to create the model. It is crucial to ensure that the model iswell-optimized and accurately predicting the target variable before proceeding to the MDA analysis.Step 2: Assessing baseline accuracyBefore evaluating the impact of variables, it is important toestablish a baseline accuracy for the model. The baseline accuracy represents the predictive power of the model without considering any variables' influence. This can be achieved by running the model on a validation dataset or performing cross-validation on the training dataset to estimate the accuracy. The obtained accuracy will serve as a benchmark against which the variable importance will be compared.Step 3: Permuting the variableThe core idea behind MDA is to analyze the effect of permuting or shuffling the values of each variable on the model's accuracy. For each variable in the dataset, it needs to be randomly permuted (shuffled), while keeping the other variables unchanged. In this step, the variable under analysis is replaced with randomly shuffled values either in the training or test dataset. The predictions are then made using this modified dataset. This process is repeated multiple times to obtain reliable results.Step 4: Calculating accuracy differenceAfter permuting the variable, the next step is to calculate the accuracy difference between the original model and the model with shuffled values. This is done by comparing the accuracyobtained in Step 2 (baseline accuracy) with the accuracy obtained by permuting each variable in Step 3. The higher the difference in accuracy, the more important the variable is to the model's accuracy.Step 5: Ranking variable importanceThe accuracy differences obtained in Step 4 need to be aggregated and ranked to determine the variable importance. The variables with larger accuracy differences are considered more influential in predicting the target variable. These differences can be averaged over multiple iterations to obtain a stable measure of variable importance.Step 6: Visualizing resultsTo facilitate interpretation and presentation, the results of the MDA analysis can be visualized using various techniques. One popular approach is to create a bar plot or a heatmap, where the variables are ranked based on their importance scores. Visualization helps in identifying the key drivers of the model's accuracy and provides insights into the relationships between variables.Step 7: Insights and decision-makingThe final step of the MDA process involves interpreting the results and drawing meaningful insights. By identifying the most important variables, decision-makers can focus their attention and resources on improving those particular factors. Moreover, it helps in understanding the underlying mechanisms and relationships between variables in the predictive model. These insights can potentially guide feature selection, model improvement, and business decisions.In conclusion, the mean decrease accuracy method is a valuable tool for assessing variable importance in predictive models. By permuting variables and observing the resulting impact on model accuracy, MDA enables data analysts to quantify the contributions of each variable in making accurate predictions. This step-by-step process helps in understanding the factors driving the model's performance and guides decision-making processes.。
标题:MDA建库原理引言:MDA(Model Driven Architecture,模型驱动架构)是一种软件开发方法论,它提倡以模型为核心驱动软件系统的开发过程。
在软件开发领域,建库(Code Generation)是MDA的核心概念之一,本文将详细介绍MDA建库原理。
一、MDA概述1.1 MDA的定义MDA是由OMG(Object Management Group)提出的一种软件开发方法论,它将软件开发过程从代码层面抽象到模型层面。
MDA通过使用模型来描述问题域和解决方案,实现了从模型生成代码的自动化过程。
1.2 MDA的核心概念- 平台无关性(Platform Independence):模型应该与特定的技术平台无关,以便可以在不同的平台上重用。
- 可追溯性(Traceability):模型应该能够和源代码之间建立起双向的关联,从而可以跟踪模型和代码之间的变化。
- 自动化构建(Automation):通过模型生成代码的自动化过程,减少了手工编写代码的工作量,提高了开发效率。
二、MDA建库的基本原理2.1 建库的概念建库是将模型转换为可执行代码的过程,也称为模型到代码的转换。
它是MDA的核心环节之一,通过自动化的方式将抽象的模型转化为具体的代码。
2.2 建库的基本过程- 模型定义(Model Definition):首先需要定义模型,包括问题域模型和解决方案模型。
问题域模型描述了实际问题的概念和关系,解决方案模型描述了如何解决这些问题。
- 模型转换(Model Transformation):将模型转换为中间表示形式,通常是一种称为PIM(Platform Independent Model)的模型。
- 平台特定模型转换(Platform Specific Model Transformation):根据目标平台的要求,将PIM模型转换为PSM(Platform Specific Model)模型。
第2章模型驱动的企业计算MDA 以新方式整合一系列趋势,从而有助于我们应付企业计算的压力。
基于组件开发、设计模式、中间件、说明性规约、抽象、多层系统、企业应用集成、契约式设计并不是MDA 的新发明,但是MDA 可以扩展并推动这些技术更好地协作。
本章探讨MDA 如何做到这点。
本章所讨论的许多内容都会在第二和第三部分更为深入地探讨。
2.1 将模型中心的思想引入中间层、EAI 和B2Bi 驱动数据库引擎的数据格式的声明,以及驱动GUI 开发工具代码生成器的所见即所得模型的声明,都是MDA 的前驱。
这些说明性的数据和GUI 模型并不仅仅是设计工件,它们是形式化开发工件,直接改善了前端和后端系统开发的可行性变量。
MDA 把这一开发方法也引入了企业系统的中间层,并且引入了EAI 和B2B 集成(B2B integration,B2Bi )的领域。
32应用MDAMDA使用基于标准的建模语言作为形式化开发语言。
形式化模型驱动产生3GL代码、HTML、XML、WSDL、IDL以及其他工件的生成器。
MDA工具允许工程师细调这些工件的产生方式。
有时候MDA使用动态执行引擎(也就是虚拟机)直接执行模型。
作为开发工件的模型我们大多数人都习惯于把软件模型看作设计工件,而把3GL程序看作开发工件。
许多公司把建模人员和编码人员的角色完全分离。
结果就是,模型,比如UML模型,经常是非正式1的,这意味着它们不能被机器处理。
程序员把它们当作“指南”和“说明书”使用,而不是直接作用于编码过程。
于是许多人把它们看作生产过程中较为次要的东西。
MDA使用可以被机器处理的形式化模型。
这样的模型是生产过程的直接部分。
在这样的环境中,建模人员和编码人员的角色区分就不再那么明显了。
建模行为即编程行为。
这并不是说不再需要非正式的建模。
非正式的建模有助于人们相互之间关于构架和设计的交流。
非正式的建模是对UML的良好运用,但是不能驱动代码生成器或者虚拟机。
2.2 语法抽象和语义抽象中间件(如CORBA和COM)对3GL的抽象程度相对有限。
编译器由对对象接口的IDL声明产生的代码只是一个骨架,程序员还必须做大量的3GL编码工作。
产生这一限制的原因,是IDL的表达力不够丰富。
IDL很大程度上只限于用来声明接口的语法。
例如,CORBA接口的声明包含对属性和操作的声明。
你可以声明属性类型和操作签名,但是除此之外就没什么可声明的了。
请思考下面的CORBA IDL,它描述了某些组件导出(expose)2的接口,这些接口只不过是我们前面看过的Java声明的“独立于编程语言的”翻译版本。
interface Customer{1译注:“正式”的意思是用形式化方式严格而精确地描述。
2译注:这里“导出”指的是把接口提供给用户使用。
第2章模型驱动的企业计算 33 typedef sequence<Account> Accounts;attribute string id;};interface Checkingaccount : Account{attribute double minimumBalance;};interface SavingsAccount : Account{…};interface FundsTransfer{TransferFromChecking(in CheckingAccount fromAcct,in SavingsAccount toAcct,in double amount);…};有许多语义信息(即关于所表达的意思,而不是所用语法的信息)是IDL所不能表达的,而这类信息可能对真正的银行应用程序很重要。
比如,IDL不能描述某一客户“拥有”他的账户(意即当客户被从系统中删除时,他的账户也应当被一起删除)。
IDL无法表述前面提到的不变式规则:某个支票账户的余额不能低于某一最小值。
IDL也不能表示转账操作的先验条件和后验条件。
因此,我把IDL称为贫语义语言(semantically thin language)。
IDL接口集合并不表示接口的语义,或者只表示了很少语义。
语义的贫乏极大地限制了IDL作为目标系统形式化说明语言的价值,也限制了IDL编译器产生代码的能力。
编译器产生可以分发、可以弥补3GL之间的不同的代码,但是程序员依然必须用某种3GL手工编写系统的基本语义。
程序员必须确保客户对账户的拥有权,必须确保不变式、先验条件和后验条件被遵守。
质量保证团队必须手工开发测试框架以验证要求的语义被满足。
34应用MDA另一方面,建模语言却是富语义(semantically rich)的。
它们可以以独立于3GL的方式描述语法,但它们同样可以独立于3GL描述语义,并且很大程度上是用说明性的风格描述。
比如,图2.1是账户和客户的UML模型,大体上和IDL的一部分等价。
黑色菱形声明了一个组合,表示客户拥有账户。
模型通过UML的对象约束语言(Object Constraint Language,OCL)形式化地声明了不变式。
UML还可以表述操作的先验条件和后验条件。
我们将在本章稍后的部分讲这一点,在第4章我们将深入探讨它们,并讨论UML对“契约式设计”的整体支持。
我们的富语义模型同贫语义模型相比,是一个更有效的工程规约(specification)。
另外,对于富语义模型,代码生成器能做的事情也更多。
生成器可以生成确保客户对账户的拥有权并确保不变式和先验条件、后验条件得到遵守的代码。
代码生成器还可以生成用于评估设置的约束是否被满足的测试框架部分。
因此,与基于IDL的中间件相比,富语义、形式化的模型以及与之配套的生成器,可以更大幅度地在3GL之上提高编程抽象级别。
紧凑的语意声明可对应于许多行生成的3GL程序代码。
图2.1 客户和账户的UML模型第2章模型驱动的企业计算 35当编程抽象层次从二进制提升至汇编,再提升至3GL时,3个可行性变量都得到了极大改善,那么在3GL之上再显著提高抽象层次也会如此。
生产力提高了,因为一个语言结构(比如组合)可对应于许多行3GL代码;质量改善了,因为生成器在产生3GL代码(比如,确保组合的代码)时复用经过时间考验的逻辑;全寿命期延长了,因为把对3GL本身的关注从对基本语义的关注中分离了出来。
这使我们可以通过编写新的生成器将模型移植到不同的3GL上,这在很大程度上类似于提供新的编译器以使你可以将COBOL和C++程序移植到新的具有不同处理器和操作系统的计算机上。
正如以前对编程抽象层次的提升,在过渡阶段的早期总会有一些“成长的烦恼”。
生成算法和MDA工具会随着时间而改进。
程序员只有在有时间转到新的工具和技术并对其建立起信心时才会放弃以3GL为中心的开发技术。
另外,我们还需要处理企业的遗产系统,这将实际情况复杂化了:MDA生成器必须以不影响3GL编译器的方式构建。
我将在本章稍后部分和后续的章节中再次谈及这一棘手的问题。
2.3 B2Bi和MDA为B2Bi而发展的新技术快速涌现,都快让软件产业不知所措了。
比如,近期一篇报道提及Web Service技术:“Web Service的前景很大程度上取决于厂商对标准的支持......分析家认为可能会制定更多的标准......如果Web Service成功了,那么全球两千多万名开发者就必须遵循UDDI、WSDL、XML、SOAP来编写程序......最大的问题可能是如何转换当前的开发技术 (1)这一方式的扩展性并不好,并且从长远上看也不可行。
理由如下:让两千万程序员以及数不清的开发团体更换开发工具以编写适用于UDDI、WSDL、XML、SOAP的代码有风险性。
即便有一天我们完成了这一代价昂贵的过程,我们可能会发现某种未预见到的进展又使得我们好不容易才适应的技术再次显得落伍,或者在某些关键环境中被代替。
1 [INFW 2001]。
36应用MDA首先,Web Service的相关技术正在快速变化中,而且有好几种不同的方式来组合这些技术。
我们将在稍后看到这一点。
简单对象访问协议(SOAP),统一描述、发现和集成协议(UDDI)以及Web Service描述语言(WSDL),依然是发展中的新生事物。
有些技术依赖端口80实现Web Service。
当我们开始通过它传递大量Web Service消息时,端口80还是不是像它原来所设计的那样充当安全防火墙通道,这值得置疑。
仅仅几年以前,大多数业界观察家还认为客户与企业(C2B)的电子商务和企业间(B2B)电子商务会使用CORBA和微软的DCOM来在互联网上调用服务1。
但是,结果却是,防火墙管理员已经开放了一个端口给HTTP,不情愿再开放新的端口给CORBA和DCOM了。
因此HTTP和基于HTTP的技术,如XML,现在统治了涉及到通过防火墙交易的通信,而CORBA和从DCOM发展而来的那部分.NET技术就被隔离在防火墙之外了。
关键问题在于,平台的易变性使得Web Service下层依赖的技术很容易改变。
让开发者直接用这些技术编程会导致他们的程序快速过时,而且这也太浪费劳动力了。
我们这些做技术工作的人往往有“爱上技术本身”的倾向,在这个例子中是SOAP、WSDL等。
因此,我们可能会只见树木,不见森林。
我们必须从技术本身退后一步,以便了解:信息,以及使用和创建信息的服务,才是至关重要的。
Web Service的开创性概念在于信息和服务可以通过互联网来提供和访问。
Web Service的实现技术确实很重要,但是它们应当隐藏于幕后,因为随着时间流逝,这些技术会改变,但是这个开创性的概念将会继续存在。
我们的目标应当是提供一个环境,在这个环境中可以尽可能地独立于特定(实现)技术来生产Web Service。
这一努力的目标是在底层技术的改变时保护对Web Service的投资。
另外,这一努力也提升了自动或者半自动产生特定于某种技术的Web Service工件的能力,而不必让程序员完全手工构造它们。
2.3.1 第一代和第二代Web Service整合第一代Web Service带来的产品本质上是把已经存在的对象和组件(例如CORBA、Java 对象和COM组件)映射成Web Service。
有工具用于产生所需要1参见[GM 1995]等。
第2章模型驱动的企业计算 37的WSDL、SOAP和其他XML文件,并产生代码(比如Java代码)来将Web Service 绑定到它们所包裹的对象和组件。
这些工具很大程度上减轻了程序员做这些乏味工作的负担,它们也满足了避免大量手工编写特定于某种技术的工件的需要。
可以说,程序员只需要按部就班,工具自会完成剩下的一切,产生我们需要的大量XML、WSDL、SOAP和3GL工件。
但是,同许多现在已经存在的对象和组件相比,Web Service是(也必然是)粗粒度的,因为我们需要导出给其他企业的业务功能通常包含了比现有的单个对象或组件多得多的应用逻辑。