1

IBM Watson Tradeoff Analytics 是否支持 CSV?看起来 API 只接受 JSON。如何将问题从 CSV 转换为 JSON?

4

1 回答 1

1

输入只能是 JSON,但您可以使用此工具从 CSV 生成 JSON:http: //tradeoff-analytics-csvtojson.mybluemix.net/

有效 JSON 的一个示例是:

{
  "subject": "phone",
  "columns": [{
    "key": "price",
    "type": "numeric",
    "goal": "min",
    "full_name": "Price",
    "is_objective": true,
    "format": "€####0.00"
  }, {
    "key": "brand",
    "type": "categorical",
    "goal": "min",
    "full_name": "Brand",
    "is_objective": true,
    "range": ["Samsung", "Apple", "HTC", "LG", "Nokia", "Sony"],
    "preference": ["Samsung", "Apple", "HTC", "LG", "Nokia", "Sony"]
  }, {
    "key": "RAM",
    "type": "numeric",
    "goal": "max",
    "full_name": "RAM (MB)",
    "is_objective": false
  }, {
    "key": "screen_size",
    "type": "numeric",
    "goal": "max",
    "full_name": "Screen (inch)",
    "is_objective": true
  }, {
    "key": "camera",
    "type": "numeric",
    "goal": "max",
    "full_name": "Camera",
    "is_objective": false,
    "format": "####0 MP"
  }, {
    "key": "memory_size",
    "type": "numeric",
    "goal": "max",
    "full_name": "Memory",
    "is_objective": false,
    "format": "####0 GB"
  }, {
    "key": "battery",
    "type": "numeric",
    "goal": "max",
    "full_name": "Battery (mAh)",
    "is_objective": false
  }, {
    "key": "weight",
    "type": "numeric",
    "goal": "min",
    "full_name": "Weight",
    "is_objective": true,
    "format": "####0 g"
  }, {
    "key": "rDate",
    "type": "datetime",
    "goal": "max",
    "full_name": "Release Date",
    "is_objective": false
  }],
  "options": [{
    "key": "1",
    "name": "Samsung Galaxy S4 White",
    "values": {
      "weight": 130,
      "price": 239,
      "RAM": 2048,
      "battery": 2600,
      "camera": 13,
      "memory_size": 16,
      "screen_size": 5,
      "brand": "Samsung",
      "rDate": "2013-04-29T00:00:00Z"
    }
  }, {
    "key": "2",
    "name": "Samsung Galaxy S4 Black",
    "values": {
      "weight": 130,
      "price": 239,
      "RAM": 2048,
      "battery": 2600,
      "camera": 13,
      "memory_size": 16,
      "screen_size": 5,
      "brand": "Samsung",
      "rDate": "2013-04-29T00:00:00Z"
    }
  }, {
    "key": "3",
    "name": "Samsung Galaxy S3 White",
    "values": {
      "weight": 133,
      "price": 79,
      "RAM": 2048,
      "battery": 2100,
      "camera": 8,
      "memory_size": 16,
      "screen_size": 4.8,
      "brand": "Samsung",
      "rDate": "2012-05-29T00:00:00Z"
    }
  }]
}
于 2015-10-13T14:11:01.443 回答