kandi background
Explore Kits

ML-From-Scratch | Machine Learning From Scratch | Machine Learning library

 by   eriklindernoren Python Version: Current License: MIT

 by   eriklindernoren Python Version: Current License: MIT

Download this library from

kandi X-RAY | ML-From-Scratch Summary

ML-From-Scratch is a Python library typically used in Institutions, Learning, Education, Artificial Intelligence, Machine Learning, Deep Learning, Example Codes applications. ML-From-Scratch has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can install using 'pip install ML-From-Scratch' or download it from GitHub, PyPI.
Python implementations of some of the fundamental Machine Learning models and algorithms from scratch. The purpose of this project is not to produce as optimized and computationally efficient algorithms as possible but rather to present the inner workings of them in a transparent and accessible way.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • ML-From-Scratch has a medium active ecosystem.
  • It has 20024 star(s) with 3880 fork(s). There are 972 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 25 open issues and 36 have been closed. On average issues are closed in 38 days. There are 17 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of ML-From-Scratch is current.
ML-From-Scratch Support
Best in #Machine Learning
Average in #Machine Learning
ML-From-Scratch Support
Best in #Machine Learning
Average in #Machine Learning

quality kandi Quality

  • ML-From-Scratch has 0 bugs and 0 code smells.
ML-From-Scratch Quality
Best in #Machine Learning
Average in #Machine Learning
ML-From-Scratch Quality
Best in #Machine Learning
Average in #Machine Learning

securitySecurity

  • ML-From-Scratch has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • ML-From-Scratch code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
ML-From-Scratch Security
Best in #Machine Learning
Average in #Machine Learning
ML-From-Scratch Security
Best in #Machine Learning
Average in #Machine Learning

license License

  • ML-From-Scratch is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
ML-From-Scratch License
Best in #Machine Learning
Average in #Machine Learning
ML-From-Scratch License
Best in #Machine Learning
Average in #Machine Learning

buildReuse

  • ML-From-Scratch releases are not available. You will need to build from source code and install.
  • Deployable package is available in PyPI.
  • Build file is available. You can build the component from source.
  • Installation instructions are not available. Examples and code snippets are available.
ML-From-Scratch Reuse
Best in #Machine Learning
Average in #Machine Learning
ML-From-Scratch Reuse
Best in #Machine Learning
Average in #Machine Learning
Top functions reviewed by kandi - BETA

