Would a machine learning classifier algorithm be able to determine whether a number is odd or even? I was testing out some classifier algorithms in scikit but wasn't able to find a classifier (linear or non-linear) that managed to provide good prediction on whether an input number is odd or even. Here's the code:
import numpy as np
from sklearn.linear_model import SGDClassifier
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV, RidgeClassifierCV
from sklearn.svm import SVC, NuSVC
length = 10000

evens = np.array([np.arange(0, length*2, 2)])
zeroes = np.array([np.resize([[0]], length)])

odds = np.array([np.arange(1, length*2, 2)])
ones = np.array([np.resize([[1]], length)])

evens_data = np.concatenate((evens.T, zeroes.T), axis=1)
odds_data = np.concatenate((odds.T, ones.T), axis=1)

data = np.array([np.append(evens_data, odds_data)]).reshape(length*2, 2)
np.random.shuffle(data)
X = np.array([data[:,0]]).reshape(length*2,1)
y = data[:,1]

## 
## Tried all algorithms below
##
# clf = LogisticRegression(random_state=42, max_iter=1000)
# clf = LogisticRegressionCV(cv=5, random_state=42, max_iter=1000)
# clf = RidgeClassifierCV(cv=5)
# clf = SGDClassifier(max_iter=1000)
# clf = SVC(random_state=42, max_iter=1000)
clf = NuSVC(random_state=42)
clf.fit(X, y)

for tuple_ in [(np.arange(0, 20, 2), 0), (np.arange(1, 22, 2), 1)]:
    X, y = tuple_
    for x in X:
        predicted = clf.predict([[x]])
        print(f'{"Good" if predicted[0] == y else "Bad"} predicting: {x} is {predicted[0]} and it should be {y}')

I anticipate some people saying that I could (should) have processed my data in a more machine learning ready way (like translating it to binary) but I didn't want to do that as my idea is to being able to find a classifier algorithm that could clusterize the data based on features not as clear as odd/even but on something the analyst couldn't foresee just by looking at the data.
I wonder if Linear or SVM-based classifier algorithms aren't able to do that. If not, I'd appreciate someone explaining why not.
Also, (if Linear / SVM-based classifiers are not indicated for this job) what would be the right tool for that?

As is often the case, the issue is one of defining your features.
If you use the digits of the binary expansion of the number as features, your classifiers should have no problem picking up the fact that only one feature perfectly separates the target classes.
Here  I construct an example where the training data is 500 integers randomly selected from $\{1,2, \dots, 1000\}$ and use linear regression to classify:
y <- sample(1:1000, 500, replace=FALSE)

x <- t(matrix(as.integer(intToBits(y)), 32))
x <- x[, 1:10]  # as the numbers < 1001 don't use any higher bits

tgt <- y %% 2

train_data <- data.frame(cbind(tgt,x))
m1 <- lm(tgt~., data=train_data)

y_pred <- sample(1:1000, 10, replace=FALSE)
x_pred <- t(matrix(as.integer(intToBits(y_pred)), 32))[, 1:10]
test_data <- data.frame(x_pred)

test_results <- data.frame(actual = y_pred, odd_even = predict(m1, test_data))

# Clean up the results, as floating point math doesn't always give exact integers
test_results$cleaned_odd_even <- ifelse(test_results$odd_even < 1e-10, 0, 1)

and the results:
> test_results
   actual      odd_even cleaned_odd_even
1     727  1.000000e+00                1
2     544 -1.311871e-15                0
3     689  1.000000e+00                1
4     647  1.000000e+00                1
5     444 -1.116987e-15                0
6      89  1.000000e+00                1
7     168 -1.229638e-15                0
8     770 -1.401580e-15                0
9     870 -1.107620e-15                0
10     31  1.000000e+00                1

This would allow you to classify any non-negative integer based on its lowest order 10 bits (or however many bits we include).  The algorithm figured out that only the lowest order bit mattered.
