0
$\begingroup$

Neural Networks seem so complex these days. Can anyone please suggest a simple structure (i.e. code) for training numeric vector data: examples of 24 numeric inputs to produce 1 (integer) numeric output. Any help would be much appreciated, thanks!

$\endgroup$
  • $\begingroup$ P.S. I've been trying to use NetChain[] but unclear to me $\endgroup$ – Putnik11 Oct 17 '19 at 7:29
  • $\begingroup$ Welcome to Mathematica SE. Can you provide some code that you tried, so that specific hints can be given. The problem is not totally clear to me. $\endgroup$ – mgamer Oct 17 '19 at 7:57
  • $\begingroup$ Have a read of this documentation: reference.wolfram.com/language/tutorial/… particularly this part: reference.wolfram.com/language/tutorial/… $\endgroup$ – Carl Lange Oct 17 '19 at 9:22
  • $\begingroup$ Use Decision Trees or Naive Bayesian Classifiers. E.g. Classify[___,Method->"NaiveBayes"]. $\endgroup$ – Anton Antonov Oct 17 '19 at 10:53
  • $\begingroup$ This question as written is too vague. It requires some indication of "typical" input and expected output. Along a minimal concrete example. $\endgroup$ – Daniel Lichtblau Oct 17 '19 at 22:43
2
$\begingroup$

The following code (1) takes example data -- a numerical matrix, (2) categorizes the last column, (3) picks 24 rows/vectors, (4) builds a classifier, and (5) tests the classifier over the rest of data's rows/vectors.

SeedRandom[323]

(* Get example data. *)
data = RandomSample[ExampleData[{"Statistics", "BostonHomes"}]];

Dimensions[data]

(* {506, 14} *)

(* Data summary. *)
ResourceFunction["RecordsSummary"][data]

(* Pick 24 vectors. *)
tind = 24;

(* Categorize the last column in order to make integer labels. *)
data[[All, -1]] = 
  Map[Piecewise[{{1, # < 17}, {2, 17 <= # < 22}, {3, 
       22 <= # < 25}, {4, # >= 50}}] &, data[[All, -1]]];

(* Train a Naive Bayesian Classifier. *)
cf = 
 Classify[data[[1 ;; tind, 1 ;; -2]] -> data[[1 ;; tind, -1]], 
  Method -> "NaiveBayes"]

(* Evaluate classification results. *)
Tally[
 MapThread[
  Equal, {cf[data[[tind + 1 ;; -1, 1 ;; -2]]], 
   data[[tind + 1 ;; -1, -1]]}]]

(* {{False, 215}, {True, 267}} *)
$\endgroup$
  • $\begingroup$ Thank you very much Anton! Unfortunately I had some very difficult circumstances, hence the very late reply. $\endgroup$ – Putnik11 Nov 19 '19 at 5:06
  • $\begingroup$ @Putnik11 No problem. Good luck! $\endgroup$ – Anton Antonov Nov 19 '19 at 14:59

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