I'm new at ML and have a problem with catboost. So, I want to predict function value (For example cos | sin etc.). I went over everything but my prediction is always straight line

Is it possible and if it is, how i can issue with my problems

I will be glad to any comment ))

train_data = np.array(np.arange(1, 100, 0.5))
test_data = np.array(np.arange(100, 120, 0.5))

train_labels = np.array(list(map(lambda x : math.cos(x), np.arange(1, 100, 0.5))))

model = CatBoostRegressor(iterations=100, learning_rate=0.01, depth=12, verbose=False)
model.fit(train_data, train_labels)
preds = model.predict(test_data)


This picture shows what i want:

enter image description here


The underlying model of CATBoost is decision trees. Outside of the domain they have been trained on, their continuation is a straight line. So there is no way for it to generate other results for values outside of the range seen during training. It also cannot learn the periodicity of your function.

A polynomial kernel model (with SVM) might do a bit better, but also likely to diverge quickly outside the training domain. In general, avoid extrapolation with machine learning, if you can.


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.