Comparison of values and classification

3 ビュー (過去 30 日間)
Alexander
Alexander 2023 年 4 月 25 日
コメント済み: Alexander 2023 年 4 月 25 日
I have a excel spreadsheet with 14 Columns and 1084 rows. I have to comapre the data in each row to eachother. Would it also be possible to do any of these and if so how would i do it.
Mdl = fitcdiscr(Tbl,ResponseVarName)
Mdl = fitcnb(Tbl,ResponseVarName)
Mdl = fitcknn(Tbl,ResponseVarName)
Mdl = fitctree(Tbl,ResponseVarName)
Im not sure how to go about doing this and i am very lost so any help is appreciated.

回答 (1 件)

Kevin Holly
Kevin Holly 2023 年 4 月 25 日
Generate table:
matrix = rand(1084,4); % making 4 columns because I don't feel like creating 14 column names
Tbl = array2table(matrix);
Tbl.Properties.VariableNames = {'Example','VariableName','Thisone','Anotherone'}
Tbl = 1084×4 table
Example VariableName Thisone Anotherone _________ ____________ ________ __________ 0.008419 0.94549 0.57949 0.26174 0.88127 0.91574 0.85093 0.41558 0.90647 0.93937 0.96487 0.0085924 0.70741 0.35517 0.64649 0.10701 0.046089 0.79723 0.0688 0.26858 0.51422 0.28245 0.37771 0.72541 0.35115 0.094531 0.59553 0.311 0.39849 0.97084 0.027262 0.047593 0.97249 0.91244 0.48412 0.98297 0.4826 0.76309 0.94302 0.78793 0.79139 0.76139 0.3027 0.19743 0.6975 0.275 0.4691 0.57933 0.47841 0.33515 0.53218 0.72264 0.0011759 0.85494 0.30534 0.28503 0.085123 0.96305 0.44785 0.17248 0.56161 0.88413 0.91003 0.042377
Note, you could just read your table from the Excel spreadsheet directly using readtable function.
Chose Response Variable
ResponseVarName = 'Thisone';
Mdl = fitcknn(Tbl,ResponseVarName)
Mdl =
ClassificationKNN PredictorNames: {'Example' 'VariableName' 'Anotherone'} ResponseName: 'Thisone' CategoricalPredictors: [] ClassNames: [7.0290e-04 7.2041e-04 0.0015 0.0022 0.0039 0.0059 0.0063 0.0067 0.0074 0.0106 0.0112 0.0114 0.0123 0.0130 0.0155 0.0157 0.0169 0.0177 0.0183 0.0210 0.0212 0.0214 … ] ScoreTransform: 'none' NumObservations: 1084 Distance: 'euclidean' NumNeighbors: 1 Properties, Methods
  1 件のコメント
Alexander
Alexander 2023 年 4 月 25 日
Im getting an error that says not enough input arguments

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by