Skip to content

Adafel's ODL SDK to Contribute, Extract and Compute Onchain/Offline Data to build efficient ML Models

Notifications You must be signed in to change notification settings

adafel-official/openDataLibrary-js-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Open Data Library (ODL) sdk

Typescript SDK for interacting with Open Data Library protocol.

Features

  • Add new users: addNewUser
  • Create new schema: createSchema
  • Add new data points: addAnalytics
  • Update existing data points: updateAnalytics
  • Get aggregate user activity data across multiple schema: getAggregateActivityData
  • Get list of all schemas: getSchemaList
  • Get all data points of particular schema: getSchemaData

Installation

npm i @adafel/opendatalibrary-js-sdk

Quickstart

  1. Initialize the client instance
import { privateKeyToAccount } from "viem/accounts";
import { OpenDataLibrary, Category } from "@adafel/opendatalibrary-js-sdk";
const privateKey = "0xabc"; // optional

const client = new OpenDataLibrary({
  account: privateKeyToAccount(privateKey), // optional
});

Note: if the private key is not supplied then sdk will use provider from window.ethereum.

  1. Reading Data from CSV You can read data from a CSV file and format it for use with the library:
const csvPath = "./data.csv";
const inputColumns = ["column1", "column2"];
const labelColumn = "label";

const [inputData, labels] = await odl.getDataFromCSV(
  csvPath,
  inputColumns,
  labelColumn
);
  1. Adding Data to the Blockchain To add data to the blockchain, use the addData method:
const schemaName = "MySchema";
const columns = ["column1", "column2"];
const category = Category.Gaming;
const data = inputData;

await odl.addData(schemaName, columns, category, data);
  1. Training a Model You can train different models using the provided methods. For example, to train a linear regression model:
const modelName = "MyLinearRegressionModel";

await odl.trainLinearRegressionOffChainData(inputData, labels, modelName);
  1. Making Predictions To make predictions using a trained model:
const predictions = await odl.predictLinearRegressionOnchainModel(
  modelName,
  inputData
);

About

Adafel's ODL SDK to Contribute, Extract and Compute Onchain/Offline Data to build efficient ML Models

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published