# Machine-learning algorithm / library for outcome prediction

I am extremely new to this data science world so bear with me if my question is not very clear, I'd be glad to clarify. What I am looking for is simple: train a program with a set of values (5 ordered integer inputs, 1 boolean output). Then I would give it 5 inputs where the outcome is not known, and it has to tell me the outcome.

• It sounds like a straightforward classification problem. If you tell us more about the nature of the data we can be more specific.
– Emre
Jun 8 '17 at 0:24
• Prediction engine for mixed martial arts. Every bout has two fighters, and fighters have a set of stats (Reach, takedown attempts, takedown accuracy, striking attempts, striking accuracy, etc.). The engine would learn from about 20 years worth of fights, comparing the differentials of these stats between the two fighters, and then register the result (the winner). Obviously there are a lot more variables that should be taken into consideration, but this is what I will be exercising with as an introduction to machine-learning. Jun 8 '17 at 1:19
• – Emre
Jun 8 '17 at 2:21
• Will do, thank you for the recommendation. Do you think the NaiveBayes algorithm will work for what I'm trying to achieve ? The example from this library seems to be relevant: accord-framework.net/docs/html/… Jun 8 '17 at 3:07
• It's the right type of algorithm so it's worth a try.
– Emre
Jun 8 '17 at 3:13

It is a basic classification model. Our focus is to train the model using training dataset and evaluate its performance with the test set.

In your case, assume you have 10 numbers as input and a binary output. Consider random 8 entries as your training data and train it with any classification algorithm using R/Python. Then test it on the remaining entries which acts as a test data.

Since it is associated with classification we need to consider performance metrics like accuracy, precision and recall based on the labeled feature.

For more details on classification try here

scikit-learn is a powerful and a very very simple ML library for Python.

Your doubt is about a Classification Problem, where you're going to predict a class (True or False) given some input data.

There are many classifiers that you can use.

In this example I've used Logistic Regression

from sklearn.linear_model import LogisticRegression

# Input data
data = [[1.0, 2.0, 3.0, 4.0, 5.0], [6.0, 7.0, 8.0, 9.0, 10.0]]

# Target values for input data
target = [True, False]

# Define the model (default parameters)
model = LogisticRegression(C=1.0, penalty='l1', tol=1e-6)

# Train the model
model.fit(data, target)

# Once the model is trained, we make a prediction
model.predict([[1.0, 2.0, 3.0, 4.0, 5.0]])


If you execute this code, the prediction for that data is False

• shouldn't it return True? First element of the target array as match to first element of data array? Sep 6 '17 at 13:02
• It's a very simple example, so please don't take it too seriously. See that there're only 2 rows for training the model, and it must not fit with 100% of accuracy. Sep 6 '17 at 13:20
• Decreasing the regularisation (by increasing C to e.g. 10), or changing weight penalty type to 'l2' should make the predictions work as expected. Or just using the default model = LogisticRegression() - that might be better in this answer, as including regularisation terms without explaining them makes the example more complicated and the goal is a simple example . . . (also your comment # (default parameters) is not correct, the defaults are (C=1.0, penalty='l2', tol=1e-4) Sep 7 '17 at 9:59

It seems overkill, but I gonna tell you how to get strict math dependency from your data:

1. same sets of inputs should be converted to single set and rate instead of bool, where true increments rate and false decrements the rate for same sets of values.
2. input vars set should be converted to system of equations: $v_1=a, v_2=b ...$ where $a,b,c,d,e$ are particular inputs set. And one more var for rate.
3. simultaneous equations may be converted to single equation formed by summing it squares: $(v1-a)^2+(v2-b)^2+(v3-c)^2...=0$
4. the equation may be used if you insert new set of vars values in equation and see which rate will outcome.
5. find the equation that gives best fit to your set of data.

If you have aggressive calculation abilities then you may want to proceed to next level of precision:

1. Do steps 1-3 of the previous sequence.
2. Different sets are non-simultaneous equation of the system you need. Non-simulteneous system may be converted to single equation using multiplication. You'l have big product of all your data like $((v1-a1)^2+(v2-b1)^2+(v3-c1)^2...)((v1-a2)^2+(v2-b2)^2+(v3-c2)^2...)((v1-a3)^2+(v2-b3)^2+(v3-c3)^2...)...=0$
3. Use the system and OpenCL or IBM XL C++ compiler OpenMP extension offload to Nvidia GPUs feature to simulteneously calculate members of the product that have all information of flight results.

Similar approach is used in this extrapolator implementation and its math framework.