Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

MACHINE LEARNING QUESTION, USE JUPYTER LAB, NO AI PLZ: import this: import sys from packaging import version import sklearn import matplotlib.pyplot as plt import numpy

MACHINE LEARNING QUESTION, USE JUPYTER LAB, NO AI PLZ:
import this:
import sys
from packaging import version
import sklearn
import matplotlib.pyplot as plt
import numpy as np
from sklearn.preprocessing import add_dummy_feature
import numpy as np
from sklearn import metrics #Import scikit-learn metrics module for accuracy calculation
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
from sklearn.datasets import make_blobs
print("Sklearn package",sys.version_info)
print("Sklearn package",sklearn.__version__)
assert sys.version_info >=(3,10)
#assert version.parse(sklearn.__version__)>= version.parse("1.2.1")
plt.rc('font', size=12)
plt.rc('axes', labelsize=14, titlesize=14)
plt.rc('legend', fontsize=14)
plt.rc('xtick', labelsize=10)
plt.rc('ytick', labelsize=10)
-----
Questions:
# Q1 Gradient Descent
## Write a gradient descent method that finds the minimum for this function:
$f(x)=3x^2+5x$
-----
def f(x):
return(3*x*x +5*x)
X = np.linspace(-10,10,1000)
y =[f(x) for x in X]
plt.figure(figsize=(7,4))
plt.plot(X, y, linewidth=2)
plt.xlabel(r"$x$")
plt.ylabel(r"$f\(x)$")
plt.grid()
plt.show()
## Plot f(x) vs iteration
## Use these initial parameters
eta =0.2 # learning rate
n_epochs =50
theta =10

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Create a workflow analysis.

Answered: 1 week ago