aboutsummaryrefslogtreecommitdiff
path: root/R_LogR/mlclass-ex2/plotData.m
diff options
context:
space:
mode:
authorleshe4ka46 <alex9102naid1@ya.ru>2025-12-13 19:41:40 +0300
committerleshe4ka46 <alex9102naid1@ya.ru>2025-12-13 19:41:40 +0300
commit175ac10904d0f31c3ffeeeed507c8914f13d0b15 (patch)
tree671c68a03354c5084470c5cfcfd4fe87aae2aff8 /R_LogR/mlclass-ex2/plotData.m
parent72b4edeadeafc9c54b3db9b0961a45da3d07b77c (diff)
linr, logr
Diffstat (limited to 'R_LogR/mlclass-ex2/plotData.m')
-rw-r--r--R_LogR/mlclass-ex2/plotData.m33
1 files changed, 33 insertions, 0 deletions
diff --git a/R_LogR/mlclass-ex2/plotData.m b/R_LogR/mlclass-ex2/plotData.m
new file mode 100644
index 0000000..2eda757
--- /dev/null
+++ b/R_LogR/mlclass-ex2/plotData.m
@@ -0,0 +1,33 @@
+function plotData(X, y)
+%PLOTDATA Plots the data points X and y into a new figure
+% PLOTDATA(x,y) plots the data points with + for the positive examples
+% and o for the negative examples. X is assumed to be a Mx2 matrix.
+
+% Create New Figure
+figure; hold on;
+
+% ====================== YOUR CODE HERE ======================
+% Instructions: Plot the positive and negative examples on a
+% 2D plot, using the option 'k+' for the positive
+% examples and 'ko' for the negative examples.
+%
+
+#positive_vals = find(y == 1);
+#negative_vals = find(y == 0);
+
+
+#plot(X(positive_vals, 1), X(positive_vals, 2), 'k+', 'MarkerSize', 7);
+#plot(X(negative_vals, 1), X(negative_vals, 2), 'ko', 'MarkerSize', 7);
+
+
+pos = find(y==1); neg = find(y == 0);
+plot(X(pos, 1), X(pos, 2), 'k+', 'MarkerSize', 7);
+plot(X(neg, 1), X(neg, 2), 'ko', 'MarkerSize', 7);
+
+% =========================================================================
+
+
+
+hold off;
+
+end