Skip to main content
Share Your Experience: Take the 2024 Developer Survey
30 votes
Accepted

Siamese neural network

I think it's a great project! But it could do with a few improvements: Neuron Type(1) Suppose we have a network of perceptrons that we'd like to use to learn to solve some problem. For example, the ...
syb0rg's user avatar
  • 21.8k
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
  • 57.9k
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
  • 76.2k
8 votes
Accepted

Trending Machine Learning topics for Alexa

Structure Nothing! The code seems fairly straightforward and clear, and I was able to understand what you’re doing even if I didn't study flask too much. So I don’t think there’s anything wrong with ...
Grajdeanu Alex's user avatar
8 votes
Accepted

Implementation of linear regression in Python

Just reviewing normalizeFeatures. Instead of a comment explaining what the function does, write a docstring. (Docstrings are available from the interactive ...
Gareth Rees's user avatar
  • 49.6k
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.4k
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,703
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
  • 76.2k
7 votes
Accepted

Make a summary from a larger text-file

Use a linter The first thing I do when reviewing JavaScript code is run it through a linter. There several online linters, JSHint for example. JSHint will complain about ES6 features: 'arrow ...
janos's user avatar
  • 111k
7 votes
Accepted

Random forest and machine learning

Disclaimer: I'm not familiar with the work you're doing, so I'll limit my comments to the structure of your code. Generally, I'd make the following changes: Split data and code Write more functions ...
Jeremy Weirich's user avatar
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
  • 5,906
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,269
6 votes
Accepted

A CNN in Python WITHOUT frameworks

Disclaimer: I know practically nothing about ML or neural networks. The big problem with this program is readability. There are no docstrings or comments, so even somebody who knows about ML would ...
alexwlchan's user avatar
  • 8,555
6 votes
Accepted

Classification tree in Swift

So, let's focus on your Node class at the top. I started off, without looking at anything else, and just swiftlinting it. You have a 55 line file with 20 ...
nhgrif's user avatar
  • 25.3k
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,800
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.4k
6 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
  • 5,688
5 votes
Accepted

Modified Taylor diagrams

Let's start with the obvious remarks about whitespace: Whitespace is important in Python. You got trailing whitespaces all over the place and you use an indentation of 2 spaces where 4 is prescribed ...
Mast's user avatar
  • 13.4k
5 votes
Accepted

Apriori algorithm in Python 2

My biggest piece of advice would be to replace freqSet = defaultdict(int) with a Counter. Counters are a datatype designed to do exactly what you are doing with ...
Oscar Smith's user avatar
  • 3,597
5 votes
Accepted

Machine learning tic-tac-toe implementation

I see a number of things that may help you improve your program. Fix the bug The code marks squares with uppercase letters, but the gameStatus code looks for a ...
Edward's user avatar
  • 66.4k
5 votes

Trending Machine Learning topics for Alexa

You could break your main function into multiple functions. Doing that will not even make main() much more clearer but also you ...
Ashwini Chaudhary's user avatar
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
Accepted

Random Weighted Classifier in R

Some improvements: ...
minem's user avatar
  • 942
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,349
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.4k
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,295
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
  • 3,516
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
  • 27.8k
4 votes
Accepted

Clustering 16 million records in parallel

Hard to tell without sample data, but lets start with a cleaned up version as there's soo much duplicated code here and the formatting is inconsistent. The require ...
ferada's user avatar
  • 11.1k

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