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 ...
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). ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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(...
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.
...
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 ...
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.
...
5
votes
Accepted
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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'...
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 ...
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:
...
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 ...
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 ...
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
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
machine-learning × 254python × 182
neural-network × 38
python-3.x × 36
performance × 34
algorithm × 29
tensorflow × 29
numpy × 24
java × 19
pandas × 19
c++ × 16
ai × 16
clustering × 12
python-2.x × 11
beginner × 9
statistics × 9
natural-language-processing × 9
numerical-methods × 8
pytorch × 8
image × 7
matlab × 7
opencv × 7
data-mining × 7
object-oriented × 6
mathematics × 6