Machine Learning Program I've written a program that finds the difference between data and gives output.
Here's the code:
import json
import numpy as np
print(&quot;This is a basic machine learning thing.&quot;)
baseData = {&quot;collecting&quot;:True,&quot;x&quot;:[],&quot;y&quot;:[]}
while baseData[&quot;collecting&quot;]:
  baseData[&quot;x&quot;].append(float(input(&quot;X:&quot;)))
  baseData[&quot;y&quot;].append(float(input(&quot;Y:&quot;)))
  if input(&quot;Do you want to keep feeding data? Press enter for yes, or type anything for no.&quot;) != &quot;&quot;:
    baseData[&quot;collecting&quot;] = False
if len(baseData[&quot;x&quot;]) == len(baseData[&quot;y&quot;]):
  xdata = baseData[&quot;x&quot;]
  ydata = baseData[&quot;y&quot;]
  nums = []
  for i in range(len(xdata)):
    nums.append(xdata[i] - ydata[i])
  median = np.median(nums)
else:
  print(&quot;malformed data&quot;)
def getY(x):
  pass
while True:
  data = input(&quot;X/Data:&quot;)
  print(int(data)-median)

To work the program, give it X and Y data, then give it X data and it will predict Y data.
Maybe you should check validity of the input and ask again if input is wrong?
while baseData[&quot;collecting&quot;]:
  baseData[&quot;x&quot;].append(float(input(&quot;X:&quot;)))

This is always True, so just discard this part:
if len(baseData[&quot;x&quot;]) == len(baseData[&quot;y&quot;]):

Maybe you should give an option to exit?
while True:
  data = input(&quot;X/Data:&quot;)
  print(int(data)-median)

And in general, calling this a &quot;machiene-learning thing&quot; is quite a stretch of imagination, no? Maybe you should have a look at how to fit data. I.e. a basic linear model fit.