Does the HTM.core predictor method accept negative values

I am training the htm.core.algorithms.predictor on some EEG data, since it has negative amplitude, its giving me this error:

This makes me wonder if it can accept negative values , since when I take the absolute values it works fine.
This is a part of my code:

for count, record in enumerate(y):
    print("active cells" , tm.getActiveCells())
    if count%10000==0:
        print(count/len(y)*100)
    consumption = float(record)
    #p
   # print(consumption)
    #print(count, record)

    # Call the encoders to create bit representations for each value.  These are SDR objects.
    consumptionBits = scalarEncoder.encode(record)

    # Concatenate all these encodings into one large encoding for Spatial Pooling.
    encoding = consumptionBits
    #print(encoding)
    enc_info.addData(encoding)

    # Create an SDR to represent active columns, This will be populated by the
    # compute method below. It must have the same dimensions as the Spatial Pooler.
    activeColumns = SDR(sp.getColumnDimensions())

    # Execute Spatial Pooling algorithm over input space.
    overlaps = sp.compute(encoding, True, activeColumns)
        
    sp_info.addData(activeColumns)
    
    # Execute Temporal Memory algorithm over active mini-columns.
    tm.compute(activeColumns, learn=True)
    tm_info.addData(tm.getActiveCells().flatten())

    # Predict what will happen, and then train the predictor based on what just happened.
    pdf = predictor.infer(tm.getActiveCells())
    for n in (1, step):
        if pdf[n]:
            predictions[n].append(np.argmax(pdf[n]) * predictor_resolution)
        else:
            predictions[n].append(float('nan'))

    anomaly_Likelihood = anomaly_history.anomalyProbability(record, tm.anomaly)
    anomaly.append(tm.anomaly)
    logAnomalyLikelihood = np.log(1.0000000001 - anomaly_Likelihood) / -23.02585084720009
    anomalyLikelihood.append(anomaly_Likelihood)
    log_anomalyLikelihood.append(logAnomalyLikelihood)
    print("Int is " , int(consumption / predictor_resolution))
    
    predictor.learn(count, tm.getActiveCells(), int(consumption / predictor_resolution) )
1 Like

I suspect that you can create a mapping that converts your value to a positive value. You will need to know the range of the income value (say from -10.0 to 10.0) and then convert/map it to a positive range (say from 0.0 to 20.0)

1 Like