# How to predict based off one one value in sklearn python

Is it possible to train data and predict based on just an x value?

On my chart, I have the point (35,20) in black. This value when predicted with 35, should return 0, but a point like 15 - with most data points above the black line - should return 1

This is what my data looks like

``````def createFeatures(startTime, datapoints, function, *days):

trueStrength = []
functionData = []
beginPrice = []
endPrice = []
deltaPrice = []

for x in range(datapoints*5):

#----Friday Data----
if x%4 == 0 and x != 0:
endPrice.append((sg.HighPrice[startTime+x]+sg.LowPrice[startTime+x]+sg.ClosePrice[startTime+x])/3)

#----Monday Data----
if x%5 == 0:
functionData.append(function(trueStrength, startTime+x, *days))
beginPrice.append((sg.HighPrice[startTime+x]+sg.LowPrice[startTime+x]+sg.ClosePrice[startTime+x])/3)

for x in range(len(beginPrice)):
deltaPrice.append(endPrice[x] - beginPrice[x])
return functionData , deltaPrice

def createLabels(data, deltaPrice):
labels = []
for x in range(len(data)):
if deltaPrice[x] > 0:
labels.append(1.0)
else:
labels.append(0.0)
return labels

x, y = createFeatures(20, 200, ti.SMA, 7)
z = createLabels(x,y)

``````

Then here's my Linear Regression model:

``````labels = np.asarray(at.z)
x = np.asarray([at.x])
y = np.asarray([at.y])

testX=35.1
testY=20.1
test = np.array([[testX, testY]])

clf = LinearRegression().fit(x, y)
print clf.predict(4)

``````