Widespread Augmented Reality

Widespread Augmented Reality
Click on the image to get the Android Augmented Reality Heads up Display

Sunday, August 13, 2023

Simple Python Machine Learing Example

Code copied from https://towardsdatascience.com/simple-machine-learning-model-in-python-in-5-lines-of-code-fe03d72e78c6
from sklearn.linear_model import LinearRegression
from random import randint
#Training Dataset
TRAIN_SET_LIMIT = 1000
TRAIN_SET_COUNT = 100
TRAIN_INPUT = list()
TRAIN_OUTPUT = list()
for i in range(TRAIN_SET_COUNT):
  a = randint(0, TRAIN_SET_LIMIT)
  b = randint(0, TRAIN_SET_LIMIT)
  c = randint(0, TRAIN_SET_LIMIT)
  op = a + (2*b) + (3*c)
  TRAIN_INPUT.append([a, b, c])
  TRAIN_OUTPUT.append(op)
#Train the Model
predictor = LinearRegression(n_jobs=-1)
predictor.fit(X=TRAIN_INPUT, y=TRAIN_OUTPUT)
#Send test data to the model
X_TEST = [[10, 20, 30]]
outcome = predictor.predict(X=X_TEST)
coefficients = predictor.coef_
print('Outcome : {}\nCoefficients : {}'.format(outcome, coefficients))

No comments:

Post a Comment