from manim import *
from manim import SurroundingRectangle as sr
class ML(Scene):
def construct(self):
self.camera.background_color=GREEN
t=Text("Machine Learning Algorithms",font_size=22)
t.move_to(2.0*UP)
self.play(Write(t))
self.wait(10)
###############################
t1=Text("Supervised\n Learning",font_size=10)
t1.move_to(5.0*LEFT)
ar1=[Arrow(t.get_center(),t1.get_center(),color=RED,)]
self.play(GrowArrow(ar1[0]),Write(t1))
self.wait(10)
###############################
t2=Text("Unsupervised\nLearning",font_size=10)
t2.move_to(2.0*LEFT)
ar2=[Arrow(t.get_center(),t2.get_center(),color=RED,)]
self.play(GrowArrow(ar2[0]),Write(t2))
self.wait(5)
###############################
t3=Text("Semi Supervised \nLearning",font_size=10)
t3.move_to(2.0*RIGHT)
ar3=[Arrow(t.get_center(),t3.get_center(),color=RED,)]
self.play(GrowArrow(ar3[0]),Create(t3))
self.wait(10)
###############################
t4=Text("Reinforcement\n Learning",font_size=10)
t4.move_to(5.0*RIGHT)
ar4=[Arrow(t.get_center(),t4.get_center(),color=RED,)]
self.play(GrowArrow(ar4[0]),Create(t4))
self.wait(10)
###############################
t11=Text("Regression",font_size=10)
t11.move_to(6.0*LEFT+2.0*DOWN)
ar11=[Arrow(t1.get_center(),t11.get_center(),color=RED,)]
self.play(GrowArrow(ar11[0]),Write(t11))
self.wait(10)
##########
t12=Text("Classification",font_size=10)
t12.move_to(4.0*LEFT+2.0*DOWN)
ar12=[Arrow(t1.get_center(),t12.get_center(),color=RED,)]
self.play(GrowArrow(ar12[0]),Write(t12))
self.wait(10)
###############################
t21=Text(" Clustering",font_size=10)
t21.move_to(3.0*LEFT+2.0*DOWN)
ar21=[Arrow(t2.get_center(),t21.get_center(),color=RED,)]
self.play(GrowArrow(ar21[0]),Write(t21))
self.wait(5)
###############################
t22=Text("Feature \nReduction",font_size=10)
t22.move_to(1.0*LEFT+2.0*DOWN)
ar22=[Arrow(t2.get_center(),t22.get_center(),color=RED,)]
self.play(GrowArrow(ar22[0]),Write(t22))
self.wait(5)
###############################
for i in range(10):
self.play(Circumscribe(t12),run_time=4)
##################################################
self.remove(*t,*t1,*t11,*t12,*t21,*t22,*t2,*t3,t4,*ar1,*ar11,*ar12,*ar2,*ar21,*ar22, *ar3,*ar4,)
self.wait(4)
################################Image Mobject#######
source=Text("Image Source:: Analytics Vidya",font_size=12)
source.move_to(2.5 * UP)
self.play(Write(source))
image = ImageMobject("av_irish.png")
image.height =10
image.width=10
self.play(FadeIn(image))
self.wait(35)
self.play(FadeOut(image),FadeOut(source))
##################################################
i1=Text("S. No.").scale(0.3)
i11=Text("Sepal Length").scale(0.3)
i12=Text("Sepal Width").scale(0.3)
i13=Text("Petal Length ").scale(0.3)
i14=Text("Petal Width").scale(0.3)
l1=LabeledDot("Class").scale(0.3)
#####################################
i2=Text("1").scale(0.3)
i21=Text("5.1").scale(0.4)
i22=Text("3.5").scale(0.4)
i23=Text("1.4").scale(0.4)
i24=Text("0.2").scale(0.4)
l2=LabeledDot("Setosa").scale(0.3)
#####################################
i3=Text("2").scale(0.3)
i31=Text("4.9").scale(0.4)
i32=Text("3.0").scale(0.4)
i33=Text("1.4").scale(0.4)
i34=Text("0.2").scale(0.4)
l3=LabeledDot("Setosa").scale(0.3)
####################################
i4=Text("3").scale(0.3)
i41=Text("4.7").scale(0.4)
i42=Text("3.2").scale(0.4)
i43=Text("1.3").scale(0.4)
i44=Text("0.2").scale(0.4)
l4=LabeledDot("Setosa").scale(0.3)
################################
i5=Text("4").scale(0.3)
i51=Text("7.0").scale(0.4)
i52=Text("3.2").scale(0.4)
i53=Text("4.7").scale(0.4)
i54=Text("1.4").scale(0.4)
l5=LabeledDot("Versicolor").scale(0.2)
#########################################
i6=Text("5").scale(0.3)
i61=Text("6.5").scale(0.4)
i62=Text("2.8").scale(0.4)
i63=Text("4.6").scale(0.4)
i64=Text("1.5").scale(0.4)
l6=LabeledDot("Versicolor").scale(0.2)
#########################################
i7=Text("6").scale(0.3)
i71=Text("6.6").scale(0.4)
i72=Text("2.9").scale(0.4)
i73=Text("4.6").scale(0.4)
i74=Text("1.3").scale(0.4)
l7=LabeledDot("Versicolor").scale(0.2)
#########################################
i8=Text("7").scale(0.3)
i81=Text("6.3").scale(0.4)
i82=Text("3.3").scale(0.4)
i83=Text("6.0").scale(0.4)
i84=Text("2.5").scale(0.4)
l8=LabeledDot("Virginica").scale(0.2)
#########################################
i9=Text("8").scale(0.3)
i91=Text("7.1").scale(0.4)
i92=Text("3.0").scale(0.4)
i93=Text("5.9").scale(0.4)
i94=Text("2.1").scale(0.4)
l9=LabeledDot("Virginica").scale(0.2)
#########################################
i10=Text("9").scale(0.3)
i101=Text("7.3").scale(0.4)
i102=Text("2.9").scale(0.4)
i103=Text("6.3").scale(0.4)
i104=Text("1.8").scale(0.4)
l10=LabeledDot("Virginica").scale(0.2)
#########################################
#########################################
i1_1=Text("10").scale(0.3)
i111=Text("6.5").scale(0.4)
i112=Text("3.0").scale(0.4)
i113=Text("5.8").scale(0.4)
i114=Text("2.2").scale(0.4)
l11=LabeledDot("Unknown").scale(0.2)
#########################################
r1=VGroup(i1,i11,i12,i13,i14)
r2=VGroup(i2,i21,i22,i23,i24)
r3=VGroup(i3,i31,i32,i33,i34)
r4=VGroup(i4,i41,i42,i43,i44)
r5=VGroup(i5,i51,i52,i53,i54)
r6=VGroup(i6,i61,i62,i63,i64)
r7=VGroup(i7,i71,i72,i73,i74)
r8=VGroup(i8,i81,i82,i83,i84)
r9=VGroup(i9,i91,i92,i93,i94)
r10=VGroup(i10,i101,i102,i103,i104)
r11=VGroup(i1_1,i111,i112,i113,i114)
r1c=VGroup(i11,i12,i13,i14)
r2c=VGroup(i21,i22,i23,i24)
r3c=VGroup(i31,i32,i33,i34)
r4c=VGroup(i41,i42,i43,i44)
r5c=VGroup(i51,i52,i53,i54)
r6c=VGroup(i61,i62,i63,i64)
r7c=VGroup(i71,i72,i73,i74)
r8c=VGroup(i81,i82,i83,i84)
r9c=VGroup(i91,i92,i93,i94)
r10c=VGroup(i101,i102,i103,i104)
r11c=VGroup(i111,i112,i113,i114)
#########################################
l2.next_to(l1,RIGHT)
l3.next_to(l1,LEFT)
####################
cirsts=Circle(radius=1.0)
gsts=Group(cirsts,l2,l3,l4)
gsts.move_to(2.0*UP+3*RIGHT)
self.add(gsts)
self.play(Circumscribe(gsts),run_time=5)
###################
l5.next_to(l6,RIGHT)
l7.next_to(l6,LEFT)
###################3
cirver=Circle(radius=1.0)
gver=Group(cirver,l5,l6,l7)
gver.move_to(0.0*UP+3*RIGHT)
self.add(gver)
self.play(Circumscribe(gver),run_time=5)
####################
l8.next_to(l9,RIGHT)
l10.next_to(l9,LEFT)
###################3
cirverg=Circle(radius=1.0)
gverg=Group(cirverg,l8,l9,l10)
gverg.move_to(2.0*DOWN+3*RIGHT)
self.add(gverg)
self.play(Circumscribe(gverg),run_time=5)
####################
l1.move_to(1.5*RIGHT+2.0*UP)
l11.move_to(1.5*RIGHT)
####################
t=VGroup(*r1,*r2,*r3,*r4,*r5,*r6,*r7,*r8,*r9,*r10,*r11).set_x(0).arrange_in_grid(rows=12,cols=5)
t.shift(0.50*UP+3.5*LEFT)
###########################################################
self.play(Write(r1,run_time=2))
self.add(r1)
self.play(Circumscribe(i1,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r1c,Rectangle,time_width=2),run_time=2)
self.add(l1)
self.play(l1.copy().animate.next_to(i14, RIGHT),run_time=2)
self.wait(4)
############################################################
self.play(Write(r2),run_time=2)
self.add(r2)
self.play(Circumscribe(i2,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r2c,Rectangle,time_width=2),run_time=2)
self.add(l2)
self.play(l2.copy().animate.next_to(i24,2.50*RIGHT))
self.wait(4)
############################################################
self.play(Write(r3,run_time=2),time_width=2)
self.add(r3)
self.play(Circumscribe(i3,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r3c,Rectangle,time_width=2),run_time=2)
self.add(l3)
self.play(l3.copy().animate.next_to(i34,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r4,run_time=2),time_width=2)
self.add(r4)
self.play(Circumscribe(i4,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r4c,Rectangle,time_width=2),run_time=2)
self.add(l4)
self.play(l4.copy().animate.next_to(i44,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r5,run_time=2),time_width=2)
self.add(r5)
self.play(Circumscribe(i5,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r5c,Rectangle,time_width=2),run_time=2)
self.add(l5)
self.play(l5.copy().animate.next_to(i54,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r6,run_time=2),time_width=2)
self.add(r6)
self.play(Circumscribe(i6,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r6c,Rectangle,time_width=2),run_time=2)
self.add(l6)
self.play(l6.copy().animate.next_to(i64,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r7,run_time=2),time_width=2)
self.add(r7)
self.play(Circumscribe(i7,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r7c,Rectangle,time_width=2),run_time=2)
self.add(l7)
self.play(l7.copy().animate.next_to(i74,2.50* RIGHT),run_time=5)
self.wait(4)
##############################################################
self.play(Write(r8,run_time=2),time_width=2)
self.add(r8)
self.play(Circumscribe(i8,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r8c,Rectangle,time_width=2),run_time=2)
self.add(l8)
self.play(l8.copy().animate.next_to(i84,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r9,run_time=2),time_width=2)
self.add(r9)
self.play(Circumscribe(i9,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r9c,Rectangle,time_width=2),run_time=2)
self.add(l9)
self.play(l9.copy().animate.next_to(i94,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r10,run_time=2),time_width=2)
self.add(r10)
self.play(Circumscribe(i10,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r10c,Rectangle,time_width=2),run_time=2)
self.add(l10)
self.play(l10.copy().animate.next_to(i104,2.50* RIGHT),run_time=2)
self.wait(4)
##############################################################
self.play(Write(r11,run_time=2),time_width=2)
self.add(r11)
self.play(Circumscribe(i1_1,Circle,time_width=2),run_time=2)
self.play(Circumscribe(r11c,Rectangle,time_width=2),run_time=2)
self.add(l11)
self.play(l11.copy().animate.next_to(i114,2.50* RIGHT),run_time=2)
self.wait(20)
##############################################################
Output of the above code.