Code Monkey home page Code Monkey logo

klasifikasi-php's Introduction

Klasifikasi for PHP

Official Klasifikasi API Client Library

Requirement

  • PHP >= 7.2.5

Installation

Install klasifikasi-php with composert:

composer require bahasaai/klasifikasi-php

Quick Start

You will need valid clientId & clientSecret of your model. You can get those from credential section at your model page, which is both unique per model.

use klasifikasi\Klasifikasi;

$klasifikasiInstance = Klasifikasi::build([
    [
        'clientId' => 'client-id-1',
        'clientSecret' => 'client-id-2'
    ]
]);

you can pass multiple clientId & clientSecrert too

$klasifikasiInstance = Klasifikasi::build([
    [
        'clientId' => 'client-id-1',
        'clientSecret' => 'client-secret-1'
    ],
    [
        'clientId' => 'client-id-2',
        'clientSecret' => 'client-secret-2'
    ]
]);

Classify

You will need you model publicId to start classifying with your model. You can get your model publicId from your model page, or you can get it from here :

foreach ($klasifikasiInstance->getModels() as $publicId => $model) {
  echo $publicId;
}

Classifying example

$result = $publicId->classify('publicId', 'query');
/**
 * $result example = array[
 *  'result' => array[
 *    [
 *      'label' => 'tag 1',
 *      'score' => 0.53
 *    ],
 *    [
 *      'label' => 'tag 2',
 *      'score' => 0.23
 *    ]
 *  ]
 * ]
*/

Logs

You can get your classifying logs based on your model publicId

$startedAtString = '10 December 2020';

$endedAtString = '16 December 2020';

$logs = $instance->logs('publicId', [
    'startedAt' => new DateTime($startedAtString),
    'endedAt' => new DateTime($endedAtString),
    'take' => 10
    'skip' => 1
]);
/**
 * $logs example = array[
 *  'histories' => array[
 *    [
 *      'id' => 1,
 *      'createdAt' => '2020-12-15T11:13:12+07:00',
 *      'query' => 'query',
 *      'modelResult' => array[
 *        [
 *          'label' => 'tag 1',
 *          'score' => 0.53
 *        ],
 *        [
 *          'label' => 'tag 2',
 *          'score' => 0.23
 *        ]
 *      ]
 *    ],
 *    ...
 *  ],
 *  'length' => int
 * ]
*/

Error

All the function above will throw an Exception if something bad happen. Always run each function inside try & catch block

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.