Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perceptron predict_many as bool #1473

Open
raul-parada opened this issue Dec 10, 2023 · 4 comments
Open

Perceptron predict_many as bool #1473

raul-parada opened this issue Dec 10, 2023 · 4 comments

Comments

@raul-parada
Copy link

Hi,

Why my predict_many output is bool instead of a value using perceptron? Is it possible to change this behavior?

@raphaelsty
Copy link
Member

raphaelsty commented Dec 10, 2023

Hi @raul-parada,

The perceptron has a ´predict_proba_many´ method in order to return probabilities over a batch of input samples. Is it what you are looking for?

As part of River, the perceptron is seen as a special case of logistic_regression, are you looking for at regressor which output continuous values? If you are interested in regressor then you need to switch to the MLPRegressor https://riverml.xyz/latest/api/neural-net/MLPRegressor/

@raul-parada
Copy link
Author

Hi @raphaelsty,

I'm looking for direct prediction values. I've already tried MLPRegressor, however, I've faced some issues (due to the input). Find a reproducible example here #1460

@raphaelsty
Copy link
Member

Seems like it's a problem that's come from your input that does not fit River api.

When using learn_one and predict_one, your inpute features (x) should be formated as {feature_0: value_0, feature_1, value_1, .., feature_n: value_n}. Where each feature is a string and each value is a bool, an integer or a float. Your target value should be a single float (y)

If you attend to use learn_many or predict_many then your features (X) should be a pandas dataframe (of floats, bools or integers) and you target (y) values a pandas series.

If you share a sample of your training data (5 data points) and test data, I'll do my best to help you to fit the river API.

@raul-parada
Copy link
Author

Thanks! Below X and y samples

import pandas as pd

data = {
    'latitude(m)': [41.391846, 41.391058, 41.391133, 41.389804, 41.389701],
    'longitude(m)': [2.162545, 2.163467, 2.163620, 2.166248, 2.165495]
}

X = pd.DataFrame(data, index=[234220, 234221, 234222, 234223, 234224])

y = pd.Series({
    234220: 14215279993461140785,
    234221: 14215279993622409866,
    234222: 14215279993718637872,
    234223: 14215280005449595738,
    234224: 14215280005025331239
})

I got this error: AttributeError: 'DataFrame' object has no attribute 'to_frame'

Appreciate your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants