{ "cells": [ { "cell_type": "markdown", "source": [ "# ক্লাউডে ডেটা সায়েন্স: \"Azure ML SDK\" পদ্ধতি\n", "\n", "## ভূমিকা\n", "\n", "এই নোটবুকে, আমরা শিখব কীভাবে Azure ML SDK ব্যবহার করে একটি মডেল প্রশিক্ষণ, স্থাপন এবং ব্যবহার করা যায়।\n", "\n", "প্রয়োজনীয়তা:\n", "1. আপনি একটি Azure ML ওয়ার্কস্পেস তৈরি করেছেন।\n", "2. আপনি [Heart Failure dataset](https://www.kaggle.com/andrewmvd/heart-failure-clinical-data) Azure ML-এ লোড করেছেন।\n", "3. আপনি এই নোটবুকটি Azure ML Studio-তে আপলোড করেছেন।\n", "\n", "পরবর্তী ধাপগুলো:\n", "\n", "1. একটি বিদ্যমান ওয়ার্কস্পেসে একটি এক্সপেরিমেন্ট তৈরি করুন।\n", "2. একটি কম্পিউট ক্লাস্টার তৈরি করুন।\n", "3. ডেটাসেট লোড করুন।\n", "4. AutoMLConfig ব্যবহার করে AutoML কনফিগার করুন।\n", "5. AutoML এক্সপেরিমেন্ট চালান।\n", "6. ফলাফল বিশ্লেষণ করুন এবং সেরা মডেলটি পান।\n", "7. সেরা মডেলটি রেজিস্টার করুন।\n", "8. সেরা মডেলটি স্থাপন করুন।\n", "9. এন্ডপয়েন্ট ব্যবহার করুন।\n", "\n", "## Azure Machine Learning SDK-সম্পর্কিত ইমপোর্টসমূহ\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "from azureml.core import Workspace, Experiment\n", "from azureml.core.compute import AmlCompute\n", "from azureml.train.automl import AutoMLConfig\n", "from azureml.widgets import RunDetails\n", "from azureml.core.model import InferenceConfig, Model\n", "from azureml.core.webservice import AciWebservice" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## ওয়ার্কস্পেস আরম্ভ করুন \n", "সংরক্ষিত কনফিগারেশন থেকে একটি ওয়ার্কস্পেস অবজেক্ট আরম্ভ করুন। নিশ্চিত করুন যে কনফিগারেশন ফাইলটি .\\config.json এ উপস্থিত আছে। \n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "ws = Workspace.from_config()\n", "print(ws.name, ws.resource_group, ws.location, ws.subscription_id, sep = '\\n')" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## একটি Azure ML পরীক্ষা তৈরি করুন\n", "\n", "চলুন আমরা 'aml-experiment' নামে একটি পরীক্ষা তৈরি করি সেই কর্মক্ষেত্রে যা আমরা ঠিক এখনই আরম্ভ করেছি।\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "experiment_name = 'aml-experiment'\n", "experiment = Experiment(ws, experiment_name)\n", "experiment" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## একটি কম্পিউট ক্লাস্টার তৈরি করুন \n", "আপনার AutoML রান-এর জন্য একটি [কম্পিউট টার্গেট](https://docs.microsoft.com/azure/machine-learning/concept-azure-machine-learning-architecture#compute-target) তৈরি করতে হবে। \n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "aml_name = \"heart-f-cluster\"\n", "try:\n", " aml_compute = AmlCompute(ws, aml_name)\n", " print('Found existing AML compute context.')\n", "except:\n", " print('Creating new AML compute context.')\n", " aml_config = AmlCompute.provisioning_configuration(vm_size = \"Standard_D2_v2\", min_nodes=1, max_nodes=3)\n", " aml_compute = AmlCompute.create(ws, name = aml_name, provisioning_configuration = aml_config)\n", " aml_compute.wait_for_completion(show_output = True)\n", "\n", "cts = ws.compute_targets\n", "compute_target = cts[aml_name]" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## ডেটা\n", "নিশ্চিত করুন যে আপনি ডেটাসেটটি Azure ML-এ আপলোড করেছেন এবং যে কীটি ডেটাসেটের নামের সাথে একই।\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "key = 'heart-failure-records'\n", "dataset = ws.datasets[key]\n", "df = dataset.to_pandas_dataframe()\n", "df.describe()" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## অটোএমএল কনফিগারেশন\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "automl_settings = {\n", " \"experiment_timeout_minutes\": 20,\n", " \"max_concurrent_iterations\": 3,\n", " \"primary_metric\" : 'AUC_weighted'\n", "}\n", "\n", "automl_config = AutoMLConfig(compute_target=compute_target,\n", " task = \"classification\",\n", " training_data=dataset,\n", " label_column_name=\"DEATH_EVENT\",\n", " enable_early_stopping= True,\n", " featurization= 'auto',\n", " debug_log = \"automl_errors.log\",\n", " **automl_settings\n", " )" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## অটোএমএল রান\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "remote_run = experiment.submit(automl_config)" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "RunDetails(remote_run).show()" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "best_run, fitted_model = remote_run.get_output()" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "best_run.get_properties()" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "model_name = best_run.properties['model_name']\n", "script_file_name = 'inference/score.py'\n", "best_run.download_file('outputs/scoring_file_v_1_0_0.py', 'inference/score.py')\n", "description = \"aml heart failure project sdk\"\n", "model = best_run.register_model(model_name = model_name,\n", " description = description,\n", " tags = None)" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## সেরা মডেলটি ডিপ্লয় করুন\n", "\n", "সেরা মডেলটি ডিপ্লয় করতে নিচের কোডটি চালান। আপনি Azure ML পোর্টালে ডিপ্লয়মেন্টের অবস্থা দেখতে পারবেন। এই ধাপটি সম্পন্ন হতে কয়েক মিনিট সময় লাগতে পারে।\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "inference_config = InferenceConfig(entry_script=script_file_name, environment=best_run.get_environment())\n", "\n", "aciconfig = AciWebservice.deploy_configuration(cpu_cores = 1,\n", " memory_gb = 1,\n", " tags = {'type': \"automl-heart-failure-prediction\"},\n", " description = 'Sample service for AutoML Heart Failure Prediction')\n", "\n", "aci_service_name = 'automl-hf-sdk'\n", "aci_service = Model.deploy(ws, aci_service_name, [model], inference_config, aciconfig)\n", "aci_service.wait_for_deployment(True)\n", "print(aci_service.state)" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "source": [ "## এন্ডপয়েন্ট ব্যবহার করুন\n", "আপনি নিম্নলিখিত ইনপুট নমুনায় ইনপুট যোগ করতে পারেন।\n" ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "data = {\n", " \"data\":\n", " [\n", " {\n", " 'age': \"60\",\n", " 'anaemia': \"false\",\n", " 'creatinine_phosphokinase': \"500\",\n", " 'diabetes': \"false\",\n", " 'ejection_fraction': \"38\",\n", " 'high_blood_pressure': \"false\",\n", " 'platelets': \"260000\",\n", " 'serum_creatinine': \"1.40\",\n", " 'serum_sodium': \"137\",\n", " 'sex': \"false\",\n", " 'smoking': \"false\",\n", " 'time': \"130\",\n", " },\n", " ],\n", "}\n", "\n", "test_sample = str.encode(json.dumps(data))" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "response = aci_service.run(input_data=test_sample)\n", "response" ], "outputs": [], "metadata": {} }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n---\n\n**অস্বীকৃতি**: \nএই নথিটি AI অনুবাদ পরিষেবা [Co-op Translator](https://github.com/Azure/co-op-translator) ব্যবহার করে অনুবাদ করা হয়েছে। আমরা যথাসাধ্য সঠিকতা নিশ্চিত করার চেষ্টা করি, তবে অনুগ্রহ করে মনে রাখবেন যে স্বয়ংক্রিয় অনুবাদে ত্রুটি বা অসঙ্গতি থাকতে পারে। মূল ভাষায় থাকা নথিটিকে প্রামাণিক উৎস হিসেবে বিবেচনা করা উচিত। গুরুত্বপূর্ণ তথ্যের জন্য, পেশাদার মানব অনুবাদ সুপারিশ করা হয়। এই অনুবাদ ব্যবহারের ফলে কোনো ভুল বোঝাবুঝি বা ভুল ব্যাখ্যা হলে আমরা দায়বদ্ধ থাকব না।\n" ] } ], "metadata": { "orig_nbformat": 4, "language_info": { "name": "python" }, "coopTranslator": { "original_hash": "af42669556d5dc19fc4cc3866f7d2597", "translation_date": "2025-09-01T20:03:08+00:00", "source_file": "5-Data-Science-In-Cloud/19-Azure/notebook.ipynb", "language_code": "bn" } }, "nbformat": 4, "nbformat_minor": 2 }