Don’t forget to like this video and subscribe!
I’ll also add more supervised and unsupervised machine learning model later!
Also for featureMatrix, number of rows are equal to number of data. Meanwhile number of columns are equal to number of variables contained in that particular data in featureMatrix.
Same goes for labelVector, where number of rows are number of data, but only have one column because that is the actual value related to one given data.
Available Models
 Linear Regression
 Logistic Regression
 KMeans
 (Linear) Support Vector Machine
How To Use
You need two libraries (one for matrix library and another for machine learning library). You must use the matrix library that is made by me or it will not work!
(PS: it’s probably not the fastest or best matrix library, but I really don’t want to deal with legal issues if I use other people’s matrix libraries)
Step 1
Once you put those two libraries into your game make sure you link the Machine Learning Library with the Matrix Library. This can be done via setting the “AqwamRobloxMatrixLibraryLinker” value (under the Machine Learning library) to the Matrix Library.
Step 2
Use require() on Machine Learning Library.
Step 3
Here are the examples.
local MachineLL = require(game.ServerScriptService.AqwamRobloxMachineLearningLibrary)
local LinearRegression = MachineLL.LinearRegression
local LogisticRegression = MachineLL.LogisticRegression
local modelParameters, cost = LinearRegression:train(featureMatrix, labelVector, maxNumberOfIterations, learningRate, lossFunction, targetCost, suppressOutput)
local result = LinearRegression:predict(featureMatrix, modelParameters)
local modelParameters, cost = LogisticRegression:train(featureMatrix, labelVector, maxNumberOfIterations, learningRate, sigmoidFunction, targetCost, suppressOutput)
local result = LogisticRegression:predict(featureMatrix, modelParameters)
Make sure the matrices/vectors are created like shown below:
local featureMatrix = {
{ 0, 0},
{10, 10},
{3, 3},
{2, 2},
{ 2, 2},
{ 1, 1},
{1, 1},
{ 3, 3},
{8, 8},
}
local labelVectorRegression = {
{ 0},
{10},
{3},
{2},
{ 2},
{ 1},
{1},
{ 3},
{8},
}
local labelVectorLogistic = {
{1},
{1},
{0},
{0},
{1},
{1},
{0},
{1},
{0}
}
local testFeatureMatrix = {
{3, 3},
}
Explanation

In order for you to create a machine learning model, you need to train using input data first by putting it in the first two arguments :train() function (featureMatrix and labelVector). featureMatrix is the matrix for values to be input, and labelVector is the vector containing actual values (or rather, selected feature) that has certain relationship with the featureMatrix.

You may set additional settings to other arguments. However, you can leave it to set it as default. Using nil as a value will set that particular setting as default.

Once the model is run using the values given, it will generate a model parameter that you can use for your future prediction. Make sure to save it in DataStore if you want to keep the model parameters!

To predict values, you can use :predict() function, where the first argument will be your feature matrix and the second argument is your generated model.
Differences Between Linear and Logistic Regression

Linear Regression: predicts continuous values (e.g. 1.2, 3.1, 2, and so on)

Logistic Regression: predicts discrete values that falls either 0 or 1 only
How To Save Models

Save it to DataStoreService

Copy paste to any text editor
Important Notes

When using the feature matrix and label vector to train the models, make sure the number of rows are the same!

The labelVector must only have (n x 1) dimension!

Make sure the value of learningRate is between 0 and 1! Anything else may cause the machine learning model not work properly!

For the best model accuracy, ensure that the cost decreases until it stabilizes. If there is a large increase of cost value after a while, then it means the training is not complete and the model may not be accurate. To get best model accuracy, make sure you play around with the argument settings

Consequently, if the cost keeps on steadily increasing, it means your learning rate is too large and started to diverge. Try smaller values.
Use Cases
LinearRegression:
 Make prediction on how long will a player reach certain level
 Spawn an enemy where the difficulty is based on input
LogisticRegression:
 Make an enemy that makes decision between 2 choices (e.g. fighting and running)
 Detect hacking players
KMeans
 Group players in terms of experience level
SupportVectorMachine
 Detect hacking players
Libraries Download Links
Required Libraries:
Aqwam's Roblox Machine Learning Library  Roblox
Aqwam's Roblox Matrix Library  Roblox
Bonus Libraries:
Github
GitHub  AqwamCreates/AqwamRobloxMachineLearningLibrary: A Machine Learning Library For Roblox
GitHub  AqwamCreates/AqwamRobloxMatrixLibrary: A Matrix Library For Roblox
GitHub  AqwamCreates/AqwamRobloxDataMiningLibrary: A Data Mining Library For Roblox
Known Problems

Some times the cost value can turn to nan. This is because there are very long decimal points when training the model parameters. A short term fix is to add target cost or limit the max number of iterations when training the model.

Setting c value for support vector machine does not change anything in the model for now. You can use this model without issues.
Models Under Development
 ExpectationMaximization