我正在努力(通过JupyterLab)在Google Cloud的AI平台中了解FairLearn。现在,我从tutorial开始,当我运行Fairlearn仪表板的代码时,会得到一个不确定的“正在加载小部件...”,如下所示。
我一直在阅读JupyterLab中与Wit-widget斗争的用户的其他线索,但无济于事。
在JupyterLab的终端中(在conda环境中),我成功完成了以下安装:
import 'package:flutter/material.dart';
List<Anchor> _parseAnchors(Map<String, dynamic> map) {
final anchors = <Anchor>[];
for (var anchorMap in map['Anchors']) {
final anchor = Anchor.fromMap(anchorMap);
anchors.add(anchor);
}
return anchors;
}
class Anchor {
final int oId;
final String name;
final String acronym;
final List<DistributionCenter> distributionCenters;
const Anchor({
@required this.oId,
@required this.name,
@required this.acronym,
@required this.distributionCenters,
});
factory Anchor.fromMap(Map<String, dynamic> map) {
final distributionCenters = <DistributionCenter>[];
for (var distribution in map['DistributionCentres']) {
final distributionCenter = DistributionCenter.fromMap(distribution);
distributionCenters.add(distributionCenter);
}
return Anchor(
oId: map['Oid'] as int,
name: map['Name'] as String,
acronym: map['Acronym'] as String,
distributionCenters: distributionCenters,
);
}
}
class DistributionCenter {
final int id;
final String name;
final String address;
const DistributionCenter({
@required this.id,
@required this.name,
@required this.address,
});
factory DistributionCenter.fromMap(Map<String, dynamic> map) {
return DistributionCenter(
id: map['Oid'] as int,
name: map['Name'] as String,
address: map['Address'] as String,
);
}
}
class AnchorPage extends StatelessWidget {
// details page
final Anchor anchor;
@override
const AnchorPage({Key key, @required this.anchor}) : super(key: key);
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Text(anchor.name),
),
);
}
}
class AnchorsPage extends StatefulWidget {
const AnchorsPage({Key key}) : super(key: key);
@override
_AnchorsPageState createState() => _AnchorsPageState();
}
class _AnchorsPageState extends State<AnchorsPage> {
static const anchorsMap = {
"Anchors": [
{
"Oid": 11,
"Name": "MAIZE ASSOCIATION OF NIGERIA",
"Acronym": "MAAN",
"DistributionCentres": [
{
"Oid": 11,
"Name": "Logo Centre (Zone A)",
"Address": "Private Warehouse, Ugba, Logo LGA"
},
{
"Oid": 12,
"Name": "Makurdi Centre (Zone B)",
"Address": "Ministry of Agric, Makurdi "
},
{
"Oid": 13,
"Name": "Oturkpo Centre (Zone C)",
"Address": "Private Warehouse, Oturkpo"
},
{
"Oid": 15,
"Name": "Borno MAAN centre",
"Address": "Bolori Store, Flavour Mill, Behind Vita Foam, Maiduguri"
},
{
"Oid": 18,
"Name": "Bauchi Centre",
"Address": "BASPD, Dass Road, Bauchi"
}
],
"NoOfDistributionCentres": 5
},
{
"Oid": 2,
"Name":
"MAIZE GROWERS, PROCESSORS AND MARKETERS ASSOCIATION OF NIGERIA",
"Acronym": "MAGPAMAN",
"DistributionCentres": [
{
"Oid": 2,
"Name": "Guma Centre",
"Address":
"P 32, 2nd Avenue Federal Housing Estate, N/Bank, Makurdi"
},
{
"Oid": 3,
"Name": "Logo Centre",
"Address": "Terhemen Akema Storage Facility, Ugba, Logo LGA"
},
{
"Oid": 5,
"Name": "Oturkpo Centre",
"Address": "Grain Store, Lower Benue Okele Project, Otukpo"
},
{
"Oid": 6,
"Name": "Gboko Centre",
"Address":
"K3 New Road, Opposite former coca cola plant. Solar Schools Street,
Gboko"
},
{
"Oid": 7,
"Name": "Gwer East Centre",
"Address":
"Ahua Shardye's Warehouse, Behind Sylkan Filling Station, Ikpayongo ,
G/East LGA"
},
{
"Oid": 8,
"Name": "Kwande Centre",
"Address": "KM 3, Adagi Road, Adikpo"
},
{
"Oid": 9,
"Name": "Ohimini Centre",
"Address": "Ajoga Oglewu, Ohimini"
},
{
"Oid": 10,
"Name": "Oju Centre",
"Address": "Behind Town Hall, Ohuhu owo, Oju LGA"
}
],
"NoOfDistributionCentres": 8
}
],
};
final _anchors = <Anchor>[];
@override
Widget build(BuildContext context) {
// now you can use the anchors list here
return Scaffold(
body: ListView.builder(
itemCount: _anchors.length,
itemBuilder: (context, index) {
final anchor = _anchors[index];
return ListTile(
title: Text(anchor.name),
subtitle: Text(anchor.acronym),
trailing: Text(anchor.distributionCenters?.length?.toString()),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => AnchorPage(anchor: anchor),
),
);
},
);
},
),
);
}
@override
void initState() {
super.initState();
final anchors = _parseAnchors(anchorsMap);
_anchors.addAll(anchors);
}
}
在我的jupyter笔记本中,我还包括:
import math
def find(p):
return math.ceil(math.sqrt(2*365*math.log(1/(1-p))));
print(find(0.25))
我还有以下jupyterlab扩展列表:
答案 0 :(得分:0)
尚不支持JupyterLab,请参阅https://github.com/fairlearn/fairlearn/issues/484#issuecomment-651095161作为参考。
不过,您应该可以直接在Jupyter(而非Jupyter Lab)中运行它。