var digits = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
var numbers = [digits[0], digits[1]...digits[9], digits[1] + digits[0], digits[1] + digits[1]...];

What would you use to build a model that can predictNextNumber(19)=20 by understanding how counting works?

  • 2
    $\begingroup$ myLearningAlgorithm(int x) { return x + 1; } $\endgroup$
    – SmallChess
    Aug 28 '16 at 11:17
  • 1
    $\begingroup$ Do you want to use text input (strings) or numeric input? $\endgroup$
    – Pieter
    Aug 28 '16 at 18:49

I suggest using supervised learning and employing a linear model: linear regression.

This is a perfectly linear system (y=x+1), so linear regression will work just fine i.e. perfectly. Further, you have an infinite amount of data you can use to train the system, so it should be easy to train ;-) I jest... I think that two data points will be sufficient, again, since it is perfectly linear!

Pedagogically, the triviality of this extremely simple linear system gets a little more interesting when you try analogue based methods like support vector machine (SVM) - which should also be able to provide a perfect result, decision trees or random forests, and even naive Bayes regressors.

Though its useful to start learning with very simple systems, I suggest quickly moving on to something more complex, i.e. don't get too stuck in your own head for the trivial linear model. Don't forget that the power of data science and machine learning lies in its statistical nature, so try to find a test case that includes some statistical variation in the input.

Hope this helps!

  • $\begingroup$ The problem with treating this as a linear system is a chicken-and-egg situation. Using a y=x+1 model is telling the system how to count, not having the system learn from data. Its the difference between coding a tic-tac-toe game by either coding the winning algorithm or coding a general learning algorithm and playing sample games. $\endgroup$
    – Spacedman
    Aug 29 '16 at 11:14
  • $\begingroup$ @Spacedman, linear regression models do not require that the equation be provided to the algorithm apriori. Rather the equation is inferred from the data. In this case the linear behavior is so simple that only two records are needed. I'm not proposing that y=x+1 be given, just that two records be given. No chicken and egg problem here. $\endgroup$
    – AN6U5
    Aug 29 '16 at 14:16
  • $\begingroup$ The only thing the system "learns" by fitting a linear model is the intercept and slope. The slope is just the way of saying "add 1" or "add 2" or "add 3.14" for every 1 unit in x. The machine is not learning to count, its just learning what steps to count in. We're still waiting for the OP to clarify what they mean. Do they want to put addition or linearity into the system a priori, or do they want a symbolic learning process that has no inherent idea about "1" and "2" being mathematical concepts. $\endgroup$
    – Spacedman
    Aug 29 '16 at 18:51

Feed enough examples into a learning algorithm. In pseudocode:

L = learn_plus_one()

after being taught enough examples, it should figure out that 73 plus one is 74, even though it really knows nothing about addition, its just discovered the pattern from the examples.

So what does learn_plus_one look like? Well that could be a neural network, or any other machine learning system really. Your question is quite vague so I cant be specific.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.