Skip to main content
16 votes
Accepted

C++20 : Simple Softmax classifier for MNIST dataset

In addition to Toby Speight's remarks, I would add: Use constexpr for all constants I see you already used constexpr for ...
G. Sliepen's user avatar
  • 69.5k
10 votes

C++20 : Simple Softmax classifier for MNIST dataset

That's a very big list of includes! It might be a sign that you have functionality that should be split out to separate source files (e.g. filesystem read/write away from the core computation). ...
Toby Speight's user avatar
  • 88.7k
9 votes
Accepted

Remove hot-spots from picture without touching edges

np.sum(neighborhood) is computing the mean filter with a rectangular neighborhood (sum filter, really, but since you compare to 0, the scaling doesn’t matter). This ...
Cris Luengo's user avatar
  • 7,041
9 votes

Python project to scrape webpages and build text datasets for ML purposes

comments Lines of code: ~200 I'm sure that was true when you wrote it. Looks like you've added a hundred or so lines since then. Comments tend to bit rot as the codebase evolves, which is why we ...
J_H's user avatar
  • 43.3k
8 votes
Accepted

Simple neural network in c++

Looks plausible. The two biggest pieces of advice I have for you are: Format your code consistently and idiomatically! One easy way to do this is to use the ...
Quuxplusone's user avatar
  • 19.7k
8 votes

C++20 : Simple Softmax classifier for MNIST dataset

Toby Speight and G. Sliepen gave excellent feedbacks from the programmer's perspective; A friend of mine gave some feedbacks from the machine learning researcher's perspective, as follows: User ...
frozenca's user avatar
  • 1,751
8 votes

Remove background from a directory of JPEG images

Performance This is a simple loop, and I would expect that the majority of time is spent in rembg.remove() - but you should profile to demonstrate that. If my guess ...
Toby Speight's user avatar
  • 88.7k
7 votes
Accepted

How to make my neural network train faster

I don't know much about machine learning, so I'll be reviewing your style. Also, this is my first review, I hope I do it right. Use Python 3 Judging by your print statements, you are currently using ...
gazoh's user avatar
  • 3,399
7 votes
Accepted

Univariate linear regression from scratch in Python

About OOP I tried to exploit OOP as much as I could, instead of using a procedural approach to write the algorithm. Although I believe that your approach was fine, using OOP for the sake of OOP is ...
Dair's user avatar
  • 6,220
7 votes

Python project to scrape webpages and build text datasets for ML purposes

You have docstrings and comments that are very useful. Your code also seems to be very well organized and structured. The API is simple enough. My only questions/suggestions are: Security Concerns You ...
Booboo's user avatar
  • 4,101
6 votes

K-nearest neighbours in C# for large number of dimensions

You should definitely avoid computing distance from every training sample. That's the main cause of inefficiency. By using proper data structure, the search for nearest neighbours can be done in \$O(...
Otakaro's user avatar
  • 61
6 votes
Accepted

K-means function in Python

You can vectorize this at various points to apply arithmetic to the whole dataframe rather than row-by-row. ...
Stuart's user avatar
  • 2,860
6 votes
Accepted

My first functional naive neural network in C++

#define WEIGHT_RANDOM_RANGE .1 Don't use #define to make your constants. Use constexpr. In ...
JDługosz's user avatar
  • 11.7k
6 votes
Accepted

ML Project - Weather Prediction on Jupyter Notebook

Again, this looks good. Burying the to_datetime() call down in the loading helper is nice, it keeps things organized. Nice use of the "viridis" palette. ...
J_H's user avatar
  • 43.3k
5 votes
Accepted

Random Weighted Classifier in R

Some improvements: ...
minem's user avatar
  • 1,012
5 votes
Accepted

Naive Bayesian Algorithm in Python with cross-validation

DRY There is a whole lot of repetition in this code. Especially if you look at the complete code for the 3 classes. Imagine you need to add a fourth class... The way to tackle this is to separate ...
Maarten Fabré's user avatar
5 votes

Simple Linear Regression in C++

C++ is not Java. All these this-> can be safely omitted. Most of the methods of lsr.cpp are better expressed via STL numeric ...
vnp's user avatar
  • 58.7k
5 votes
Accepted

Polynomial regression with Gradient Descent: Python

Encoding polynomials According to your code, you represent a polynomial $$\sum\limits_{k=0}^{n} a_kx^k$$ as [a_1, ..., a_n, a_0] which is odd to my eyes. The ...
Eman Yalpsid's user avatar
  • 1,569
5 votes

C++20 : Simple Softmax classifier for MNIST dataset

function should return values Others have mentioned "return things rather than using output parameters" but here is an elaborated example. ...
JDługosz's user avatar
  • 11.7k
5 votes

C++: Linear Regression and Polynomial Regression

My first thought is to change the LinearRegression::fit() method into a constructor called with the same arguments--that is, rename ...
Mark H's user avatar
  • 2,435
5 votes
Accepted

Linear Regression in Scikit_learn

To test whether the libraries do what you would expect simply create a very simple dataset (e.g. y = 2x + normalerror) which OLS should deal with without any issues. From my understanding of the ...
LOLcat_enjoyer's user avatar
5 votes

Minimal AlphaGo algorithm implementation for game 2048, connect4

The code layout is good, and you used meaningful names for classes, functions and variables. Assuming this code is to be used as a starting point for the students, I recommend adding comments at the ...
toolic's user avatar
  • 16.4k
5 votes
Accepted

Minimal AlphaGo algorithm implementation for game 2048, connect4

You aim to teach folks to write good code. A noble goal! deps Before a student can run or enhance this codebase, they first need to get over some installation hurdles. This is a common hangup for ...
J_H's user avatar
  • 43.3k
5 votes

Machine Learning Model to Predict the Type of Variable Star from Light Curve

You're asking for two very separate critiques, of ML approach and of implemented code. That P-R curve looks just dreadful. It's saying that for super obvious cases you nail it, and then after that you'...
J_H's user avatar
  • 43.3k
5 votes
Accepted

ML Project on Predicting Weather App

Looks good. I didn't notice any data leakage. future warning Passing palette without assigning hue is deprecated That should ...
J_H's user avatar
  • 43.3k
5 votes
Accepted

Flask App: ML Project on Predicting Weather

High level advice: helper functions are your friends, use lots of little ones. defer execution This runs at import time: ...
J_H's user avatar
  • 43.3k
4 votes
Accepted

Python Perceptron

Here's your code slightly changed. Please check python conventions, PEP8, etc. Also, learn how to name variables, functions, and classes. Furthermore, learn how to comment. Usually, you comment on the ...
Raphael's user avatar
  • 160
4 votes
Accepted

Genetic algorithm for playing Tetris

The thing that strikes me immediately is the amount of repetition in genetic.py. Suppose that you needed to add a new trait. How many places in the code would have to be updated? Well, you'd need to ...
Gareth Rees's user avatar
  • 50.1k
4 votes

Simple neural network implementation in Python

A more pythonic way of writing self.momentum = [0 for _ in range(input_neurons)] would be self.momentum = [0]*input_neurons
Noah Haasis's user avatar
4 votes
Accepted

Basic Single Header statistics and ml libray for C++ - Scikit-Learn like implementation

Wrapper classes I don't get why many algorithms (like get_mean, get_median, ...) are wrapped inside a class that is basically ...
hoffmale's user avatar
  • 6,528

Only top scored, non community-wiki answers of a minimum length are eligible