كود generate random points & classification

السلام عليكم

سجلت بالنتى لحاجتي القصوى بحل assignment

السؤال كالتالي مع محاولة اجابتي :

The purpose of the assignment is to create data belonging to two different classes according to the
specifications below. The figure above depicts two classes: red points belong to class 1; blue points
belong to class 0. The generated data should be of the form [(x,y),class]. The points are generated
randomly. However, x should always be between -1 and 4; y should be between -4 and 4. You should
generate 100 points for each class: 100 points for class 1 and 100 points for class 2. The data is stored
in a file.

  1. Create the two-class data so that the two classes are linearly separable. Plot the data to show
    result graphically.
  2. Create the two-class data so that the two classes are not linearly separable: typically, you will
    have 20% of the generated data (for each class) violating the linear separability. Plot the data
    to show result graphically.

What is required:

I. Generate the data for the two classes according to 1. and 2.
II. Plot the data (generated in 1. and 2.)
III. Explain how the data was generated

حــلي :

x=randint(200,1,[-1,4]);
y=randint(200,1,[-4,4]);
class=randsrc(200,1,[1 0,0.5 0.5]);
x=x';
y=y';
class=class';
axis([-1 4 -4 4]);
for i=1:200
    if class(i)==1
        hold on
        plot(x(1,i),y(1,i),'d','MarkerFaceColor','g');
    else
        hold on
        plot(x(1,i),y(1,i),'s','MarkerFaceColor','r');
    end
end

بليييييز ساااعدووني اليووم ضروووري

شكـــرا على عـــدم المســاعدة !!

نرجو توضيح المشكلة حتى نقدر نساعدك ؟؟
يعنى ما هو المطلوب ؟؟

[CENTER]وعليكم السلام

العضو الكريم

ان تنتظر المساعدة الفورية في يوم واحد ليس متوفرا دائما

بالاضافة كما قال الاخ المدير اني لم افهم المطلوب، خصوصا ان البرنامج يشتغل

وضح المطلوب+اصبر قليلا=تجد الاجابة
ان شاء الله
[/center]

عفوا منكم

بس لاني ماحصلت رد مو شرط من يومها

وسبب استعجالي لازم اسلم الحل يوم الاثنين بعد بكرة !!

صحيح اشتغل بس مو مثل المطلوب كما في السؤال

لاجل كذا ارفقت السؤال

المفروض تظهر مية نقطة من كلاسين غير منفصلة وبعدين اجعلها منفصلة

اتمنى وضحت لكم

وعذرا مرة أخرى !!

[CENTER]في الحقيقة لست من اهل الاختصاص
لكني ارى ان ال data غير منفصلة

فقط لانها من نوع integer لايظهر انفصالها

فلو كتبنا

clear all
clc
close all

x=randint(100,1,[-1,4]);
y=randint(100,1,[-4,4]);
class = randi(2, [100 1]);    
gscatter(x, y, class, 'rb', 'xo')

ستكون النتيجة

لاننا نحن من اردنا ارقام صحيحة عشوائية

لكن لو كنا نريد ارقام حقيقية عشوائية
نكتب

clear all
clc
close all


x= -1 + 5.*rand(100,1);
y= -4 + 8.*rand(100,1);
class = randi(2, [100 1]);    
gscatter(x, y, class, 'rb', 'xo')

والنتيجة

فهل هذا ما تريدينه ؟

والفصل بينهما ليس بالامر الهين

[/center]