Linked Questions

Popular Questions

How to predict based off one one value in sklearn python

Asked by At

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:

        #----Monday Data----
        if x%5 == 0:
            functionData.append(function(trueStrength, startTime+x, *days))

    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:
    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])

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

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

Related Questions