Giter Site home page Giter Site logo

polynomial-regression's Introduction

Polynomial Regression

PolynomialRegression là một class trong JavaScript để thực hiện việc khớp một phương trình đa thức với một tập hợp các điểm dữ liệu sử dụng phương pháp hồi quy đa thức. Class này cung cấp một số phương thức cho việc tính toán và xử lý ma trận, bao gồm:

transpose(matrix: number[][]): number[][]: Tính chuyển vị của một ma trận.

multiplyMatrices(a: number[][], b: number[][]): number[][]: Nhân hai ma trận lại với nhau.

invertMatrix(matrix: number[][]): number[][]: Tính nghịch đảo của một ma trận vuông sử dụng phép loại Gauss.

Usage

Bạn có thể sử dụng class PolynomialRegression bằng cách import hoặc require nó vào trong dự án của mình, sau đó khởi tạo một đối tượng và gọi các phương thức để thực hiện việc khớp đa thức với dữ liệu.

import { PolynomialRegression } from './PolynomialRegression';

const xValues = [0, 1, 2, 3, 4];
const yValues = [1, 2, 3, 4, 5];

const polynomialRegression = new PolynomialRegression();

const degree = 2;

const coefficients = polynomialRegression.fit(xValues, yValues, degree);

console.log(coefficients);

Logger

(async () => {
  const xValues = [1, 2, 3];
  const yValues = [1, 4, 9];
  const order = 2;
  const coefficients = await PolynomialRegression.polynomialRegression(
    xValues,
    yValues,
    order
  );

  // Kết quả của hồi quy đa thức = [0, 0, 1] với y = 1 * x^2.
  console.log("Kết quả của hồi quy đa thức là " + coefficients);
  PolynomialRegression.testing(coefficients);

  console.log(
    "Giá trị x tương ứng với giá trị y bằng 16 là " +
      PolynomialRegression.findX(
        coefficients,
        16,
        1,
        PolynomialRegression.tolerance,
        1000
      )
  ); // 4

  console.log(
    "Giá trị y tương ứng với giá trị x bằng 4 là " +
      PolynomialRegression.findY(coefficients, 4)
  ); // 16
})();

Stay in touch

Facebook - Khanh Nguyen

polynomial-regression's People

Watchers

 avatar  avatar  avatar

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.