使用约束的可视化推荐

draco的Python项目详细描述



<;a href="https://uwdata.github.io/draco/">;
<;img src="logos/dark/logo dark.png"width=260>;
<;/img>;
<;/a>;
<;/p>;

[构建状态](https://travis-ci.org/uwdata/draco.svg?branch=master)(https://travis ci.org/uwdata/draco)
[![覆盖状态](https://coveralls.io/repos/github/uwdata/draco/badge.svg?branch=master)(https://coveralls.io/github/uwdata/draco?分支=主)
[![pypi](https://img.shields.io/pypi/v/draco.svg)(https://pypi.org/project/draco/)
[![代码样式:黑色](https://img.shields.io/badge/code%20style-black-000000.svg)(https://github.com/ambv/black)
[![代码风格:漂亮](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=rounded)](https://github.com/prettier/prettier)


draco是一个将有效可视化设计的设计知识表示为约束集合的正式框架。您可以使用draco在vega lite中找到有效的可视化视觉设计。基于应答集编程(asp)实现了draco的约束,并用clago约束求解器求解。我们还实现了一种直接从图形感知实验结果中学习推荐系统权重的方法。

阅读我们的介绍性[关于draco的博客文章](https://medium.com/@uwdata/draco-representing-application-learning-visualization-design-guidelines-64ce20287e9d)以及我们的[研究论文](https://idl.cs.washington.edu/papers/draco/)了解更多细节。在浏览器https://uwdata.github.io/draco editor中尝试draco。

\status

**there be dragons!**该项目正在积极开发中,我们正在努力清理存储库,使DRACO中的推荐模型更易于使用。如果你现在想用这个,请和我们谈谈。即将提供更多文档。

概述

.py)、用于**draco core**api的[cli](https://github.com/uwdata/draco/blob/master/draco/cli.py)和[python包装器](https://github.com/uwdata/draco/blob/master/draco/js.py)。此外,还包括一些[helper函数](https://github.com/uwdata/draco/blob/master/draco/helper.py),这些函数可能被证明是有用的。
*[**draco core**](https://www.npmjs.com/package/draco-core)(npm)保存了一个asp程序的typescript/javascript友好副本,此外,还有一个typescript/所有Draco翻译逻辑的JavaScriptAPI,如下所述。


包括Draco的解算器Cligo的捆绑WebAssembly模块。

*[Draco学习](https://github.com/uwdata/Draco学习)
*根据感知实验的结果运行学习排名方法。

*[Draco工具](https://github.com/uwdata/Draco工具)
*UI工具到CRE创建成对可视化的注释数据集,查看建议,并探索示例可视化的大型数据集。

*[draco分析](https://github.com/uwdata/draco分析)
*分析结果的笔记本。

除了下面描述的draco核心api的包装外,python api还包含以下函数。

*object**result**[<>;](https://github.com/uwdata/draco/blob/2de31eeb6eab29577b1b09ab3c0fd7bd2e0/draco/run.py\l36)

>;draco运行的结果,一个解决方案一个德拉科的问题。用户"result.as_vl()"将此解决方案转换为Vega Lite规范。

**run***(draco_query:list[str][,constants,files,relax_hard,silence_warnings,debug,clear_cache])->;result:*[<;gt;](https://github.com/uwdata/draco/blob/2de31e3eeb6eab29577b1b09ab3c0fd7bd2e0/draco/run.py l115)


>;运行"draco_query",定义为针对给定"文件"asp程序的draco asp事实(字符串)列表(默认为基本DRACO集合)。如果查询可以满足,则返回"result"。如果将"relax\u hard"设置为"true",则不会严格执行硬约束(`hard.lp`),而是会在违反时产生无限的成本。


****是否有效(draco-u查询:list[str][,debug])->;bool:*[<;>>**(https://github.com/uwdata/draco/draco/draco/blob/2de31e3eeb6eab229577b1b09a9ab3c0ab3c0fd7bde0/draco/draco/draco/draco/draco/blob/2de3eeb/2de3e3eb6eab2b2E3313131e129577b1b1b09a9a9ab3c0b0b0是的` draco_query`,定义为针对draco的硬约束的draco asp事实(字符串)列表。如果查询定义的可视化是有效的(不违反硬约束),则返回true;否则返回false。硬约束可以在[`hard.lp`](https://github.com/uwdata/draco/draco/blob/master/asp/hard.lp)中找到(https://github.com/uwdata/draco/draco/draco/blob/2de31e3eeb6EAB129577b1b099a9a9a9a9a9b0b3b0fd7bd2e0/draco/draco/helpco/laco/draco/draco/draco/blob/blob/master/master/asp/asp/hard.lp/hard.lp)和(https://br/>

/br/>/br/>>;读取一个数组的数据数组,读取一个数组的数据和返回它的asp声明(a事实列表)。


**将数据读入asp***(文件:str)->;list[str]:[<;>;](https://github.com/uwdata/draco/draco/blob/2dE31E3EE3B6EAB129577B1099B19A92AB3C0FD7BD20AB0FD7BDEO/draco/helper.py l24)

>;读取数据的"文件"(无论是".json"或".csv"是".json"是".json"还是".csv",并返回数据的asp声明(事实列表)。





>draco核心api(typescript/j


**vl2assp***(spec:topLevelUnitspec):string[]*[<>gt;](https://github.com/uwdata/draco/blob/master/js/src/vl2assp.ts)


>;将vega-lite规范翻译成一个asp-draco事实清单。




**cql2assp***(spec:any):string[]*[<;](https://github.com/uwdata/draco/draco/blob/master/master/js/src/cql2assp.js/cql2assp.jsc ts)

>;将CompassQL规范转换为ASP DRACO约束列表。

**asp2vl**(事实:字符串[]):topLevelUnitSpec*[<>;](https://github.com/uwdata/draco/blob/master/js/src/asp2vl.ts)

>;将ASP DRACO事实列表解释为Vega Lite规范。

**data2schema**(数据:任意[]):schema*[<;>;](https://github.com/uwdata/draco/blob/master/js/src/data2schema.ts)

>;读取行列表并生成数据集的数据架构。`数据`应该作为字典列表给出。

**schema2asp**(schema:schema):string[]*[<>;](https://github.com/uwdata/draco/blob/master/js/src/schema2asp.ts)

>;将数据模式转换为它描述的数据的asp声明。

**constraints2json**(constraintsAsp:string,weightsAsp?:string):constraint[]*[<;](https://github.com/uwdata/draco/blob/master/js/src/constraints2json.ts)

>;将给定的asp约束和匹配权重(即软约束)转换为json格式。

**json2constraints***(constraints:constraints[]:constraintasp*[<;]/js/src/json2conConstraints.ts)

>>;将给定的json格式的asp约束转换为asp字符串,用于定义和权值(如果适用,即用于软约束)的定义和权值(如果适用,即用于软约束)的asp字符串。



_________stall-c potasco clago`.在MacOS上,您也可以运行"brew install clago"。


**如果您希望**在**Web浏览器**中运行**draco,请考虑使用[**draco vis**](https://github.com/uwdata/draco vis),它将Clingo解算器捆绑为一个WebAssembly模块。德拉科核心API本身不包含此功能。它只处理各种接口语言之间的转换逻辑。

"yarn add draco core"或"npm install draco core"

在MacOS操作系统上,您也可以运行"brew install clago"。


<
<35<35<35<35<35<35<35<35 <35<35<<<

"yarn"或"npm install `


















<

<

<

<<

<<
<

`pip install-r requirements.txt`或`conda install--file requirements.txt`

以可编辑模式安装draco。我们期望python 3。

`pip install-e.`


现在可以调用命令行工具'draco'。For example `draco --version` or `draco --help`.


#### Tests

You should also be able to run the tests (and coverage report)

`python setup.py test`

##### Run only ansunit tests

`ansunit asp/tests.yaml`

##### Run only python tests

`pytest -v`

##### Test types

`mypy DRACO测试--忽略丢失的导入项--忽略丢失的导入项--运行DRACO的导入项





<
35 35 35 35 35 35<

>要在部分规范上运行DRACO的示例









/>`sh sh sh sh sh run pypu pipepipeline.sh spec sh spec sh run

####使用compassql生成示例



run"yarn build_cql_cql_cql_示例`.








直接在一组asp约束上运行draco可以直接在一组asp约束上运行draco可以使用帮助文件'asp/_all.lp`.





>或者,可以使用draco-m asp test.lp`.draco调用draco,或者,可以使用draco-m asp-m asp test.asp test.lp`.draco调用draco。





运行apt example

`clagoasp/_apt.lp examples/example_apt.lp--opt mode=opttn--quiet=1--project-c max_extra_encs=0`


这只打印相关数据并限制正在生成的额外编码。


*更新‘draco/u init.py’中的‘draco/u init.py’版本并使用下面的正确版本。
*`git commit-m"bump version to 0.0.1 0.0.1"`
*标记最后一个commit的‘git tag-a v0.0.1 `.
*`git push `和‘git push ` tags`
*运行‘python setup.pypy sdist upload`.


;资源


>

相关存储库r/>*https://github.com/wwdata/vis-csp
*https://github.com/domoritz/vis约束











*https://github.com/uwdata/draco-vis
*https://github.com/wwwdata/draco-vis
*https://github.com/potasco/potassco/guidesco/releass

>
>
>
>
>*https://github.com/potassco/potassco/potassco/potassco br/>

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
用于切换状态结果的枚举的java输入   检测*NIX上打开的端口时出现java问题   java捕获和保存屏幕截图   java SLF4JLogback:基于日志级别的多模式   Java从字符串中删除动态子字符串   在spring引导中contextLoads测试时运行java Liquibase   基于规则集的任意嵌套POJO的java任意就地转换   java如何做,边做边循环这段代码?   java是什么导致jmh测量中的错误?   java Spring RabbitTemplate执行方法可见性   java jms创建连接http超时weblogic   java如何在JMapViewer中的两点之间放置像箭头一样的图像   在我的形状计算器Java程序中使用带有Switch/Case语句的循环   字符串如何在Java中比较字符和数字