Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Multi Variable Categorical Regression

1 Ansicht (letzte 30 Tage)
Connor Stepkoski
Connor Stepkoski am 20 Apr. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I'm attempting to build a predictor for attendence at baseball games. Based on 5 variables, 4 of which are categorical. I've tried a multitude of different things and am having no luck. Does anyone have any advice/ideas on how I should go about this?
I've attatched the data I've compsed.
  1 Kommentar
the cyclist
the cyclist am 20 Apr. 2020
It would be helpful to know ...
  • what sorts of things you tried (e.g. which MATLAB functions?)
  • what does "having no luck" mean? Do you have code that crashes? Code that runs, but doesn't result in a "good" model?
  • whether or not you have the Statistics and Machine Learning Toolbox
  • a little bit of info on your level of experience with MATLAB
  • a little bit of info on your level of experience using predictive models (either in MATLAB or other language)

Antworten (1)

the cyclist
the cyclist am 20 Apr. 2020
Bearbeitet: the cyclist am 20 Apr. 2020
The following code fits a binary regression tree to your data:
baseballData = readtable('BaseballData.xlsx'); % Load the data into a table
baseballData.Date = []; % Remove the date, which presumably should not be used for prediction
tree = fitrtree(baseballData,'Attendence'); % Fit the model
You can then predict attendance for a particular set of parameters. Here, I predict attendance for the first row of the table:
predict(tree,baseballData(1,:))
You could also do a simple linear model using
linear = fitlm(baseballData)
Note that for both of these models, the syntax is particularly simple because your response variable happens to be the last variable in the table (which is the default assumption by MATLAB), and because the functions are able to figure out automatically which variables are categorical.
  1 Kommentar
the cyclist
the cyclist am 20 Apr. 2020
Before running this, remove the rows in the table (e.g. row 82) that just has the year and no other data.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by