numinajs

1.0.4 • Public • Published

NuminaJS

NuminaJS is a comprehensive data science package for JavaScript, providing a wide range of tools for data preprocessing, feature selection, data transformation, machine learning algorithms, and data visualization. It's designed to simplify complex data science tasks and make them accessible to JavaScript developers.

Table of Contents

  1. Installation
  2. Features
  3. Usage
  4. API Reference
  5. Contributing
  6. License

Installation

npm install numinajs

Features

  • CSV file reading
  • Data preprocessing (handling missing values, outlier detection, normalization)
  • Feature selection (correlation analysis, chi-square test, ANOVA, Lasso, Ridge, Elastic Net)
  • Data transformation
  • Handling imbalanced datasets
  • Supervised learning algorithms (SVM, Linear Regression, Logistic Regression, Decision Trees, Random Forests, KNN, Naive Bayes, Gradient Boosting, AdaBoost, Voting Classifier)
  • Unsupervised learning algorithms (K-Means, Hierarchical Clustering, DBSCAN)
  • Comprehensive model evaluation metrics
  • Cross-validation techniques
  • Data visualization with Chart.js integration
  • Data export to various formats (HTML, JSON, PDF)

Usage

Data Reading

const { readCSV } = require('numinajs');

const data = readCSV('path/to/your/file.csv');
console.log(data);

Data Preprocessing

const { handleMissingValues, detectAndHandleOutliers, normalizeData } = require('numinajs');

// Handle missing values
let processedData = handleMissingValues(data, 'column_name', 'mean');

// Detect and handle outliers
processedData = detectAndHandleOutliers(processedData, 'column_name', 'remove');

// Normalize data
processedData = normalizeData(processedData, 'column_name', 'min-max');

Feature Selection

const { selectFeatures, chiSquareTest, anovaFTest } = require('numinajs');

// Select features based on correlation
const selectedFeatures = selectFeatures(data, 'correlation', 0.5);

// Perform chi-square test
const chiSquareResults = chiSquareTest(data, targetColumn);

// Perform ANOVA F-test
const anovaResults = anovaFTest(data, targetColumn);

Data Transformation

const { transformData } = require('numinajs');

// Apply log transformation
const transformedData = transformData(data, 'column_name', 'log');

Handling Imbalanced Data

const { handleImbalance } = require('numinajs');

// Oversample minority class
const balancedData = handleImbalance(data, 'oversample');

Supervised Learning Algorithms

const { linearRegression, logisticRegression, svm, randomForests } = require('numinajs');

// Linear Regression
const linearModel = linearRegression(data, targetColumn);

// Logistic Regression
const logisticModel = logisticRegression(data, targetColumn);

// Support Vector Machine
const svmModel = svm(data, targetColumn);

// Random Forests
const rfModel = randomForests(data, targetColumn);

Unsupervised Learning Algorithms

const { kMeans, hierarchicalClustering, dbscan } = require('numinajs');

// K-Means Clustering
const kMeansResult = kMeans(data, 3); // 3 clusters

// Hierarchical Clustering
const hierarchicalResult = hierarchicalClustering(data);

// DBSCAN
const dbscanResult = dbscan(data, 0.5, 5); // epsilon = 0.5, minPoints = 5

Model Evaluation Metrics

const { accuracy, precision, recall, f1Score, confusionMatrix, specificity, falsePositiveRate, trueNegativeRate, areaUnderROC, meanSquaredError, rootMeanSquaredError, meanAbsoluteError, rSquared } = require('numinajs');

// Classification metrics
const accuracyScore = accuracy(trueLabels, predictedLabels);
const precisionScore = precision(trueLabels, predictedLabels);
const recallScore = recall(trueLabels, predictedLabels);
const f1 = f1Score(trueLabels, predictedLabels);
const confMatrix = confusionMatrix(trueLabels, predictedLabels);
const specificityScore = specificity(trueLabels, predictedLabels);
const fpr = falsePositiveRate(trueLabels, predictedLabels);
const tnr = trueNegativeRate(trueLabels, predictedLabels);
const auc = areaUnderROC(trueLabels, predictedScores);

