Spaces:
Sleeping
Sleeping
File size: 47,521 Bytes
484b456 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from dotenv import load_dotenv\n",
"import os\n",
"load_dotenv()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"api_key = os.environ.get('GOOGLE_API_KEY')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"api_key loaded successfully\n"
]
}
],
"source": [
"if not api_key:\n",
" raise ValueError('GOOGLE_API_KEY environment variable not found')\n",
"print(\"api_key loaded successfully\")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"from llama_index.readers.web import SimpleWebPageReader\n",
"from llama_index.core import VectorStoreIndex\n",
"from llama_index.embeddings.gemini import GeminiEmbedding\n",
"from llama_index.core import StorageContext\n",
"from llama_index.core import load_index_from_storage\n",
"import google.generativeai as genai\n",
"from llama_index.llms.gemini import Gemini\n",
"from IPython.display import Markdown\n",
"from IPython.display import display"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"genai.configure(api_key=api_key)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"models/chat-bison-001\n",
"models/text-bison-001\n",
"models/embedding-gecko-001\n",
"models/gemini-1.0-pro-latest\n",
"models/gemini-1.0-pro\n",
"models/gemini-pro\n",
"models/gemini-1.0-pro-001\n",
"models/gemini-1.0-pro-vision-latest\n",
"models/gemini-pro-vision\n",
"models/gemini-1.5-pro-latest\n",
"models/gemini-1.5-pro-001\n",
"models/gemini-1.5-pro-002\n",
"models/gemini-1.5-pro\n",
"models/gemini-1.5-pro-exp-0801\n",
"models/gemini-1.5-pro-exp-0827\n",
"models/gemini-1.5-flash-latest\n",
"models/gemini-1.5-flash-001\n",
"models/gemini-1.5-flash-001-tuning\n",
"models/gemini-1.5-flash\n",
"models/gemini-1.5-flash-exp-0827\n",
"models/gemini-1.5-flash-002\n",
"models/gemini-1.5-flash-8b\n",
"models/gemini-1.5-flash-8b-001\n",
"models/gemini-1.5-flash-8b-latest\n",
"models/gemini-1.5-flash-8b-exp-0827\n",
"models/gemini-1.5-flash-8b-exp-0924\n",
"models/gemini-2.0-flash-exp\n",
"models/gemini-exp-1206\n",
"models/gemini-exp-1121\n",
"models/gemini-exp-1114\n",
"models/gemini-2.0-flash-thinking-exp-01-21\n",
"models/gemini-2.0-flash-thinking-exp\n",
"models/gemini-2.0-flash-thinking-exp-1219\n",
"models/learnlm-1.5-pro-experimental\n",
"models/embedding-001\n",
"models/text-embedding-004\n",
"models/aqa\n"
]
}
],
"source": [
"for models in genai.list_models():\n",
" print(models.name)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"models/gemini-1.0-pro-latest\n",
"models/gemini-1.0-pro\n",
"models/gemini-pro\n",
"models/gemini-1.0-pro-001\n",
"models/gemini-1.0-pro-vision-latest\n",
"models/gemini-pro-vision\n",
"models/gemini-1.5-pro-latest\n",
"models/gemini-1.5-pro-001\n",
"models/gemini-1.5-pro-002\n",
"models/gemini-1.5-pro\n",
"models/gemini-1.5-pro-exp-0801\n",
"models/gemini-1.5-pro-exp-0827\n",
"models/gemini-1.5-flash-latest\n",
"models/gemini-1.5-flash-001\n",
"models/gemini-1.5-flash-001-tuning\n",
"models/gemini-1.5-flash\n",
"models/gemini-1.5-flash-exp-0827\n",
"models/gemini-1.5-flash-002\n",
"models/gemini-1.5-flash-8b\n",
"models/gemini-1.5-flash-8b-001\n",
"models/gemini-1.5-flash-8b-latest\n",
"models/gemini-1.5-flash-8b-exp-0827\n",
"models/gemini-1.5-flash-8b-exp-0924\n",
"models/gemini-2.0-flash-exp\n",
"models/gemini-exp-1206\n",
"models/gemini-exp-1121\n",
"models/gemini-exp-1114\n",
"models/gemini-2.0-flash-thinking-exp-01-21\n",
"models/gemini-2.0-flash-thinking-exp\n",
"models/gemini-2.0-flash-thinking-exp-1219\n",
"models/learnlm-1.5-pro-experimental\n"
]
}
],
"source": [
"for models in genai.list_models():\n",
" if 'generateContent' in models.supported_generation_methods:\n",
" print(models.name)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"documents = SimpleWebPageReader(html_to_text=True)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SimpleWebPageReader(is_remote=True, html_to_text=True)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"documents"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"data = documents.load_data(urls = [\"https://www.javatpoint.com/machine-learning\"])"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[](/)\n",
"\n",
"__\n",
"\n",
"__\n",
"\n",
"Tutorials\n",
"\n",
"× \n",
"\n",
"### Python\n",
"\n",
"[Python](/python-tutorial) [Django](/django-tutorial) [Numpy](/numpy-tutorial)\n",
"[Pandas](/python-pandas) [Tkinter](/python-tkinter) [Pytorch](/pytorch)\n",
"[Flask](/flask-tutorial) [OpenCV](/opencv)\n",
"\n",
"### AI, ML and Data Science\n",
"\n",
"[Artificial Intelligence](/artificial-intelligence-ai) [Machine\n",
"Learning](/machine-learning) [Data Science](/data-science) [Deep\n",
"Learning](/deep-learning) [TensorFlow](/tensorflow) [Artificial Neural\n",
"Network](/artificial-neural-network) [Matplotlib](/matplotlib) [Python\n",
"Scipy](/python-scipy)\n",
"\n",
"### Java\n",
"\n",
"[Java](/java-tutorial) [Servlet](/servlet-tutorial) [JSP](/jsp-tutorial)\n",
"[Spring Boot](/spring-boot-tutorial) [Spring Framework](/spring-tutorial)\n",
"[Hibernate](/hibernate-tutorial) [JavaFX](/javafx-tutorial) [Java Web\n",
"Services](/java-web-services-tutorial)\n",
"\n",
"### B.Tech and MCA\n",
"\n",
"[DBMS](/dbms-tutorial) [Data Structures](/data-structure-tutorial) [Operating\n",
"System](/operating-system) [Computer Network](/computer-network-tutorial)\n",
"[DAA](/daa-tutorial) [Computer Organization](/computer-organization-and-\n",
"architecture-tutorial) [Software Engineering](/software-engineering) [Data\n",
"Mining](/data-mining)\n",
"\n",
"### Web Technology\n",
"\n",
"[HTML](/html-tutorial) [CSS](/css-tutorial) [JavaScript](/javascript-tutorial)\n",
"[Jquery](/jquery-tutorial) [Angular-8](/angular-8) [React JS](/reactjs-\n",
"tutorial) [React Native](/react-native-tutorial) [Node JS](/nodejs-tutorial)\n",
"\n",
"### Software Testing\n",
"\n",
"[Software Testing](/software-testing-tutorial) [Selenium](/selenium-tutorial)\n",
"[JIRA](/jira-tutorial) [JMeter](/jmeter-tutorial) [Postman](/postman)\n",
"[TestNG](/testng-tutorial) [SoapUI](/soapui) [Cucumber](/cucumber-testing)\n",
"\n",
"Interview\n",
"\n",
"× \n",
"\n",
"### Technical Interview\n",
"\n",
"[C](/c-interview-questions) [C++](/cpp-interview-questions) [Php](/php-\n",
"interview-questions) [Java](/corejava-interview-questions) [Python](/python-\n",
"interview-questions) [JavaScript](/javascript-interview-questions)\n",
"[TypeScript](/typescript-interview-questions)\n",
"\n",
"### Java Interview\n",
"\n",
"[JDBC](/jdbc-interview-questions) [Servlet](/servletinterview) [Maven](/maven-\n",
"interview-questions) [Jenkins](/jenkins-interview-questions) [Spring](/spring-\n",
"interview-questions) [Spring Boot](/spring-boot-interview-questions)\n",
"[JDB](/jdb-interview-questions) [Hibernate](/hibernate-interview-questions)\n",
"[JSF](/jsf-interview-questions)\n",
"\n",
"### Web Interview\n",
"\n",
"[HTML](/html-interview-questions) [CSS](/css-interview-questions)\n",
"[JavaScript](/javascript-interview-questions) [Jquery](/jquery-interview-\n",
"questions) [Angular](/angular-interview-questions) [Node-JS](/node-js-\n",
"interview-questions) [AJAX](/ajax-interview-questions)\n",
"\n",
"### Database Interview\n",
"\n",
"[DBMS](/dbms-interview-questions) [SQL](/sql-interview-questions)\n",
"[PL/SQL](/pl-sql-interview-questions) [Oracle](/oracle-interview-questions)\n",
"[MySQL](/mysql-interview-questions) [MongoDB](/mongodb-interview-questions)\n",
"[Redis](/redis-interview-questions-and-answers) [MariaDB](/mariadb-interview-\n",
"questions)\n",
"\n",
"### Company Interviews\n",
"\n",
"[IBM](/ibm-interview-questions) [Adobe](/adobe-interview-questions)\n",
"[Microsoft](/microsoft-interview-questions) [Amazon](/amazon-interview-\n",
"questions) [TCS](/tcs-interview-questions) [HCL](/hcl-interview-questions)\n",
"[Wipro](/wipro-interview-questions) [DXC](/dxc-technology-interview-questions)\n",
"[Accenture](/accenture-interview-questions) [Capgemini](/capgemini-interview-\n",
"questions) [Space X](/spacex-interview-questions) [Ericsson](/ericsson-\n",
"interview-questions) [Infosy](/infosys-interview-questions) [IGate](/igate-\n",
"interview-questions) [EXL](/exl-interview-questions) [IndiaMART](/indiamart-\n",
"interview-questions) [Sapient](/sapient-interview-questions)\n",
"\n",
"Compiler\n",
"\n",
"× \n",
"\n",
"### Online Compilers\n",
"\n",
"[ __Python Online Compiler](/compiler/python)[ J Java Online Compiler\n",
"](/compiler/java)[__PHP Online Compiler](/compiler/php)[ __C Online\n",
"Compiler](/compiler/c)[ __C++ Online Compiler](/compiler/cpp)[ __HTML Online\n",
"Compiler](/compiler/html)[ __JavaScript Online\n",
"Compiler](/compiler/javascript)[ __TypeScript Online\n",
"Compiler](/compiler/typescript)[ __R Online Compiler](/compiler/r)[ Sw Swift\n",
"Online Compiler](/compiler/swift)\n",
"\n",
" * __\n",
"\n",
" * * * * \n",
"\n",
" * [Home](/)\n",
" * [ Python](/python-tutorial)\n",
" * [ Java](/java-tutorial)\n",
" * [ JavaScript](/javascript-tutorial)\n",
" * [HTML](/html-tutorial)\n",
" * [ SQL](/sql-tutorial)\n",
" * [ PHP](/php-tutorial)\n",
" * [ C#](/c-sharp-tutorial)\n",
" * [ C++](/cpp-tutorial)\n",
" * [ DS](/data-structure-tutorial)\n",
" * [ Aptitude](/aptitude/quantitative)\n",
" * [ Reasoning](/reasoning)\n",
" * [ Selenium](/selenium-tutorial)\n",
" * [ DBMS](/dbms-tutorial)\n",
" * [ C](/c-programming-language-tutorial)\n",
" * [ Andriod](/android-tutorial)\n",
" * [ Interview Q](/interview-tips)\n",
"\n",
"## Reinforcement Learning\n",
"\n",
" * [Reinforcement Learning Tutorial](/reinforcement-learning)\n",
"\n",
"## Related Tutorials\n",
"\n",
" * [Machine Learning Tutorial](/machine-learning)\n",
" * [Artificial Intelligence Tutorial](/artificial-intelligence-tutorial)\n",
" * [NLP Tutorial](/nlp)\n",
" * [Tensorflow Tutorial](/tensorflow)\n",
" * [Data Science Tutorial](/data-science)\n",
"\n",
"[next ->](applications-of-machine-learning)\n",
"\n",
"# Machine Learning Tutorial\n",
"\n",
"The Machine Learning Tutorial covers\n",
"both the fundamentals and more complex ideas of machine learning. Students and\n",
"professionals in the workforce can benefit from our machine learning\n",
"tutorial.A rapidly developing field of technology, machine learning allows\n",
"computers to automatically learn from previous data. For building mathematical\n",
"models and making predictions based on historical data or information, machine\n",
"learning employs a variety of algorithms. It is currently being used for a\n",
"variety of tasks, including speech recognition, email filtering, auto-tagging\n",
"on Facebook, a recommender system, and image recognition.You will learn about\n",
"the many different methods of machine learning, including reinforcement\n",
"learning, supervised learning, and unsupervised learning, in this machine\n",
"learning tutorial. Regression and classification models, clustering\n",
"techniques, hidden Markov models, and various sequential models will all be\n",
"covered.\n",
"\n",
"## What is Machine Learning\n",
"\n",
"In the real world, we are surrounded by humans who can learn everything from\n",
"their experiences with their learning capability, and we have computers or\n",
"machines which work on our instructions. But can a machine also learn from\n",
"experiences or past data like a human does? So here comes the role of\n",
"**Machine Learning**.**Introduction to Machine\n",
"Learning** A subset of artificial intelligence known as machine learning\n",
"focuses primarily on the creation of algorithms that enable a computer to\n",
"independently learn from data and previous experiences. Arthur Samuel first\n",
"used the term \"machine learning\" in 1959. It could be summarized as\n",
"follows:Without being explicitly programmed, machine learning enables a\n",
"machine to automatically learn from data, improve performance from\n",
"experiences, and predict things.Machine learning algorithms create a\n",
"mathematical model that, without being explicitly programmed, aids in making\n",
"predictions or decisions with the assistance of sample historical data, or\n",
"training data. For the purpose of developing predictive models, machine\n",
"learning brings together statistics and computer science. Algorithms that\n",
"learn from historical data are either constructed or utilized in machine\n",
"learning. The performance will rise in proportion to the quantity of\n",
"information we provide.**A machine can learn if it can gain more data to\n",
"improve its performance.**\n",
"\n",
"## How does Machine Learning work\n",
"\n",
"A machine learning system builds prediction models, learns from previous data,\n",
"and predicts the output of new data whenever it receives it. The amount of\n",
"data helps to build a better model that accurately predicts the output, which\n",
"in turn affects the accuracy of the predicted output.Let's say we have a\n",
"complex problem in which we need to make predictions. Instead of writing code,\n",
"we just need to feed the data to generic algorithms, which build the logic\n",
"based on the data and predict the output. Our perspective on the issue has\n",
"changed as a result of machine learning. The Machine Learning algorithm's\n",
"operation is depicted in the following block diagram:\n",
"\n",
"## Features of Machine Learning:\n",
"\n",
" * Machine learning uses data to detect various patterns in a given dataset.\n",
" * It can learn from past data and improve automatically.\n",
" * It is a data-driven technology.\n",
" * Machine learning is much similar to data mining as it also deals with the huge amount of the data.\n",
"\n",
"## Need for Machine Learning\n",
"\n",
"The demand for machine learning is steadily rising. Because it is able to\n",
"perform tasks that are too complex for a person to directly implement, machine\n",
"learning is required. Humans are constrained by our inability to manually\n",
"access vast amounts of data; as a result, we require computer systems, which\n",
"is where machine learning comes in to simplify our lives.By providing them\n",
"with a large amount of data and allowing them to automatically explore the\n",
"data, build models, and predict the required output, we can train machine\n",
"learning algorithms. The cost function can be used to determine the amount of\n",
"data and the machine learning algorithm's performance. We can save both time\n",
"and money by using machine learning.The significance of AI can be handily\n",
"perceived by its utilization's cases, Presently, AI is utilized in self-\n",
"driving vehicles, digital misrepresentation identification, face\n",
"acknowledgment, and companion idea by Facebook, and so on. Different top\n",
"organizations, for example, Netflix and Amazon have constructed AI models that\n",
"are utilizing an immense measure of information to examine the client interest\n",
"and suggest item likewise.Following are some key points which show the\n",
"importance of Machine Learning:\n",
"\n",
" * Rapid increment in the production of data\n",
" * Solving complex problems, which are difficult for a human\n",
" * Decision making in various sector including finance\n",
" * Finding hidden patterns and extracting useful information from data.\n",
"\n",
"## Classification of Machine Learning\n",
"\n",
"At a broad level, machine learning can be classified into three types:\n",
"\n",
" 1. **Supervised learning**\n",
" 2. **Unsupervised learning**\n",
" 3. **Reinforcement learning**\n",
"\n",
"\n",
"\n",
"### 1) Supervised Learning\n",
"\n",
"In supervised learning, sample labeled data are provided to the machine\n",
"learning system for training, and the system then predicts the output based on\n",
"the training data.The system uses labeled data to build a model that\n",
"understands the datasets and learns about each one. After the training and\n",
"processing are done, we test the model with sample data to see if it can\n",
"accurately predict the output.The mapping of the input data to the output data\n",
"is the objective of supervised learning. The managed learning depends on\n",
"oversight, and it is equivalent to when an understudy learns things in the\n",
"management of the educator. Spam filtering is an example of supervised\n",
"learning.Supervised learning can be grouped further in two categories of\n",
"algorithms:\n",
"\n",
" * **Classification**\n",
" * **Regression**\n",
"\n",
"### 2) Unsupervised Learning\n",
"\n",
"Unsupervised learning is a learning method in which a machine learns without\n",
"any supervision.The training is provided to the machine with the set of data\n",
"that has not been labeled, classified, or categorized, and the algorithm needs\n",
"to act on that data without any supervision. The goal of unsupervised learning\n",
"is to restructure the input data into new features or a group of objects with\n",
"similar patterns.In unsupervised learning, we don't have a predetermined\n",
"result. The machine tries to find useful insights from the huge amount of\n",
"data. It can be further classifieds into two categories of algorithms:\n",
"\n",
" * **Clustering**\n",
" * **Association**\n",
"\n",
"### 3) Reinforcement Learning\n",
"\n",
"Reinforcement learning is a feedback-based learning method, in which a\n",
"learning agent gets a reward for each right action and gets a penalty for each\n",
"wrong action. The agent learns automatically with these feedbacks and improves\n",
"its performance. In reinforcement learning, the agent interacts with the\n",
"environment and explores it. The goal of an agent is to get the most reward\n",
"points, and hence, it improves its performance.The robotic dog, which\n",
"automatically learns the movement of his arms, is an example of Reinforcement\n",
"learning.\n",
"\n",
"#### Note: We will learn about the above types of machine learning in detail\n",
"in later chapters.\n",
"\n",
"## History of Machine Learning\n",
"\n",
"Before some years (about 40-50 years), machine learning was science fiction,\n",
"but today it is the part of our daily life. Machine learning is making our day\n",
"to day life easy from **self-driving cars** to **Amazon virtual assistant\n",
"\"Alexa\"**. However, the idea behind machine learning is so old and has a long\n",
"history. Below some milestones are given which have occurred in the history of\n",
"machine learning:\n",
"\n",
"## The early history of Machine Learning (Pre-1940):\n",
"\n",
" * **1834:** In 1834, Charles Babbage, the father of the computer, conceived a device that could be programmed with punch cards. However, the machine was never built, but all modern computers rely on its logical structure.\n",
" * **1936:** In 1936, Alan Turing gave a theory that how a machine can determine and execute a set of instructions.\n",
"\n",
"## The era of stored program computers:\n",
"\n",
" * **1940:** In 1940, the first manually operated computer, \"ENIAC\" was invented, which was the first electronic general-purpose computer. After that stored program computer such as EDSAC in 1949 and EDVAC in 1951 were invented.\n",
" * **1943:** In 1943, a human neural network was modeled with an electrical circuit. In 1950, the scientists started applying their idea to work and analyzed how human neurons might work.\n",
"\n",
"## Computer machinery and intelligence:\n",
"\n",
" * **1950:** In 1950, Alan Turing published a seminal paper, \"**Computer Machinery and Intelligence** ,\" on the topic of artificial intelligence. **In his paper, he asked, \"Can machines think?\"**\n",
"\n",
"## Machine intelligence in Games:\n",
"\n",
" * **1952:** Arthur Samuel, who was the pioneer of machine learning, created a program that helped an IBM computer to play a checkers game. It performed better more it played.\n",
" * **1959:** In 1959, the term \"Machine Learning\" was first coined by **Arthur Samuel**.\n",
"\n",
"## The first \"AI\" winter:\n",
"\n",
" * The duration of 1974 to 1980 was the tough time for AI and ML researchers, and this duration was called as **AI winter**.\n",
" * In this duration, failure of machine translation occurred, and people had reduced their interest from AI, which led to reduced funding by the government to the researches.\n",
"\n",
"## Machine Learning from theory to reality\n",
"\n",
" * **1959:** In 1959, the first neural network was applied to a real-world problem to remove echoes over phone lines using an adaptive filter.\n",
" * **1985:** In 1985, Terry Sejnowski and Charles Rosenberg invented a neural network **NETtalk** , which was able to teach itself how to correctly pronounce 20,000 words in one week.\n",
" * **1997:** The IBM's **Deep blue** intelligent computer won the chess game against the chess expert Garry Kasparov, and it became the first computer which had beaten a human chess expert.\n",
"\n",
"## Machine Learning at 21st century\n",
"\n",
"**2006:**\n",
"\n",
" * Geoffrey Hinton and his group presented the idea of profound getting the hang of utilizing profound conviction organizations.\n",
" * The Elastic Compute Cloud (EC2) was launched by Amazon to provide scalable computing resources that made it easier to create and implement machine learning models.\n",
"\n",
"**2007:**\n",
"\n",
" * Participants were tasked with increasing the accuracy of Netflix's recommendation algorithm when the Netflix Prize competition began.\n",
" * Support learning made critical progress when a group of specialists utilized it to prepare a PC to play backgammon at a top-notch level.\n",
"\n",
"**2008:**\n",
"\n",
" * Google delivered the Google Forecast Programming interface, a cloud-based help that permitted designers to integrate AI into their applications.\n",
" * Confined Boltzmann Machines (RBMs), a kind of generative brain organization, acquired consideration for their capacity to demonstrate complex information conveyances.\n",
"\n",
"**2009:**\n",
"\n",
" * Profound learning gained ground as analysts showed its viability in different errands, including discourse acknowledgment and picture grouping.\n",
" * The expression \"Large Information\" acquired ubiquity, featuring the difficulties and open doors related with taking care of huge datasets.\n",
"\n",
"**2010:**\n",
"\n",
" * The ImageNet Huge Scope Visual Acknowledgment Challenge (ILSVRC) was presented, driving progressions in PC vision, and prompting the advancement of profound convolutional brain organizations (CNNs).\n",
"\n",
"**2011:**\n",
"\n",
" * On Jeopardy! IBM's Watson defeated human champions., demonstrating the potential of question-answering systems and natural language processing.\n",
"\n",
"**2012:**\n",
"\n",
" * AlexNet, a profound CNN created by Alex Krizhevsky, won the ILSVRC, fundamentally further developing picture order precision and laying out profound advancing as a predominant methodology in PC vision.\n",
" * Google's Cerebrum project, drove by Andrew Ng and Jeff Dignitary, utilized profound figuring out how to prepare a brain organization to perceive felines from unlabeled YouTube recordings.\n",
"\n",
"**2013:**\n",
"\n",
" * Ian Goodfellow introduced generative adversarial networks (GANs), which made it possible to create realistic synthetic data.\n",
" * Google later acquired the startup DeepMind Technologies, which focused on deep learning and artificial intelligence.\n",
"\n",
"**2014:**\n",
"\n",
" * Facebook presented the DeepFace framework, which accomplished close human precision in facial acknowledgment.\n",
" * AlphaGo, a program created by DeepMind at Google, defeated a world champion Go player and demonstrated the potential of reinforcement learning in challenging games.\n",
"\n",
"**2015:**\n",
"\n",
" * Microsoft delivered the Mental Toolbox (previously known as CNTK), an open-source profound learning library.\n",
" * The performance of sequence-to-sequence models in tasks like machine translation was enhanced by the introduction of the idea of attention mechanisms.\n",
"\n",
"**2016:**\n",
"\n",
" * The goal of explainable AI, which focuses on making machine learning models easier to understand, received some attention.\n",
" * Google's DeepMind created AlphaGo Zero, which accomplished godlike Go abilities to play without human information, utilizing just support learning.\n",
"\n",
"**2017:**\n",
"\n",
" * Move learning acquired noticeable quality, permitting pretrained models to be utilized for different errands with restricted information.\n",
" * Better synthesis and generation of complex data were made possible by the introduction of generative models like variational autoencoders (VAEs) and Wasserstein GANs.\n",
" * These are only a portion of the eminent headways and achievements in AI during the predefined period. The field kept on advancing quickly past 2017, with new leap forwards, strategies, and applications arising.\n",
"\n",
"## Machine Learning at present:\n",
"\n",
"The field of machine learning has made significant strides in recent years,\n",
"and its applications are numerous, including self-driving cars, Amazon Alexa,\n",
"Catboats, and the recommender system. It incorporates clustering,\n",
"classification, decision tree, SVM algorithms, and reinforcement learning, as\n",
"well as unsupervised and supervised learning.Present day AI models can be\n",
"utilized for making different expectations, including climate expectation,\n",
"sickness forecast, financial exchange examination, and so on.\n",
"\n",
"## Prerequisites\n",
"\n",
"Before learning machine learning, you must have the basic knowledge of\n",
"followings so that you can easily understand the concepts of machine learning:\n",
"\n",
" * Fundamental knowledge of probability and linear algebra.\n",
" * The ability to code in any computer language, especially in Python language.\n",
" * Knowledge of Calculus, especially derivatives of single variable and multivariate functions.\n",
"\n",
"## Audience\n",
"\n",
"Our Machine learning tutorial is designed to help beginner and professionals.\n",
"\n",
"## Problems\n",
"\n",
"We assure you that you will not find any difficulty while learning our Machine\n",
"learning tutorial. But if there is any mistake in this tutorial, kindly post\n",
"the problem or error in the contact form so that we can improve it.\n",
"\n",
"* * *\n",
"\n",
"Next Topic[Applications of Machine Learning](applications-of-machine-learning)\n",
"[next ->](applications-of-machine-learning) \n",
" \n",
"--- \n",
" \n",
"## Related Posts\n",
"\n",
" * ### [NLP TutorialNLP tutorial provides basic and advanced concepts of the NLP tutorial. Our NLP tutorial is designed for beginners and professionals. What is NLP? History of NLP Advantages of NLP Disadvantages of NLP Components of NLP Applications of NLP How to build an NLP pipeline? Phases of NLP Why NLP is Difficult? NLP APIs NLP Libraries Difference between Natural language and...__11 min read](nlp)\n",
" * ### [Tensorflow TutorialTensorFlow Tutorial Welcome to the TensorFlow tutorial, TensorFlow tutorial is designed for both beginners and professionals. Our tutorial provides all the basic and advanced concept of machine learning and deep learning concept such as deep neural network, image processing and sentiment analysis. TensorFlow is one of the famous deep...__2 min read](tensorflow)\n",
" * ### [Artificial Intelligence TutorialArtificial Intelligence (AI) Tutorial The Artificial Intelligence tutorial provides an introduction to AI which will help you to understand the concepts behind Artificial Intelligence. In this tutorial, we have also discussed various popular topics such as History of AI, applications of AI, deep learning, machine learning, natural language...__11 min read](artificial-intelligence-tutorial)\n",
" * ### [Data Science Tutorialfor Beginners Data Science has become the most demanding job of the 21st century. Every organization is looking for candidates with knowledge of data science. In this tutorial, we are giving an introduction to data science, with data science Job roles, tools for data science, components of...__19 min read](data-science)\n",
"\n",
"## Learn Important Tutorial\n",
"\n",
"[Python](/python-\n",
"tutorial)[Java](/java-\n",
"tutorial)[Javascript](/javascript-\n",
"tutorial)[HTML](/html-\n",
"tutorial)[Database](/sql-create-\n",
"database)[PHP](/php-\n",
"tutorial)[C++](/cpp-\n",
"tutorial)[React](/reactjs-tutorial)\n",
"\n",
"## B.Tech / MCA\n",
"\n",
"[DBMS](/dbms-\n",
"tutorial)[Data Structures](/data-structure-tutorial)[DAA](/daa-\n",
"tutorial)[Operating System](/operating-system)[Computer Network](/computer-network-tutorial)[Compiler Design](/compiler-tutorial)[Computer Organization](/computer-organization-and-\n",
"architecture-tutorial)[Discrete Mathematics](/discrete-mathematics-\n",
"tutorial)[Ethical Hacking](/ethical-hacking)[Computer Graphics](/computer-graphics-tutorial)[Web\n",
"Technology](/html-tutorial)[Software Engineering](/software-engineering)[Cyber Security](/cyber-security-tutorial)[Automata](/automata-\n",
"tutorial)[C\n",
"Programming](/c-programming-language-tutorial)[C++](/cpp-\n",
"tutorial)[Java](/java-\n",
"tutorial)[.Net](/net-framework)[Python](/python-\n",
"tutorial)[Programs](/programs-\n",
"list)[Control System](/control-system-tutorial)[Data Warehouse](/data-werehouse)\n",
"\n",
"## Preparation\n",
"\n",
"[Aptitude](/aptitude/quantitative)[Reasoning](/reasoning)[Verbal Ability](/verbal-ability)[Interview\n",
"Questions](/interview-questions-and-answers)[Company Questions](/company-interview-questions-and-recruitment-\n",
"process)\n",
"\n",
"\n",
"\n",
"We provides tutorials and interview questions of all technology like java\n",
"tutorial, android, java frameworks\n",
"\n",
"##### Contact info\n",
"\n",
" __G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India\n",
"\n",
" __[[email protected]](/cdn-cgi/l/email-protection).\n",
"\n",
"##### Follow us\n",
"\n",
"[](https://www.facebook.com/javatpoint)[](https://twitter.com/pagejavatpoint)[](https://javatpoint.blogspot.com)[](https://www.youtube.com/channel/UCUnYvQVCrJoFWZhKK3O2xLg)\n",
"\n",
" \n",
"\n",
"[Latest Post](/latest-post)\n",
"\n",
"[PRIVACY POLICY](/privacy-policy)\n",
"\n",
"##### Tutorials\n",
"\n",
"[Java](/java-tutorial) [Data Structures](/data-structure-tutorial) [C\n",
"Programming](/c-programming-language-tutorial) [C++ Tutorial](/cpp-tutorial)\n",
"[C# Tutorial](/c-sharp-tutorial) [PHP Tutorial ](/php-tutorial)[HTML\n",
"Tutorial](/html-tutorial) [JavaScript Tutorial ](/javascript-tutorial)[jQuery\n",
"Tutorial ](/jquery-tutorial)[Spring Tutorial](/spring-tutorial)\n",
"\n",
"##### Interview Questions\n",
"\n",
"[Tcs ](/tcs-interview-questions)[Intuit ](/intuit-interview-questions)[Wipro\n",
"](/wipro-interview-questions)[Adobe ](/adobe-interview-questions)[Infosys\n",
"](/infosys-interview-questions)[Amazon ](/amazon-interview-\n",
"questions)[Accenture](/accenture-interview-questions) [Cognizant ](/cognizant-\n",
"interview-questions)[Capgemini ](/capgemini-interview-\n",
"questions)[Microsoft](/microsoft-interview-questions)\n",
"\n",
"##### Online Compiler\n",
"\n",
"[C ](/compiler/c)[R ](/compiler/r)[C++ ](/compiler/cpp)[Php\n",
"](/compiler/php)[Java ](/compiler/java)[Html ](/compiler/html)[Swift\n",
"](/compiler/swift)[Python ](/compiler/python)[JavaScript\n",
"](/compiler/javascript)[TypeScript](/compiler/typescript)\n",
"\n",
"(C) Copyright 2025 Javatpoint. All Rights Reserved.\n",
"\n",
"__\n"
]
}
],
"source": [
"print(data[0].text)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [],
"source": [
"gemini_embedding = GeminiEmbedding(model_name='models/embedding-001')"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"GeminiEmbedding(model_name='models/embedding-001', embed_batch_size=10, callback_manager=<llama_index.core.callbacks.base.CallbackManager object at 0x00000198B1055D50>, num_workers=None, title=None, task_type='retrieval_document', api_key=None)"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gemini_embedding"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"model = Gemini(model_name = 'models/gemini-pro',api_key=api_key)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core.node_parser import SentenceSplitter\n",
"from llama_index.core import Settings\n",
"\n",
"Settings.llm = model\n",
"Settings.embed_model = gemini_embedding\n",
"Settings.node_parser = SentenceSplitter(chunk_size=512, chunk_overlap=20)\n",
"Settings.num_output = 512\n",
"Settings.context_window = 3900"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"SentenceSplitter(include_metadata=True, include_prev_next_rel=True, callback_manager=<llama_index.core.callbacks.base.CallbackManager object at 0x00000198B1057DF0>, id_func=<function default_id_func at 0x00000198AD4501F0>, chunk_size=512, chunk_overlap=20, separator=' ', paragraph_separator='\\n\\n\\n', secondary_chunking_regex='[^,.;。?!]+[,.;。?!]?')"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Settings.node_parser "
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"index = VectorStoreIndex.from_documents(data,settings = Settings)\n",
"# index.storage_context.persist()"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"query_engine = index.as_query_engine()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"response = query_engine.query(\"tell me about the history of machine learning\")"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [],
"source": [
"def to_markdown(text):\n",
" return Markdown(text)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [],
"source": [
"new_response = to_markdown(response.response)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"The history of machine learning can be divided into several eras:\n",
"\n",
"**Pre-1940:**\n",
"- 1834: Charles Babbage conceived a device that could be programmed with punch cards.\n",
"- 1936: Alan Turing gave a theory on how a machine can determine and execute a set of instructions.\n",
"\n",
"**The era of stored program computers:**\n",
"- 1940: The first manually operated computer, \"ENIAC\" was invented, which was the first electronic general-purpose computer.\n",
"- 1943: A human neural network was modeled with an electrical circuit.\n",
"- 1949: EDSAC, a stored program computer, was invented.\n",
"- 1951: EDVAC, another stored program computer, was invented.\n",
"\n",
"**Computer machinery and intelligence:**\n",
"- 1950: Alan Turing published a seminal paper, \"Computer Machinery and Intelligence,\" on the topic of artificial intelligence.\n",
"\n",
"**Machine intelligence in Games:**\n",
"- 1952: Arthur Samuel created a program that helped an IBM computer to play a checkers game.\n",
"- 1959: The term \"Machine Learning\" was first coined by Arthur Samuel.\n",
"\n",
"**The first \"AI\" winter:**\n",
"- 1974-1980: This was a tough time for AI and ML researchers, and this duration was called as **AI winter**.\n",
"\n",
"**Machine Learning from theory to reality:**\n",
"- 1959: The first neural network was applied to a real-world problem to remove echoes over phone lines using an adaptive filter."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_response"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"model = genai.GenerativeModel(model_name=\"models/gemini-pro\")"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"total_tokens: 336"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.count_tokens(response.response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|