You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Data-Science-For-Beginners/translations/te/5-Data-Science-In-Cloud/19-Azure/notebook.ipynb

325 lines
12 KiB

{
"cells": [
{
"cell_type": "markdown",
"source": [
"# క్లౌడ్‌లో డేటా సైన్స్: \"Azure ML SDK\" విధానం\n",
"\n",
"## పరిచయం\n",
"\n",
"ఈ నోట్‌బుక్‌లో, Azure ML SDK ఉపయోగించి మోడల్‌ను శిక్షణ ఇవ్వడం, డిప్లాయ్ చేయడం మరియు వినియోగించడం ఎలా చేయాలో నేర్చుకుంటాము.\n",
"\n",
"ముందస్తు అవసరాలు:\n",
"1. మీరు ఒక Azure ML వర్క్‌స్పేస్ సృష్టించారు.\n",
"2. మీరు [హార్ట్ ఫెయిల్యూర్ డేటాసెట్](https://www.kaggle.com/andrewmvd/heart-failure-clinical-data) ను Azure ML లో లోడ్ చేశారు.\n",
"3. మీరు ఈ నోట్‌బుక్‌ను Azure ML స్టూడియోలో అప్లోడ్ చేశారు.\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 మెషీన్ లెర్నింగ్ 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": [
"## Initialize Workspace\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": [
"## Data\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": [
"## ఉత్తమ మోడల్‌ను సేవ్ చేయండి\n"
],
"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<!-- CO-OP TRANSLATOR DISCLAIMER START -->\n**అస్పష్టత**: \nఈ పత్రాన్ని AI అనువాద సేవ [Co-op Translator](https://github.com/Azure/co-op-translator) ఉపయోగించి అనువదించబడింది. మేము ఖచ్చితత్వానికి ప్రయత్నించినప్పటికీ, ఆటోమేటెడ్ అనువాదాల్లో పొరపాట్లు లేదా తప్పిదాలు ఉండవచ్చు. అసలు పత్రం దాని స్వదేశీ భాషలోనే అధికారిక మూలంగా పరిగణించాలి. ముఖ్యమైన సమాచారానికి, ప్రొఫెషనల్ మానవ అనువాదం సిఫార్సు చేయబడుతుంది. ఈ అనువాదం వాడకంలో ఏర్పడిన ఏవైనా అపార్థాలు లేదా తప్పుదారితీసే అర్థాలు కోసం మేము బాధ్యత వహించము.\n<!-- CO-OP TRANSLATOR DISCLAIMER END -->\n"
]
}
],
"metadata": {
"orig_nbformat": 4,
"language_info": {
"name": "python"
},
"coopTranslator": {
"original_hash": "af42669556d5dc19fc4cc3866f7d2597",
"translation_date": "2025-12-19T17:09:39+00:00",
"source_file": "5-Data-Science-In-Cloud/19-Azure/notebook.ipynb",
"language_code": "te"
}
},
"nbformat": 4,
"nbformat_minor": 2
}