// Regression metrics
const mse = meanSquaredError(trueValues, predictedValues);
const rmse = rootMeanSquaredError(trueValues, predictedValues);
const mae = meanAbsoluteError(trueValues, predictedValues);
const r2 = rSquared(trueValues, predictedValues);

Cross-Validation

const { kFoldCrossValidation, stratifiedKFoldCrossValidation } = require('numinajs');

// K-Fold Cross-Validation
const kFoldResults = kFoldCrossValidation(data, labels, model, 5);

// Stratified K-Fold Cross-Validation
const stratifiedResults = stratifiedKFoldCrossValidation(data, labels, model, 5);

Data Visualization

const { plotGraph } = require('numinajs');

// Create a bar chart
const barChartData = {
  labels: ['January', 'February', 'March', 'April', 'May'],
  datasets: [{
    label: 'Sales',
    data: [12, 19, 3, 5, 2],
    backgroundColor: 'rgba(75, 192, 192, 0.6)'
  }]
};

plotGraph(800, 600, 'bar', barChartData, { title: { display: true, text: 'Monthly Sales' } }, 'sales_chart');

Data Export

const { exportToHTML, exportToJSON, exportToPDF } = require('numinajs');

exportToHTML(data, 'output.html');
exportToJSON(data, 'output.json');
exportToPDF(data, 'output.pdf');

API Reference

Data Preprocessing

  • handleMissingValues(data, column, method, specificValue)
  • detectAndHandleOutliers(data, column, method)
  • normalizeData(data, column, method)
  • encodeCategorical(data, column, method)
  • cleanData(data)

Feature Selection

  • selectFeatures(data, method, threshold, column1, column2)
  • chiSquareTest(data, target)
  • anovaFTest(data, target)
  • lassoRegularization(data, target, alpha)
  • ridgeRegularization(data, target, alpha)

Supervised Learning

  • linearRegression(data, target)
  • logisticRegression(data, target, learningRate, iterations)
  • svm(data, target, C, iterations, learningRate)
  • decisionTrees(data, target)
  • randomForests(data, target, numTrees)
  • kNearestNeighbors(data, target, k)
  • naiveBayes(data, target)
  • gradientBoosting(data, target, numTrees, learningRate)
  • adaBoost(data, target, numEstimators)
  • votingClassifier(data, target, models)

Unsupervised Learning

  • kMeans(data, k, maxIterations)
  • hierarchicalClustering(data)
  • dbscan(data, epsilon, minPoints)

Model Evaluation Metrics

  • accuracy(trueLabels, predictedLabels)
  • precision(trueLabels, predictedLabels)
  • recall(trueLabels, predictedLabels)
  • f1Score(trueLabels, predictedLabels)
  • confusionMatrix(trueLabels, predictedLabels)
  • specificity(trueLabels, predictedLabels)
  • falsePositiveRate(trueLabels, predictedLabels)
  • trueNegativeRate(trueLabels, predictedLabels)
  • areaUnderROC(trueLabels, predictedScores)
  • meanSquaredError(trueValues, predictedValues)
  • rootMeanSquaredError(trueValues, predictedValues)
  • meanAbsoluteError(trueValues, predictedValues)
  • rSquared(trueValues, predictedValues)

Cross-Validation

  • kFoldCrossValidation(data, labels, model, k)
  • stratifiedKFoldCrossValidation(data, labels, model, k)

Data Visualization

  • plotGraph(width, height, graphType, data, options, filename)

Data Export

  • exportToHTML(data, filePath)
  • exportToJSON(data, filePath)
  • exportToPDF(data, filePath)

Contributing

We welcome contributions to NuminaJS! Please see our Contributing Guidelines for more information.

License

NuminaJS is released under the MIT License. See the LICENSE file for details.

Package Sidebar

Install

npm i numinajs

Weekly Downloads

0

Version

1.0.4

License

MIT

Unpacked Size

64.7 kB

Total Files

15

Last publish

Collaborators

  • arjun_shukla