kandi has reviewed ML-From-Scratch and discovered the below as its top functions. This is intended to give you an instant insight into ML-From-Scratch implemented functionality, and help decide if they suit your requirements.

  • Train the discriminator
    • Generate images for the MNIST dataset
    • Set trainable value
    • Train the loss function
  • Calculate the cost for each sample
    • Compute the clusters for the given medoids
    • Calculates the cost of each sample
    • Compute the euclidean distance between two points
  • Backward of the layer
    • Build the discriminator layer
      • Predict cluster labels
        • Train the autoencoder
          • Find the most frequent items in the list
            • K - fold cross validation sets
              • Fit the network to the given data
                • Fit the model to the given data
                  • Build the generator
                    • Compute the DecisionStump
                      • Fit the quadratic model
                        • Train the model
                          • Evolves the population
                            • Run the crossover algorithm
                              • Plots the class distribution in 2d
                                • Evolve the population
                                  • Fit the model
                                    • Compute the posterior distribution

                                      Get all kandi verified functions for this library.

                                      Get all kandi verified functions for this library.

                                      ML-From-Scratch Key Features

                                      Machine Learning From Scratch. Bare bones NumPy implementations of machine learning models and algorithms with a focus on accessibility. Aims to cover everything from linear regression to deep learning.

                                      Installation

                                      copy iconCopydownload iconDownload
                                      $ git clone https://github.com/eriklindernoren/ML-From-Scratch
                                      $ cd ML-From-Scratch
                                      $ python setup.py install
                                      

                                      Polynomial Regression

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/polynomial_regression.py
                                      

                                      Classification With CNN

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/convolutional_neural_network.py
                                      
                                      +---------+
                                      | ConvNet |
                                      +---------+
                                      Input Shape: (1, 8, 8)
                                      +----------------------+------------+--------------+
                                      | Layer Type           | Parameters | Output Shape |
                                      +----------------------+------------+--------------+
                                      | Conv2D               | 160        | (16, 8, 8)   |
                                      | Activation (ReLU)    | 0          | (16, 8, 8)   |
                                      | Dropout              | 0          | (16, 8, 8)   |
                                      | BatchNormalization   | 2048       | (16, 8, 8)   |
                                      | Conv2D               | 4640       | (32, 8, 8)   |
                                      | Activation (ReLU)    | 0          | (32, 8, 8)   |
                                      | Dropout              | 0          | (32, 8, 8)   |
                                      | BatchNormalization   | 4096       | (32, 8, 8)   |
                                      | Flatten              | 0          | (2048,)      |
                                      | Dense                | 524544     | (256,)       |
                                      | Activation (ReLU)    | 0          | (256,)       |
                                      | Dropout              | 0          | (256,)       |
                                      | BatchNormalization   | 512        | (256,)       |
                                      | Dense                | 2570       | (10,)        |
                                      | Activation (Softmax) | 0          | (10,)        |
                                      +----------------------+------------+--------------+
                                      Total Parameters: 538570
                                      
                                      Training: 100% [------------------------------------------------------------------------] Time: 0:01:55
                                      Accuracy: 0.987465181058
                                      

                                      Density-Based Clustering

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/dbscan.py
                                      

                                      Generating Handwritten Digits

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/unsupervised_learning/generative_adversarial_network.py
                                      
                                      +-----------+
                                      | Generator |
                                      +-----------+
                                      Input Shape: (100,)
                                      +------------------------+------------+--------------+
                                      | Layer Type             | Parameters | Output Shape |
                                      +------------------------+------------+--------------+
                                      | Dense                  | 25856      | (256,)       |
                                      | Activation (LeakyReLU) | 0          | (256,)       |
                                      | BatchNormalization     | 512        | (256,)       |
                                      | Dense                  | 131584     | (512,)       |
                                      | Activation (LeakyReLU) | 0          | (512,)       |
                                      | BatchNormalization     | 1024       | (512,)       |
                                      | Dense                  | 525312     | (1024,)      |
                                      | Activation (LeakyReLU) | 0          | (1024,)      |
                                      | BatchNormalization     | 2048       | (1024,)      |
                                      | Dense                  | 803600     | (784,)       |
                                      | Activation (TanH)      | 0          | (784,)       |
                                      +------------------------+------------+--------------+
                                      Total Parameters: 1489936
                                      
                                      +---------------+
                                      | Discriminator |
                                      +---------------+
                                      Input Shape: (784,)
                                      +------------------------+------------+--------------+
                                      | Layer Type             | Parameters | Output Shape |
                                      +------------------------+------------+--------------+
                                      | Dense                  | 401920     | (512,)       |
                                      | Activation (LeakyReLU) | 0          | (512,)       |
                                      | Dropout                | 0          | (512,)       |
                                      | Dense                  | 131328     | (256,)       |
                                      | Activation (LeakyReLU) | 0          | (256,)       |
                                      | Dropout                | 0          | (256,)       |
                                      | Dense                  | 514        | (2,)         |
                                      | Activation (Softmax)   | 0          | (2,)         |
                                      +------------------------+------------+--------------+
                                      Total Parameters: 533762
                                      

                                      Deep Reinforcement Learning

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/deep_q_network.py
                                      
                                      +----------------+
                                      | Deep Q-Network |
                                      +----------------+
                                      Input Shape: (4,)
                                      +-------------------+------------+--------------+
                                      | Layer Type        | Parameters | Output Shape |
                                      +-------------------+------------+--------------+
                                      | Dense             | 320        | (64,)        |
                                      | Activation (ReLU) | 0          | (64,)        |
                                      | Dense             | 130        | (2,)         |
                                      +-------------------+------------+--------------+
                                      Total Parameters: 450
                                      

                                      Image Reconstruction With RBM

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/restricted_boltzmann_machine.py
                                      

                                      Evolutionary Evolved Neural Network

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/neuroevolution.py
                                      
                                      +---------------+
                                      | Model Summary |
                                      +---------------+
                                      Input Shape: (64,)
                                      +----------------------+------------+--------------+
                                      | Layer Type           | Parameters | Output Shape |
                                      +----------------------+------------+--------------+
                                      | Dense                | 1040       | (16,)        |
                                      | Activation (ReLU)    | 0          | (16,)        |
                                      | Dense                | 170        | (10,)        |
                                      | Activation (Softmax) | 0          | (10,)        |
                                      +----------------------+------------+--------------+
                                      Total Parameters: 1210
                                      
                                      Population Size: 100
                                      Generations: 3000
                                      Mutation Rate: 0.01
                                      
                                      [0 Best Individual - Fitness: 3.08301, Accuracy: 10.5%]
                                      [1 Best Individual - Fitness: 3.08746, Accuracy: 12.0%]
                                      ...
                                      [2999 Best Individual - Fitness: 94.08513, Accuracy: 98.5%]
                                      Test set accuracy: 96.7%
                                      

                                      Genetic Algorithm

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/genetic_algorithm.py
                                      
                                      +--------+
                                      |   GA   |
                                      +--------+
                                      Description: Implementation of a Genetic Algorithm which aims to produce
                                      the user specified target string. This implementation calculates each
                                      candidate's fitness based on the alphabetical distance between the candidate
                                      and the target. A candidate is selected as a parent with probabilities proportional
                                      to the candidate's fitness. Reproduction is implemented as a single-point
                                      crossover between pairs of parents. Mutation is done by randomly assigning
                                      new characters with uniform probability.
                                      
                                      Parameters
                                      ----------
                                      Target String: 'Genetic Algorithm'
                                      Population Size: 100
                                      Mutation Rate: 0.05
                                      
                                      [0 Closest Candidate: 'CJqlJguPlqzvpoJmb', Fitness: 0.00]
                                      [1 Closest Candidate: 'MCxZxdr nlfiwwGEk', Fitness: 0.01]
                                      [2 Closest Candidate: 'MCxZxdm nlfiwwGcx', Fitness: 0.01]
                                      [3 Closest Candidate: 'SmdsAklMHn kBIwKn', Fitness: 0.01]
                                      [4 Closest Candidate: '  lotneaJOasWfu Z', Fitness: 0.01]
                                      ...
                                      [292 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
                                      [293 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
                                      [294 Answer: 'Genetic Algorithm']
                                      

                                      Association Analysis

                                      copy iconCopydownload iconDownload
                                      $ python mlfromscratch/examples/apriori.py
                                      +-------------+
                                      |   Apriori   |
                                      +-------------+
                                      Minimum Support: 0.25
                                      Minimum Confidence: 0.8
                                      Transactions:
                                          [1, 2, 3, 4]
                                          [1, 2, 4]
                                          [1, 2]
                                          [2, 3, 4]
                                          [2, 3]
                                          [3, 4]
                                          [2, 4]
                                      Frequent Itemsets:
                                          [1, 2, 3, 4, [1, 2], [1, 4], [2, 3], [2, 4], [3, 4], [1, 2, 4], [2, 3, 4]]
                                      Rules:
                                          1 -> 2 (support: 0.43, confidence: 1.0)
                                          4 -> 2 (support: 0.57, confidence: 0.8)
                                          [1, 4] -> 2 (support: 0.29, confidence: 1.0)
                                      

                                      Community Discussions

                                      Trending Discussions on ML-From-Scratch
                                      • Why the predicted value by LinearRegression is exactly the same as the true value?
                                      Trending Discussions on ML-From-Scratch

                                      QUESTION

                                      Why the predicted value by LinearRegression is exactly the same as the true value?

                                      Asked 2020-Sep-24 at 23:10

                                      I'm doing a regression by LinearRegression and get the mean squared error 0. I think there should be some deviation(at least small). Could you please explain this phenomenon?

                                      ## Import packages
                                      import numpy as np
                                      import pandas as pd
                                      from sklearn.linear_model import LinearRegression
                                      from sklearn.metrics import mean_squared_error
                                      import urllib.request
                                      
                                      ## Import dataset
                                      urllib.request.urlretrieve('https://raw.githubusercontent.com/Data-Science-FMI/ml-from-scratch-2019/master/data/house_prices_train.csv',
                                                                 'house_prices_train.csv')
                                      df_train = pd.read_csv('house_prices_train.csv')
                                      x = df_train['GrLivArea'].values.reshape(1, -1)
                                      y = df_train['SalePrice'].values.reshape(1, -1)
                                      print('The explanatory variable is', x)
                                      print('The variable to be predicted is', y)
                                      
                                      ## Regression
                                      reg = LinearRegression().fit(x, y)
                                      mean_squared_error(y, reg.predict(x))
                                      print('The MSE is', mean_squared_error(y, reg.predict(x)))
                                      print('Predicted value is', reg.predict(x))
                                      print('True value is', y)
                                      

                                      The result is

                                      The explanatory variable is [[1710 1262 1786 ... 2340 1078 1256]]
                                      The variable to be predicted is [[208500 181500 223500 ... 266500 142125 147500]]
                                      The MSE is 0.0
                                      Predicted value is [[208500. 181500. 223500. ... 266500. 142125. 147500.]]
                                      True value is [[208500 181500 223500 ... 266500 142125 147500]]
                                      

                                      ANSWER

                                      Answered 2020-Sep-24 at 23:10

                                      While the comments are certainly correct that a model's score on its own training set will be inflated, it is unlikely to get a perfect fit with linear regression, especially with just one feature.

                                      Your problem is that you've reshaped the data incorrectly: reshape(1, -1) makes an array of shape (1, n), so your model thinks it has n features and n outputs with only a single sample, and so is a multiple linear regression with a perfect fit. Try instead with reshape(-1, 1) for x and no reshaping for y.

                                      Source https://stackoverflow.com/questions/64042359

                                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                      Vulnerabilities

                                      No vulnerabilities reported

                                      Install ML-From-Scratch

                                      You can install using 'pip install ML-From-Scratch' or download it from GitHub, PyPI.
                                      You can use ML-From-Scratch like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

                                      Support

                                      If there's some implementation you would like to see here or if you're just feeling social, feel free to email me or connect with me on LinkedIn.

                                      DOWNLOAD this Library from

                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                                      over 430 million Knowledge Items
                                      Find more libraries
                                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                                      Explore Kits

                                      Save this library and start creating your kit

                                      Share this Page

                                      share link
                                      Reuse Pre-built Kits with ML-From-Scratch
                                      Consider Popular Machine Learning Libraries
                                      Try Top Libraries by eriklindernoren
                                      Compare Machine Learning Libraries with Highest Support
                                      Compare Machine Learning Libraries with Highest Quality
                                      Compare Machine Learning Libraries with Highest Security
                                      Compare Machine Learning Libraries with Permissive License
                                      Compare Machine Learning Libraries with Highest Reuse
                                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                                      over 430 million Knowledge Items
                                      Find more libraries
                                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                                      Explore Kits

                                      Save this library and start creating your kit

                                      • © 2022 Open Weaver Inc.