necromant2005/bigml-php-sdk

1.5.1 2014-11-03 12:46 UTC

This package is auto-updated.

Last update: 2024-08-29 03:26:22 UTC


README

Build Status

简介

BigML PHP SDK用于访问bigml.com API

特性/目标

  • 从PHP简单访问API
  • 处理数据转换json => array, array=>json和错误处理
  • 实现资源:源、数据集、模型、预测、评估

安装

主要设置

使用composer

  1. 将以下内容添加到您的composer.json中
"require": {
    "necromant2005/bigml-php-sdk": "1.*",
}
  1. 现在运行命令以让composer下载BigMl PHP SDK
$ php composer.phar update

用法

使用API版本"andromeda"创建资源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array(
    'username' => 'alfred',
    'api_key'  => '79138a622755a2383660347f895444b1eb927730',
));

以特定API版本在开发模式下创建资源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array(
    'username' => 'alfred',
    'api_key'  => '79138a622755a2383660347f895444b1eb927730',
    'access_point' => 'https://bigml.io/dev/',
    'version' => 'andromeda',
));

使用自定义预测接入点访问特定的BigML AWS预测实例

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array(
    'username' => 'alfred',
    'api_key'  => '79138a622755a2383660347f895444b1eb927730',
    'access_point' => 'https://bigml.io/dev/',
    'access_point_prediction' => 'https://prediction.dev.bigml.io/',
    'version' => 'andromeda',
));

基本用法

通过工厂创建资源

use BigMl\Client\BigMl;

BigMl::factory('source', array( ... )); // source
BigMl::factory('dataset', array( ... )); // dataset
BigMl::factory('model', array( ... )); // model
BigMl::factory('prediction', array( ... )); // prediction
BigMl::factory('evaluation', array( ... )); // evaluation

资源用法

创建源数据

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->create(array('data' => array(
    'a', 'b', 'c',
    1, 2, 3,
    4, 5, 7
)));

创建远程源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->create(array('remote' => 's3://bigml-public/csv/iris.csv'));

获取源信息

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->retrieve('source/4f510d2003ce895676000069');

获取信息,直到处理完成,每10秒检查一次状态

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->wait('source/4f510d2003ce895676000069', 10);

查找名为'iris'的源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->retrieve('source', array(
    'name' => 'iris'
));

重命名源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->update('source/4f510d2003ce895676000069', array(
    'name' => 'iris-new'
));

删除源

use BigMl\Client\BigMl;

$source = BigMl::factory('source', array( ... ));
$source->delete('source/4f510d2003ce895676000069');

预测用法

进行预测

use BigMl\Client\BigMl;

$service = BigMl::factory('prediction', array( ... ));
$service->create(array(
    'model' => 'model/57510d2003ce895676000069',
    'input_data' => array(
        '000000' => 'value1',
        '000001' => 'valu2',
    ),
    'name' => 'my-prediction',
));