Microsoft Windows [Version 10.0.22621.
1413]
(c) Microsoft Corporation. All rights reserved.
C:\Users\rohit>ipython
Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, [Link]) [MSC v.1934 64 bit
(AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: a=10
In [2]: a
Out[2]: 10
In [3]: r=purush
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[3], line 1
----> 1 r=purush
NameError: name 'purush' is not defined
In [4]: r=Purush
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[4], line 1
----> 1 r=Purush
NameError: name 'Purush' is not defined
In [5]: w=10
In [6]: w
Out[6]: 10
In [7]: x=[Link]([1,2,3,4,5])
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[7], line 1
----> 1 x=[Link]([1,2,3,4,5])
NameError: name 'np' is not defined
In [8]: import numpy as np
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[8], line 1
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
In [9]: pip install numpy
Collecting numpy
Downloading numpy-1.25.0-cp311-cp311-win_amd64.whl (15.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 15.0/15.0 MB 1.3 MB/s eta [Link]
Installing collected packages: numpy
Successfully installed numpy-1.25.0
[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: [Link] -m pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
In [10]: import numpy as np
In [11]: x=[Link]([1,2,3,4,5])
In [12]: x
Out[12]: array([1, 2, 3, 4, 5])
In [13]: pip install pandas
Collecting pandas
Downloading pandas-2.0.3-cp311-cp311-win_amd64.whl (10.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 10.6/10.6 MB 1.8 MB/s eta [Link]
Requirement already satisfied: python-dateutil>=2.8.2 in c:\users\rohit\appdata\
local\programs\python\python311\lib\site-packages (from pandas) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in c:\users\rohit\appdata\local\
programs\python\python311\lib\site-packages (from pandas) (2022.7.1)
Requirement already satisfied: tzdata>=2022.1 in c:\users\rohit\appdata\local\
programs\python\python311\lib\site-packages (from pandas) (2022.7)
Requirement already satisfied: numpy>=1.21.0 in c:\users\rohit\appdata\local\
programs\python\python311\lib\site-packages (from pandas) (1.25.0)
Requirement already satisfied: six>=1.5 in c:\users\rohit\appdata\local\programs\
python\python311\lib\site-packages (from python-dateutil>=2.8.2->pandas) (1.16.0)
Installing collected packages: pandas
Successfully installed pandas-2.0.3
[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: [Link] -m pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
In [14]: pip install [Link] as plt
ERROR: Could not find a version that satisfies the requirement [Link]
(from versions: none)
ERROR: No matching distribution found for [Link]
[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: [Link] -m pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
In [15]: pip install [Link] as plt
ERROR: Could not find a version that satisfies the requirement [Link]
(from versions: none)
ERROR: No matching distribution found for [Link]
[notice] A new release of pip is available: 23.0.1 -> 23.1.2
[notice] To update, run: [Link] -m pip install --upgrade pip
Note: you may need to restart the kernel to use updated packages.
In [16]: pip instll matplotlib
ERROR: unknown command "instll" - maybe you meant "install"
Note: you may need to restart the kernel to use updated packages.
In [17]: def gradient_descent(x,y):
...: ...: m_curr=b_curr=0
...: ...: n=len(x)
...: ...: iterations=10000
...: ...: learning_rate=0.08
...: ...: for i in range(iterations):
...: ...: y_pred=m_curr*x+b_curr
...: ...: cost=(1/n)sum([i*2 for i in (y-y_pred)])
...: ...: md=-(2/n)sum(x(y-y_pred))
...: ...: bd=-(2/n)*sum(y-y_pred)
...: ...: m_curr=m_curr-learning_rate*md
...: ...: b_curr=b_curr-learning_rate*bd
...: ...: print("m {},b {},cost {},iterations
{}".format(m_curr,b_curr,cost,i))
Cell In[17], line 8
cost=(1/n)sum([i*2 for i in (y-y_pred)])
^
SyntaxError: invalid syntax
In [18]: def gradient_descent(x,y):
...: