Hi Kelden,

I answered your SO question but for the record this is what happens:

date_index is a scalar and you type date_index.columns which raises the error.

So you just need this:

def predict_price(dates,price):
    date_index = np.where(date_format.columns == dates)[0][0]

    x = np.zeros(len(date_format.columns))
    if date_index >= 0:
        x[date_index] = 1

    return prediction.predict([x])[0]

predict_price('Feb 20, 2018', 1000)

Bests,
Makis


On 11 Jun 2020, at 15:12, Kelden Dorji 
<keldendraduldo...@gmail.com<mailto:keldendraduldo...@gmail.com>> wrote:



Hi scikit-learn,
I have a question related to regression models. Please find my question in the 
link below. I am still new to this and would appreciate any help. Thank you and 
have a nice day!

https://stackoverflow.com/questions/62325079/issues-with-regression-model-giving-inverse-relationship

Kelden Dradul Dorji
_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn

_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn

Reply via email to