Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Multi Variable Categorical Regression

조회 수: 1 (최근 30일)
Connor Stepkoski
Connor Stepkoski 2020년 4월 20일
마감: MATLAB Answer Bot 2021년 8월 20일
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
the cyclist
the cyclist 2020년 4월 20일
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)

답변 (1개)

the cyclist
the cyclist 2020년 4월 20일
편집: the cyclist 2020년 4월 20일
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
the cyclist
the cyclist 2020년 4월 20일
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