دستهبندی گلهای Iris
از اندازههای گل، گونه را پیشبینی کن.
۱۰۰ دقیقه · ۲۲۰ XP · Python · Scikit-learn · Evaluation
هدف و راهنمای انجام
جداسازی آموزش و ارزیابی و سنجش تعمیم مدل
ورودی
train: لیست سطرهای دارای species؛ test: لیست ویژگیهای بدون هدف؛ features: ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']؛ target: species
خروجی
result.json شامل predictions با یک مقدار بهازای هر سطر test؛ عدد برای رگرسیون و برچسب موجود در train برای دستهبندی.
- request.json شامل train دارای برچسب و test بدون برچسب است؛ فایل CSV محلی برای مطالعه است و در ارزیابی به محیط ارسال نمیشود.
- train را به ویژگیها و target جدا کن؛ داده ارزیابی بیرونی را هرگز برای fit استفاده نکن.
- برای تمرین، با train_test_split و random_state=42 بخشی از train را نگه دار و مدل را با MAE یا accuracy/F1 بسنج.
- مدل یا Pipeline را فقط روی داده آموزش fit کن؛ سپس برای تمام سطرهای test پیشبینی کن.
- predictions را به ترتیب test در result.json ذخیره کن؛ امتیاز نهایی را داور روی برچسبهای خارج محیط محاسبه میکند.
تقسیم داده را داور هم مستقل انجام میدهد؛ موفقیت صرف اجرای برنامه یا metric چاپشده کافی نیست. random_state=42 را برای بازتولیدپذیری تنظیم کن.
مثال ورودی و خروجی
{
"input": {
"train": [
{
"sepal_length": 5.5,
"sepal_width": 2.5,
"petal_length": 4,
"petal_width": 1.3,
"species": "Iris-versicolor"
},
{
"sepal_length": 5.6,
"sepal_width": 2.8,
"petal_length": 4.9,
"petal_width": 2,
"species": "Iris-virginica"
},
{
"sepal_length": 5.1,
"sepal_width": 3.4,
"petal_length": 1.5,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 4.4,
"sepal_width": 3.2,
"petal_length": 1.3,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 5.5,
"sepal_width": 2.3,
"petal_length": 4,
"petal_width": 1.3,
"species": "Iris-versicolor"
},
{
"sepal_length": 6.2,
"sepal_width": 3.4,
"petal_length": 5.4,
"petal_width": 2.3,
"species": "Iris-virginica"
},
{
"sepal_length": 6.1,
"sepal_width": 2.8,
"petal_length": 4,
"petal_width": 1.3,
"species": "Iris-versicolor"
},
{
"sepal_length": 5,
"sepal_width": 3.6,
"petal_length": 1.4,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 7.2,
"sepal_width": 3.6,
"petal_length": 6.1,
"petal_width": 2.5,
"species": "Iris-virginica"
},
{
"sepal_length": 6.1,
"sepal_width": 2.9,
"petal_length": 4.7,
"petal_width": 1.4,
"species": "Iris-versicolor"
},
{
"sepal_length": 5,
"sepal_width": 3.5,
"petal_length": 1.6,
"petal_width": 0.6,
"species": "Iris-setosa"
},
{
"sepal_length": 5.3,
"sepal_width": 3.7,
"petal_length": 1.5,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 5.6,
"sepal_width": 2.9,
"petal_length": 3.6,
"petal_width": 1.3,
"species": "Iris-versicolor"
},
{
"sepal_length": 4.5,
"sepal_width": 2.3,
"petal_length": 1.3,
"petal_width": 0.3,
"species": "Iris-setosa"
},
{
"sepal_length": 5.4,
"sepal_width": 3.4,
"petal_length": 1.7,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 6.3,
"sepal_width": 3.3,
"petal_length": 6,
"petal_width": 2.5,
"species": "Iris-virginica"
},
{
"sepal_length": 4.9,
"sepal_width": 3,
"petal_length": 1.4,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 6.9,
"sepal_width": 3.1,
"petal_length": 5.1,
"petal_width": 2.3,
"species": "Iris-virginica"
},
{
"sepal_length": 5.9,
"sepal_width": 3,
"petal_length": 4.2,
"petal_width": 1.5,
"species": "Iris-versicolor"
},
{
"sepal_length": 5.1,
"sepal_width": 3.8,
"petal_length": 1.5,
"petal_width": 0.3,
"species": "Iris-setosa"
},
{
"sepal_length": 5.5,
"sepal_width": 3.5,
"petal_length": 1.3,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 4.9,
"sepal_width": 3.1,
"petal_length": 1.5,
"petal_width": 0.1,
"species": "Iris-setosa"
},
{
"sepal_length": 6.9,
"sepal_width": 3.1,
"petal_length": 4.9,
"petal_width": 1.5,
"species": "Iris-versicolor"
},
{
"sepal_length": 6.4,
"sepal_width": 3.1,
"petal_length": 5.5,
"petal_width": 1.8,
"species": "Iris-virginica"
},
{
"sepal_length": 6.1,
"sepal_width": 2.6,
"petal_length": 5.6,
"petal_width": 1.4,
"species": "Iris-virginica"
},
{
"sepal_length": 7.7,
"sepal_width": 2.6,
"petal_length": 6.9,
"petal_width": 2.3,
"species": "Iris-virginica"
},
{
"sepal_length": 5.4,
"sepal_width": 3,
"petal_length": 4.5,
"petal_width": 1.5,
"species": "Iris-versicolor"
},
{
"sepal_length": 6.2,
"sepal_width": 2.8,
"petal_length": 4.8,
"petal_width": 1.8,
"species": "Iris-virginica"
},
{
"sepal_length": 5.4,
"sepal_width": 3.9,
"petal_length": 1.7,
"petal_width": 0.4,
"species": "Iris-setosa"
},
{
"sepal_length": 4.6,
"sepal_width": 3.4,
"petal_length": 1.4,
"petal_width": 0.3,
"species": "Iris-setosa"
},
{
"sepal_length": 5.8,
"sepal_width": 2.6,
"petal_length": 4,
"petal_width": 1.2,
"species": "Iris-versicolor"
},
{
"sepal_length": 4.8,
"sepal_width": 3.4,
"petal_length": 1.6,
"petal_width": 0.2,
"species": "Iris-setosa"
},
{
"sepal_length": 7.9,
"sepal_width": 3.8,
"petal_length": 6.4,
"petal_width": 2,
"species": "Iris-virginica"
},
{
"sepal_length": 6,
"sepal_width": 2.2,
"petal_length": 5,
"petal_width": 1.5,
"species": "Iris-virginica"
},
{
"sepal_length": 5.7,
"sepal_width": 2.6,
"petal_length": 3.5,
"petal_width": 1,
"species": "Iris-versicolor"
},
{
"sepal_length": 5.8,
"sepal_width": 2.7,
"petal_length": 3.9,
"petal_width": 1.2,
"species": "Iris-versicolor"
},
{
"sepal_length": 4.3,
"sepal_width": 3,
"petal_length": 1.1,
"petal_width": 0.1,
"species": "Iris-setosa"
},
{
"sepal_length": 5,
"sepal_width": 2,
"petal_length": 3.5,
"petal_width": 1,
"species": "Iris-versicolor"
},
{
"sepal_length": 7.7,
"sepal_width": 2.8,
"petal_length": 6.7,
"petal_width": 2,
"species": "Iris-virginica"
},
{
"sepal_length": 4.4,
"sepal_width": 3,
"petal_length": 1.3,
"petal_width": 0.2,
"species": "Iris-setosa"
}
],
"test": [
{
"sepal_length": 6.7,
"sepal_width": 3.1,
"petal_length": 4.4,
"petal_width": 1.4
},
{
"sepal_length": 5.2,
"sepal_width": 3.5,
"petal_length": 1.5,
"petal_width": 0.2
},
{
"sepal_length": 5.6,
"sepal_width": 2.5,
"petal_length": 3.9,
"petal_width": 1.1
}
],
"features": [
"sepal_length",
"sepal_width",
"petal_length",
"petal_width"
],
"target": "species"
},
"output": {
"predictions": [
"برچسب یا عدد برای هر سطر test"
]
}
}معیارهای موفقیت
- accuracy و macro-F1 حداقل 0.85
- شکل و تعداد و نوع پیشبینیها مطابق ورودی
- ارزیابی روی دو تقسیم تصادفی مستقل؛ برچسب test به کد ارسال نمیشود.
کتابخانهها: pandas, scikit-learn, numpy
منبع و وضعیت دیتاستها
iris.csv · CC BY 4.0 · Fisher (1936), Iris, UCI, doi:10.24432/C56C76.
https://archive.ics.uci.edu/static/public/53/iris.zip
نسخه محلی همراه پروژه؛ ۱۵۰ ردیف. هنگام اجرا دانلود خارجی لازم نیست.
