0% found this document useful (0 votes)
20 views

Aaman Sarkar Assignment2

Uploaded by

Aaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Aaman Sarkar Assignment2

Uploaded by

Aaman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

# Question 1

import turtle
win = turtle.Screen()
win.bgcolor("pink")
# created aan object
leo = turtle.Turtle()
leo.speed(0)
# defined an function for makeing the cylinder.
def cylinder(radii,length,coloring,home):
leo.penup()
leo.setheading(0)
leo.goto(home)
leo.pendown()
leo.fillcolor(coloring)
leo.begin_fill()
leo.left(90)
leo.circle(-radii,180,20)
leo.circle(radii,180,20)
leo.forward(length)
leo.left(180)
leo.circle(-radii,180,20)
leo.circle(radii,180,20)
leo.forward(length)
leo.circle(radii, 360, 20)
leo.end_fill()
leo.penup()
leo.goto(home[0]+4*radii,length)
leo.pendown()
leo.begin_fill()
leo.circle(-radii,360,20)
leo.end_fill()

# defined a function for makeing an upper arrow.

def arrow(length1,start):
leo.penup()
leo.setheading(90)
leo.goto(start)
leo.pendown()
leo.forward(length1)
leo.stamp()

# defined a function for makeing an lower arrow.

def arrow1(length2,start):
leo.penup()
leo.setheading(270)
leo.goto(start)
leo.pendown()
leo.forward(length2)
leo.stamp()

cylinder(12.5,200,"lightblue",(0,0))
cylinder(12.5,200,"lightblue",(100,0))
cylinder(12.5,200,"lightblue",(-100,0))
arrow(50,(10,-100))
arrow(50,(110,-100))
arrow(50,(-90,-100))
arrow1(50,(30,300))
arrow1(50,(130,300))
arrow1(50,(-70,300))

leo.hideturtle()

# Question 3
import turtle
win = turtle.Screen()
win.bgcolor("pink")
# created aan object
leo = turtle.Turtle()
leo.speed(0)
# defined an function for makeing the cylinder.
def cylinder(radii,length,coloring,home):
leo.penup()
leo.setheading(0)
leo.goto(home)
leo.pendown()
leo.fillcolor(coloring)
leo.begin_fill()
leo.left(90)
leo.circle(-radii,180,20)
leo.circle(radii,180,20)
leo.forward(length)
leo.left(180)
leo.circle(-radii,180,20)
leo.circle(radii,180,20)
leo.forward(length)
leo.circle(radii, 360, 20)
leo.end_fill()
leo.penup()
leo.goto(home[0]+4*radii,length)
leo.pendown()
leo.begin_fill()
leo.circle(-radii,360,20)
leo.end_fill()

# defined a function for makeing an upper arrow.

def arrow(length1,start):
leo.penup()
leo.setheading(90)
leo.goto(start)
leo.pendown()
leo.forward(length1)
leo.stamp()

# defined a function for makeing an lower arrow.

def arrow1(length2,start):
leo.penup()
leo.setheading(270)
leo.goto(start)
leo.pendown()
leo.forward(length2)
leo.stamp()

cylinder(12.5,200,"lightblue",(0,0))
cylinder(12.5,200,"lightgreen",(100,0))
cylinder(12.5,200,"red",(-100,0))
arrow(50,(10,-100))
arrow(50,(110,-100))
arrow(50,(-90,-100))
arrow1(50,(30,300))
arrow1(50,(130,300))
arrow1(50,(-70,300))

leo.hideturtle()

# Question 3
"""import matplotlib
import matplotlib.pyplot as plt

def create_diagram():
"""
This function creates a diagram depicting the machine learning process.
"""
fig, ax = plt.subplots()
# Create shapes
labeled_data_shape = matplotlib.patches.Ellipse(xy=(2, 5), width=3,
height=2, angle=0, color='lightblue')
model_shape = matplotlib.patches.Rectangle(xy=(4.5, 5), width=2, height=2,
color='lightgreen')
square_shape = matplotlib.patches.Rectangle(xy=(7, 5), width=1, height=1,
color='lightgray')
training_data_text = plt.text(1.5, 5, 'Labeled Data', ha='center',
va='center', fontsize=10)
model_text = plt.text(5, 5.5, 'Model', ha='center', va='center',
fontsize=10)
training_text = plt.text(7.5, 5, 'Training', ha='center', va='center',
fontsize=10)
triangle1_shape = matplotlib.patches.RegularPolygon(xy=(2, 3),
numVertices=3, radius=1, color='lightblue')
triangle2_shape = matplotlib.patches.RegularPolygon(xy=(5.5, 3),
numVertices=3, radius=1, color='lightyellow')
square2_shape = matplotlib.patches.Rectangle(xy=(7, 3), width=1, height=1,
color='lightgray')
test_data_text = plt.text(1.5, 3, 'Test Data', ha='center', va='center',
fontsize=10)
prediction_text = plt.text(5.5, 3, 'Prediction', ha='center', va='center',
fontsize=10)
oval_shape = matplotlib.patches.Ellipse(xy=(4.5, 1), width=3, height=1,
angle=0, color='lightpink')
labels_text = plt.text(5, 1, 'Labels', ha='center', va='center',
fontsize=10)
# Create arrows
arrow1 = matplotlib.patches.FancyArrowPatch((2.7, 5), (4.2, 5),
mutation_scale=100, color='black')
arrow2 = matplotlib.patches.FancyArrowPatch((5.7, 5), (7, 5),
mutation_scale=100, color='black')
arrow3 = matplotlib.patches.FancyArrowPatch((2, 2.5), (2, 4.2),
mutation_scale=100, color='black')
arrow4 = matplotlib.patches.FancyArrowPatch((5.5, 2.5), (5.5, 4.2),
mutation_scale=100, color='black')

# Add shapes and text to the plot


ax.add_patch(labeled_data_shape)
ax.add_patch(model_shape)
ax.add_patch(square_shape)
ax.add_patch(triangle1_shape)
ax.add_patch(triangle2_shape)
ax.add_patch(square2_shape)
ax.add_patch(oval_shape)
ax.text(**training_data_text.get_bbox_patch().get_transform())
ax.text(**model_text.get_bbox_patch().get_transform())
ax.text(**training_text.get_bbox_patch().get_transform())
ax.text(**test_data_text.get_bbox_patch().get_transform())
ax.text(**prediction_text.get_bbox_patch().get_transform())
ax.text(**labels_text.get_bbox_patch().get_transform())
ax.add_patch(arrow1)
ax.add_patch(arrow2)
ax.add_patch(arrow3)
ax.add_patch(arrow4)

# Set limits slightly higher than object positions


ax.set_xlim(-0.)
"""

You might also like