update,
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
[[source]]
|
||||
url = "https://pypi.org/simple"
|
||||
verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
jupyter = "*"
|
||||
notebook = "*"
|
||||
pandas = "*"
|
||||
quandl = "*"
|
||||
seaborn = "*"
|
||||
sklearn = "*"
|
||||
scikit-learn = "*"
|
||||
pydot = "*"
|
||||
bokeh = "*"
|
||||
jupyter-bokeh = "*"
|
||||
|
||||
[dev-packages]
|
||||
|
||||
[requires]
|
||||
python_version = "3"
|
1403
Man1130/task1/Man1130-python-comission/tryout/jupyter-helloworld/Pipfile.lock
generated
Normal file
1403
Man1130/task1/Man1130-python-comission/tryout/jupyter-helloworld/Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "d6162175",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"ename": "NameError",
|
||||
"evalue": "name 'Graph' is not defined",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[0;32mIn [1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m graph \u001b[38;5;241m=\u001b[39m \u001b[43mGraph\u001b[49m(with_edges_file\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124medges.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m, with_nodes_file\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mnodes.csv\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n",
|
||||
"\u001b[0;31mNameError\u001b[0m: name 'Graph' is not defined"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"graph = Graph(with_edges_file=\"edges.csv\", with_nodes_file=\"nodes.csv\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "29e0b539",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.11.2"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
python -m pip install --upgrade pip
|
||||
|
||||
python -m pip install pipenv
|
||||
|
||||
pipenv sync
|
||||
|
||||
pipenv run \
|
||||
jupyter-notebook \
|
||||
--allow-root \
|
||||
--ip=0.0.0.0
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "b6bf609f",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"helloworld\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"print('helloworld')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "9b24b4df",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "1cc7f2dc",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.8"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
pipenv install jupyter
|
||||
pipenv install jupyter notebook
|
||||
|
||||
pipenv install pandas
|
||||
pipenv install quandl
|
||||
|
||||
pipenv install seaborn
|
||||
pipenv install scikit-learn
|
||||
|
||||
# jupyter-notebook
|
||||
|
@@ -0,0 +1,27 @@
|
||||
### to spin up dev environment
|
||||
|
||||
```
|
||||
./start_docker.sh
|
||||
|
||||
// inside docker
|
||||
|
||||
./dev.sh
|
||||
|
||||
open host browser:
|
||||
http://127.0.0.1:8888/?token=98ab80de026fe83fd8e03c8e344b31e7575ec4a084c59f21
|
||||
|
||||
```
|
||||
|
||||
### to develop
|
||||
|
||||
|
||||
start from fresh python docker image
|
||||
|
||||
```
|
||||
./start_docker.sh
|
||||
|
||||
./init.sh
|
||||
```
|
||||
|
||||
|
||||
|
@@ -0,0 +1,792 @@
|
||||
id,name
|
||||
2975,Laurence Fishburne
|
||||
6384,Keanu Reeves
|
||||
530,Carrie-Anne Moss
|
||||
8349,Martin Sheen
|
||||
8351,Frederic Forrest
|
||||
8354,Albert Hall
|
||||
1107983,Martin Luther King Jr.
|
||||
52057,Obba Babatundé
|
||||
110380,Colin Powell
|
||||
18471,Anthony Anderson
|
||||
74611,Tracee Ellis Ross
|
||||
1407498,Marsai Martin
|
||||
40644,Chad Stahelski
|
||||
1779512,Jackson Spidell
|
||||
1357063,Darrin Prescott
|
||||
21127,Bobby Cannavale
|
||||
1692944,Heidi Schreck
|
||||
64,Gary Oldman
|
||||
1776,Francis Ford Coppola
|
||||
38803,Roman Coppola
|
||||
20215,Billy Campbell
|
||||
2130,Cary Elwes
|
||||
529,Guy Pearce
|
||||
532,Joe Pantoliano
|
||||
1278399,Joseph Steven
|
||||
1659326,Teresa Modnick
|
||||
26466,Caroline Kava
|
||||
18269,Brendan Fraser
|
||||
5606,Sissy Spacek
|
||||
5632,Jack Fisk
|
||||
1179102,Kathleen Kennedy
|
||||
11367,Bradley Whitford
|
||||
31028,Richard Schiff
|
||||
1397846,Craig Barron
|
||||
2166741,Robert A. Baum Jr.
|
||||
3266,Joe Mantegna
|
||||
36059,Joanna Pacula
|
||||
21010,Alexandra Hay
|
||||
101032,Rod McCary
|
||||
98569,Vincent Van Patten
|
||||
2080584,Ben Jorgensen
|
||||
103835,Jeff Monahan
|
||||
6717,James Marshall
|
||||
928944,Coleman Barks
|
||||
2022250,Robert Bly
|
||||
9979,Peter Coyote
|
||||
514,Jack Nicholson
|
||||
6193,Leonardo DiCaprio
|
||||
1892,Matt Damon
|
||||
2641,Martin Landau
|
||||
92029,Gabriel Bologna
|
||||
218506,Gretchen Becker
|
||||
2098136,Brian Becker
|
||||
2098137,Richard Becker
|
||||
2098138,Blase Bonpane
|
||||
181934,Al Sharpton
|
||||
496175,Carmelo Anthony
|
||||
1280183,Coretta Scott King
|
||||
1006651,John Lewis
|
||||
237876,Sarah-Jane Sauvegrain
|
||||
180659,Rosa Parks
|
||||
1165240,Jason Alan Carvell
|
||||
2787630,Valentin Zorin
|
||||
89289,Jesse Jackson
|
||||
2102583,Andrew Cohen
|
||||
73988,Lyndon B. Johnson
|
||||
21111,John F. Kennedy
|
||||
2803017,Arthur John Birch
|
||||
2803001,Haroldson Lafayette Hunt
|
||||
4193575,Maxime Demigné
|
||||
4193577,Gabin Clerc
|
||||
4193578,Tom Chabeau
|
||||
2954,Jeffrey Wright
|
||||
33663,Donald Trump
|
||||
2301996,Mike Pence
|
||||
214317,Ben Bradlee
|
||||
13716,Carl Bernstein
|
||||
117180,Tom Brokaw
|
||||
23626,Liev Schreiber
|
||||
937663,Neil Amdur
|
||||
1931175,Bob Beamon
|
||||
12951,O.J. Simpson
|
||||
2998183,Nicole Brown Simpson
|
||||
1231277,Marcia Clark
|
||||
60158,Shirley Jones
|
||||
24810,Pat Boone
|
||||
2535,Vivica A. Fox
|
||||
225620,Rudolph Moise
|
||||
1683093,Terayle Hill
|
||||
79538,Khalil Kain
|
||||
1562353,Erica Mena
|
||||
1038,Jodie Foster
|
||||
4173,Anthony Hopkins
|
||||
349,Scott Glenn
|
||||
4587,Halle Berry
|
||||
9780,Angela Bassett
|
||||
19011,George W. Bush
|
||||
146687,Tony Blair
|
||||
74266,Dick Cheney
|
||||
1507609,Bob Coen
|
||||
1507612,Francis E. Boyle
|
||||
1507613,Jean Patterson
|
||||
1122373,Marion Barry Jr.
|
||||
1122374,Chuck Brown
|
||||
1122375,Lewis Franklin
|
||||
1897,Bernie Mac
|
||||
77896,Bill Bellamy
|
||||
2395,Whoopi Goldberg
|
||||
1735828,Halle Bailey
|
||||
53397,Christina Aguilera
|
||||
1224841,Mo Willems
|
||||
539,Thomas Lennon
|
||||
111513,Yvette Nicole Brown
|
||||
2682390,Gerd Ludwig
|
||||
2227,Nicole Kidman
|
||||
4430,Sharon Stone
|
||||
14837,Carol Burnett
|
||||
5823,Julie Andrews
|
||||
3141,Marisa Tomei
|
||||
449538,Adele
|
||||
13309,Oprah Winfrey
|
||||
1661465,Lizzo
|
||||
102786,Barack Obama
|
||||
128550,Desmond Tutu
|
||||
2320880,Sundar Pichai
|
||||
2710,James Cameron
|
||||
8691,Zoe Saldaña
|
||||
72129,Jennifer Lawrence
|
||||
189111,Suzanne Collins
|
||||
23964,Gary Ross
|
||||
3894,Christian Bale
|
||||
19498,Jon Bernthal
|
||||
9827,Rose Byrne
|
||||
143103,Krew Boylan
|
||||
21708,Tomas Milian
|
||||
72983,Manny Pérez
|
||||
124909,Danny Hoch
|
||||
4038,Susan Sarandon
|
||||
18992,Aidan Quinn
|
||||
2047,Danny Glover
|
||||
4730,Emmy Rossum
|
||||
9464,Harry Lennix
|
||||
14409,David Schwimmer
|
||||
1415341,Kazuhiro Tsuji
|
||||
1267653,Chet Zar
|
||||
7467,David Fincher
|
||||
1519399,Erik Messerschmidt
|
||||
1003,Jean Reno
|
||||
524,Natalie Portman
|
||||
1810,Heath Ledger
|
||||
3895,Michael Caine
|
||||
958722,Eiko Ishioka
|
||||
41381,Sadie Frost
|
||||
10980,Daniel Radcliffe
|
||||
10989,Rupert Grint
|
||||
10990,Emma Watson
|
||||
219479,Criss Angel
|
||||
1101349,Steve Aoki
|
||||
1407495,Miles Brown
|
||||
3361135,Peter Kent
|
||||
1812,Michelle Williams
|
||||
2037,Cillian Murphy
|
||||
5081,Emily Blunt
|
||||
2559324,Beth Lane
|
||||
2559325,Lea Madda
|
||||
27888,Raúl Juliá
|
||||
2630,Nastassja Kinski
|
||||
151007,Peter Ramsey
|
||||
1769,Sofia Coppola
|
||||
19772,Paul Rassam
|
||||
1,George Lucas
|
||||
7879,John Lasseter
|
||||
1032,Martin Scorsese
|
||||
1006721,Charles Scorsese
|
||||
11483,Catherine Scorsese
|
||||
5953,Spike Jonze
|
||||
325,Eminem
|
||||
3125,Madonna
|
||||
3084,Marlon Brando
|
||||
1158,Al Pacino
|
||||
3085,James Caan
|
||||
3087,Robert Duvall
|
||||
3092,Diane Keaton
|
||||
117669,Portia Doubleday
|
||||
558466,Alex Russell
|
||||
61555,Haley Ramm
|
||||
10017,Charlton Heston
|
||||
5563,James Coburn
|
||||
26557,Ferdy Mayne
|
||||
18688,Harry Connick Jr.
|
||||
8437,Teri Garr
|
||||
589,Daryl Hannah
|
||||
16431,Sam Elliott
|
||||
2203,Neal McDonough
|
||||
3026,Rob Reiner
|
||||
32,Robin Wright
|
||||
12132,Michael Rooker
|
||||
932719,Jeff Gordon
|
||||
2127,James Wan
|
||||
2128,Leigh Whannell
|
||||
2675,Darren Lynn Bousman
|
||||
46300,Alexander Nathan Etel
|
||||
27889,Stephan Elliott
|
||||
1331,Hugo Weaving
|
||||
326,Kim Basinger
|
||||
323,Curtis Hanson
|
||||
11099,Dante Spinotti
|
||||
7187,Richard Donner
|
||||
57371,Jeff Cohen
|
||||
3034,Corey Feldman
|
||||
147,Michael Madsen
|
||||
21200,Will Arnett
|
||||
13611,Jack White
|
||||
10750,Sheryl Crow
|
||||
8261,Willie Nelson
|
||||
54693,Emma Stone
|
||||
19492,Viola Davis
|
||||
6944,Octavia Spencer
|
||||
287,Brad Pitt
|
||||
192,Morgan Freeman
|
||||
12052,Gwyneth Paltrow
|
||||
5376,Jean Smart
|
||||
5937,Kari Matchett
|
||||
26009,Gail O'Grady
|
||||
1067583,Suzanne Happ
|
||||
10427,Anne Archer
|
||||
781,Paul Reiser
|
||||
33,Gary Sinise
|
||||
5149,Bonnie Hunt
|
||||
2144,Tobin Bell
|
||||
141,David Carradine
|
||||
2505,James Cromwell
|
||||
42206,Matt McCoy
|
||||
10167,George Lazenby
|
||||
1226195,Rob Stewart
|
||||
13637,Joan Collins
|
||||
5320,Leslie Caron
|
||||
1641,Katrin Cartlidge
|
||||
10447,Mariel Hemingway
|
||||
76184,Bryan Marshall
|
||||
75781,John Turner
|
||||
39770,Adam Roarke
|
||||
34721,Larry Bishop
|
||||
83908,Daniel Massey
|
||||
1748,William Shatner
|
||||
8499,William Windom
|
||||
16896,James Garner
|
||||
8857,Debbie Reynolds
|
||||
15395,Maurice Ronet
|
||||
51763,Ross Martin
|
||||
955923,Ginny Tyler
|
||||
6474,James Le Gros
|
||||
69122,Heather Graham
|
||||
65344,Esai Morales
|
||||
6677,Kyle MacLachlan
|
||||
6678,Michael Ontkean
|
||||
6714,Mädchen Amick
|
||||
56890,Malcolm McDowell
|
||||
46393,Roseanne Barr
|
||||
9789,Robert Altman
|
||||
6449,Warren Beatty
|
||||
1353815,Dr. Diane Ravitch
|
||||
1353816,Dr. Linda Darling-Hammond
|
||||
20212,Dermot Mulroney
|
||||
41249,Tess Harper
|
||||
1841281,Joey Molland
|
||||
1225302,Annie Nightingale
|
||||
3546502,Jack Trout
|
||||
118764,Paulo Pires
|
||||
36281,Imanol Arias
|
||||
3199207,Jerry Dealey
|
||||
3199208,Barry Ernest
|
||||
82128,Wesley Clark
|
||||
21818,Lesley Ann Warren
|
||||
12967,Swoosie Kurtz
|
||||
13567,Ann-Margret
|
||||
25834,Leslie Hope
|
||||
1204293,J. Allen Hynek
|
||||
2027993,Philip J. Klass
|
||||
20959,Louis Gossett Jr.
|
||||
57829,Anthony LaPaglia
|
||||
7447,Alec Baldwin
|
||||
9560,Ellen Burstyn
|
||||
37421,James Naughton
|
||||
9976,Henry Thomas
|
||||
69597,Drew Barrymore
|
||||
1066777,Mumia Abu-Jamal
|
||||
65013,Rubin 'Hurricane' Carter
|
||||
4808,Giancarlo Esposito
|
||||
2045089,Jeanmarie Simpson
|
||||
4687,Patricia Arquette
|
||||
2045090,Joyce Julianne Auer
|
||||
7071,Louise Fletcher
|
||||
518,Danny DeVito
|
||||
10409,Shelley Duvall
|
||||
7077,Scatman Crothers
|
||||
3391,Kathleen Turner
|
||||
117075,Henry Jaglom
|
||||
34947,Kevin Conroy
|
||||
1262612,Neal Adams
|
||||
103,Mark Ruffalo
|
||||
2282,Ben Kingsley
|
||||
24045,Joseph Gordon-Levitt
|
||||
3899,Ken Watanabe
|
||||
21007,Jonah Hill
|
||||
234352,Margot Robbie
|
||||
16418,Casey Kasem
|
||||
15831,Frank Welker
|
||||
134,Jamie Foxx
|
||||
27319,Christoph Waltz
|
||||
11478,Lorraine Bracco
|
||||
380,Robert De Niro
|
||||
9261,Frank Abagnale Jr.
|
||||
488,Steven Spielberg
|
||||
2689,Jeff Nathanson
|
||||
31,Tom Hanks
|
||||
1206,Jason Alexander
|
||||
70851,Jack Black
|
||||
2157,Robin Williams
|
||||
880,Ben Affleck
|
||||
1231844,Manny Ramírez
|
||||
1214256,Curt Schilling
|
||||
3197,Tom Sizemore
|
||||
12833,Edward Burns
|
||||
10297,Matthew McConaughey
|
||||
1813,Anne Hathaway
|
||||
83002,Jessica Chastain
|
||||
21037,Prince
|
||||
1800494,Cora Coleman-Dunham
|
||||
1775343,Josh Dunham
|
||||
1205143,John Gazarian
|
||||
1205144,Darlene Landau
|
||||
2222,Beau Bridges
|
||||
18878,Rob Cohen
|
||||
9111,Peter Graves
|
||||
98234,Barbara Bain
|
||||
24589,Paul Mercurio
|
||||
24590,Dominique Sanda
|
||||
11770,John Carpenter
|
||||
515,Glenn Close
|
||||
179512,Marv Albert
|
||||
1865991,Jim Boeheim
|
||||
59785,Fat Joe
|
||||
84932,Jay-Z
|
||||
16450,Sean Combs
|
||||
210695,Jesse Williams
|
||||
1258041,David Axelrod
|
||||
1236577,Douglas Brinkley
|
||||
1374664,Louis-Émile Galey
|
||||
1010125,Claude Heymann
|
||||
1385039,Bryan Stevenson
|
||||
1641150,Patrisse Cullors
|
||||
938972,Angela Davis
|
||||
2149806,Gus Hall
|
||||
100709,Junior Wells
|
||||
1386798,Joseph McCarthy
|
||||
13348,Howard Hughes
|
||||
1247141,Harry S. Truman
|
||||
2802990,Jean Paul Getty
|
||||
117418,Mahalia Jackson
|
||||
1188876,Horace Clarence Boyer
|
||||
61399,Mike Ditka
|
||||
1232728,Jim McMahon
|
||||
1723195,Mike Singletary
|
||||
1219050,Hank Aaron
|
||||
14414,Kareem Abdul-Jabbar
|
||||
65605,Muhammad Ali
|
||||
136403,Robert Dryden
|
||||
1999091,Chris Schenkel
|
||||
1050881,Jacqueline Kennedy
|
||||
1152,Oliver Stone
|
||||
3331792,Vasili Arkhipov
|
||||
120578,Franklin D. Roosevelt
|
||||
57738,Samuel Labarthe
|
||||
1141815,Charles de Gaulle
|
||||
1204877,André Malraux
|
||||
1257876,Margaret Whitmer
|
||||
1051824,Tom Junod
|
||||
1998031,Joanne Rogers
|
||||
1116399,Winston Churchill
|
||||
18802,Ronald Reagan
|
||||
7571,Blair Brown
|
||||
84378,Nick Fraser
|
||||
1420,Robert Drew
|
||||
2102600,Jill Drew
|
||||
225009,Pablo Larraín
|
||||
6431,Darren Aronofsky
|
||||
8289,Billy Crudup
|
||||
1670479,Abbas Abdi
|
||||
1625013,Mahmoud Ahmadinejad
|
||||
84384,Osama Bin Laden
|
||||
2214123,Véronique Préault
|
||||
2412677,Xavier Pasco
|
||||
2412679,John Logsdon
|
||||
16811,Alexander Scheer
|
||||
3910768,Jürgen Hambrecht
|
||||
2823180,Wolfgang Ischinger
|
||||
4193580,Tkun
|
||||
4193583,Sofiane
|
||||
25072,Oscar Isaac
|
||||
3910,Frances McDormand
|
||||
1241,John Turturro
|
||||
1145892,Ed Koch
|
||||
1807640,Jane Jacobs
|
||||
557911,Robert F. Kennedy Jr.
|
||||
11161,Tom Savini
|
||||
27765,Richard Nixon
|
||||
1167702,Bruno Sammartino
|
||||
1167703,Bob Backlund
|
||||
2323039,Catherine Mercado-Muñiz
|
||||
2339577,Carmen Yulín Cruz
|
||||
10127,Jon Voight
|
||||
1229169,Roger Ailes
|
||||
3553309,John Shipton
|
||||
150882,Julian Assange
|
||||
16214,Mario Van Peebles
|
||||
227811,Herschel Walker
|
||||
1222706,Skip Bayless
|
||||
1816204,Frederick Oberlander
|
||||
1816207,Tevfik Arif
|
||||
3342345,Tim Gielen
|
||||
1954181,George Soros
|
||||
240633,Bill Gates
|
||||
80757,Mike Tyson
|
||||
1003978,Larry Holmes
|
||||
1306642,Kimberly DiPersia
|
||||
2289540,Alex R. Wagner
|
||||
2662043,Andrew Cuomo
|
||||
2266228,Kim Dae-jung
|
||||
2435679,Lee Geum-hee
|
||||
2266230,Kim Young-sam
|
||||
56446,John Cena
|
||||
216075,Candice Michelle
|
||||
568535,Matthew Kaye
|
||||
1326321,Paige
|
||||
57342,Vince McMahon
|
||||
60342,Emily Maitlis
|
||||
2041195,Prince Andrew Duke of York
|
||||
2607708,Jeffrey Epstein
|
||||
16620,Hulk Hogan
|
||||
77120,Steve Austin
|
||||
1647876,Hans Henrik Wöhler
|
||||
3252749,Michael Fanone
|
||||
3370866,Aquilino Gonell
|
||||
28151,Benoît Allemane
|
||||
2982422,Michael S. Cullen
|
||||
3242458,Isabelle Rouge-Ducos
|
||||
21397,Dennis Rodman
|
||||
3981237,Shirley Rodman
|
||||
567335,Chris Benoit
|
||||
115788,Paul Michael Lévesque
|
||||
112219,Michael Hickenbottom
|
||||
25504,André Roussimoff
|
||||
160733,Nick Bockwinkel
|
||||
2189100,Moon Jae-in
|
||||
1671675,Yuna Kim
|
||||
1644623,Ahn Jung-hwan
|
||||
21278,Alan Alda
|
||||
13724,Jane Alexander
|
||||
1428889,Ivy Austin
|
||||
3323316,Tricia Brooks
|
||||
2021450,Vernon Jordan
|
||||
3797418,Maria Kirke
|
||||
937664,Abraham Beame
|
||||
937665,Bob Bright
|
||||
1416398,Joshua L. Pearson
|
||||
46432,George H.W. Bush
|
||||
116341,Bill Clinton
|
||||
2652100,Curt Flood
|
||||
2652101,Judy Pace Flood
|
||||
219189,Jackie Robinson
|
||||
214725,Duke Snider
|
||||
3905,William H. Macy
|
||||
18686,Holly Hunter
|
||||
223120,Jack O'Callahan
|
||||
223121,Herb Brooks
|
||||
223122,Mike Eruzione
|
||||
107375,Joe Frazier
|
||||
1304153,Imelda Marcos
|
||||
587506,Shameik Moore
|
||||
543505,Jake Johnson
|
||||
130640,Hailee Steinfeld
|
||||
2415973,Daniel Petrocelli
|
||||
2413592,Fred Goldman
|
||||
81439,Vincent Bugliosi
|
||||
707,Dan Aykroyd
|
||||
26485,Jim Belushi
|
||||
54812,Chevy Chase
|
||||
5788,James Cagney
|
||||
87514,Roger Smith
|
||||
2177,Lloyd Bridges
|
||||
11140,Lynn Carlin
|
||||
22865,Little Richard
|
||||
1503749,Big Freedia
|
||||
1430,Keith Richards
|
||||
562922,Christian Keyes
|
||||
21215,Elise Neal
|
||||
21563,Corin Nemec
|
||||
2939038,Sydney Malakeh
|
||||
8689,Barry Shabaka Henley
|
||||
2297056,Darik Bernard
|
||||
2295,Mickey Rourke
|
||||
141823,Tisha Campbell
|
||||
1841650,Crystal-Lee Naomi
|
||||
1838518,Jermaine Rivers
|
||||
58924,Clifton Powell
|
||||
21355,DMX
|
||||
1922617,Joy Rovaris
|
||||
587035,Nadji Jeter
|
||||
479206,Demetria McKinney
|
||||
154382,Jazsmin Lewis
|
||||
31134,Darrin Henson
|
||||
74613,Terri J. Vaughn
|
||||
2808544,Daran Acevedo
|
||||
1297171,Julian Bane
|
||||
108081,Malik Barnhardt
|
||||
1220781,Shelly Altman
|
||||
115002,John Aniston
|
||||
1395884,Gessica Généus
|
||||
105762,Jimmy Jean-Louis
|
||||
1142232,Soledad Elizabeth Jean
|
||||
7672,Reginald VelJohnson
|
||||
1432244,Lyon Beckwith
|
||||
127931,Dorien Wilson
|
||||
77353,Jasmine Guy
|
||||
233191,Terrence 'T.C.' Carson
|
||||
1108907,Nick Robinson
|
||||
9278,Jennifer Garner
|
||||
19536,Josh Duhamel
|
||||
3593345,Chara James
|
||||
3593347,Zebulen M.N. Joyner-McCaster
|
||||
1214197,Carl Anthony Payne II
|
||||
16897,Sidney Poitier
|
||||
20493,Sydney Tamiia Poitier
|
||||
119598,Phylicia Rashād
|
||||
109686,Flex Alexander
|
||||
109687,Mike Batayeh
|
||||
77072,Tyson Beckford
|
||||
1232383,Parker McKenna Posey
|
||||
1573627,Torrei Hart
|
||||
1437841,AzMarie Livingston
|
||||
55637,Brian Hooks
|
||||
1100816,René Aranda
|
||||
3581413,Dwight Boyce
|
||||
60490,Paul Terrell Clayton
|
||||
1036,Cybill Shepherd
|
||||
5049,John Hurt
|
||||
10774,Anne Bancroft
|
||||
39187,Olivia Colman
|
||||
34546,Mark Gatiss
|
||||
54448,Ismail Merchant
|
||||
54441,James Ivory
|
||||
54443,Ruth Prawer Jhabvala
|
||||
4786,Richard Attenborough
|
||||
1137,Juliette Binoche
|
||||
28974,Damon Lindelof
|
||||
15851,Amy Brenneman
|
||||
15009,Justin Theroux
|
||||
33181,Jimmy Smits
|
||||
63611,Nickolas Grace
|
||||
53574,Eric Thal
|
||||
16217,Lynn Whitfield
|
||||
15762,Tara Strong
|
||||
1160,Michelle Pfeiffer
|
||||
8891,John Travolta
|
||||
44038,Nancy Allen
|
||||
1121437,Leslie Felperin
|
||||
70243,Eartha Kitt
|
||||
15973,Julie Newmar
|
||||
16108,Lee Meriwether
|
||||
44796,Franklyn Ajaye
|
||||
35705,Regina Hall
|
||||
143242,Terrence Jenkins
|
||||
174837,Yolanda Adams
|
||||
56323,Tina Fey
|
||||
78577,Graham Norton
|
||||
3223,Robert Downey Jr.
|
||||
16828,Chris Evans
|
||||
1189929,Condoleezza Rice
|
||||
7904,Billy Crystal
|
||||
533195,Henry Kissinger
|
||||
143280,Norman Mailer
|
||||
2801284,Anthony Amsterdam
|
||||
1220601,John Chancellor
|
||||
1066763,Darrell Royal
|
||||
50707,Ed Marinaro
|
||||
1322033,Bob Brenly
|
||||
1322034,Scott Brosius
|
||||
1233313,Joe Buck
|
||||
3273875,Bob Taylor
|
||||
3622690,Betty Ong
|
||||
3622691,Nydia Gonzalez
|
||||
3492377,Madeleine Albright
|
||||
3492379,Ilie Alexandru
|
||||
3492380,Ioan Amarie
|
||||
1442410,Trevor Phillips
|
||||
1442411,Nigel Farage
|
||||
1225259,Kirsty Young
|
||||
174981,King Charles III of the United Kingdom
|
||||
1094687,Prince Edward Duke of Edinburgh
|
||||
1306064,Princess Diana of Wales
|
||||
558240,Queen Elizabeth II of the United Kingdom
|
||||
47,Björk
|
||||
3219627,Lydia Korniordou
|
||||
2921077,Jacques Rogge
|
||||
37759,Kathy Burke
|
||||
20056,Keith Allen
|
||||
2330903,Amir Amor
|
||||
3897137,Cool 'Disco' Dan
|
||||
9290,Henry Rollins
|
||||
15535,Robin Harris
|
||||
5726,Cedric the Entertainer
|
||||
68215,Reginald Hudlin
|
||||
181975,Mark Curry
|
||||
82587,Steve Harvey
|
||||
78029,Martin Lawrence
|
||||
9309,Richard Pryor
|
||||
57551,Mario Cantone
|
||||
18291,Larenz Tate
|
||||
1633946,Chris Gattling
|
||||
10814,Wesley Snipes
|
||||
1903010,Spence Moore II
|
||||
55638,Kevin Hart
|
||||
5916,Rosario Dawson
|
||||
9206,Neve Campbell
|
||||
36811,Nick Cannon
|
||||
1870421,Collie Buddz
|
||||
2412016,Lilly Bartlam
|
||||
186529,Tony Daniels
|
||||
88059,Tommy Davidson
|
||||
15411,T.K. Carter
|
||||
1428,Mick Jagger
|
||||
1429,Charlie Watts
|
||||
53396,Ron Wood
|
||||
8534,Kathy Bates
|
||||
1121,Benicio del Toro
|
||||
3392,Michael Douglas
|
||||
17051,James Franco
|
||||
59315,Olivia Wilde
|
||||
2838,Chloë Sevigny
|
||||
155488,Kelly Clarkson
|
||||
292445,Blake Shelton
|
||||
21986,Reba McEntire
|
||||
2387,Patrick Stewart
|
||||
2388,Jonathan Frakes
|
||||
1213786,Brent Spiner
|
||||
4756,Matthew Broderick
|
||||
15152,James Earl Jones
|
||||
16940,Jeremy Irons
|
||||
148120,Tiffany
|
||||
83170,Valerie Harper
|
||||
2774840,Luis Miranda
|
||||
1179651,Lin-Manuel Miranda
|
||||
216674,Hillary Clinton
|
||||
73641,Christiane Amanpour
|
||||
1202593,Neil Barnard
|
||||
33684,Bono
|
||||
1650331,Jeremy O. Harris
|
||||
350,Laura Linney
|
||||
2391,Michael Dorn
|
||||
172069,Chadwick Boseman
|
||||
1215522,Robin Roberts
|
||||
1896,Don Cheadle
|
||||
6240,Mariska Hargitay
|
||||
21411,Ice-T
|
||||
206637,Kelli Giddish
|
||||
120608,Sonia Manzano
|
||||
1596910,Nitya Vidyasagar
|
||||
934281,Alex Wolff
|
||||
1700685,Lewis Pullman
|
||||
1241339,Bo Mitchell
|
||||
14386,Beyoncé
|
||||
1214573,Serena Williams
|
||||
93527,Kelly Rowland
|
||||
167662,Ryan Seacrest
|
||||
2384929,Lindsay Arnold
|
||||
138986,Tony Bennett
|
||||
72208,Alicia Keys
|
||||
3284,Bruce Springsteen
|
||||
18746,Stevie Wonder
|
||||
37934,André 3000
|
||||
15310,Anthony Kiedis
|
||||
12207,Kylie Minogue
|
||||
1564846,Auli'i Cravalho
|
||||
1473281,James Monroe Iglehart
|
||||
2522829,Vanessa Laine Bryant
|
||||
23678,Michael Jordan
|
||||
35806,Shaquille O'Neal
|
||||
1212304,Jon Scieszka
|
||||
1192274,Jordan Fisher
|
||||
132354,Kate Micucci
|
||||
133451,Aya Cash
|
||||
111684,Lennon Parham
|
||||
60227,Greg Cipes
|
||||
1249820,Romi Dames
|
||||
8536,Victor Garber
|
||||
1178795,Ben Diskin
|
||||
1842039,Joe Tessitore
|
||||
71403,Rob Riggle
|
||||
129193,Paula Abdul
|
||||
75394,Terence Donovan
|
||||
1083951,Veronica Lang
|
||||
500,Tom Cruise
|
||||
150536,Barry Otto
|
||||
76182,Nicholas Eadie
|
||||
76788,Dev Patel
|
||||
108916,Rooney Mara
|
||||
1371,David Wenham
|
||||
113552,Briony Behets
|
||||
1242514,James Smillie
|
||||
1246450,Bartholomew John
|
||||
1747292,Robert Board
|
||||
106179,Anthony Franciosa
|
||||
82315,Jean Harlow
|
||||
11492,Clark Gable
|
||||
1916574,Caitlin Doughty
|
||||
5168,Gabriel Byrne
|
||||
516,Annette Bening
|
||||
4517,Joe Pesci
|
||||
71531,Deepak Chopra
|
||||
1383964,Thích Nhất Hạnh
|
||||
1867979,Sister Chân Không
|
||||
8293,Marion Cotillard
|
||||
32017,Didier Lavergne
|
||||
3753843,Bryna Rifkin
|
||||
5682,Anouk Aimée
|
||||
44556,Richard Anconina
|
||||
20234,Fanny Ardant
|
||||
40159,Keith Michell
|
||||
58414,Dina Merrill
|
||||
4,Carrie Fisher
|
||||
6541,Philip Bosco
|
||||
157359,Jane Connell
|
||||
1729824,Randy Doney
|
||||
1392152,Dan Levy
|
||||
26510,Eugene Levy
|
||||
11514,Catherine O'Hara
|
||||
290,Christopher Plummer
|
||||
21104,Glenne Headly
|
||||
80866,Nell Carter
|
||||
40063,Lea DeLaria
|
||||
537064,Perry Como
|
||||
109887,Caroll Spinney
|
||||
8515,Jane Darwell
|
||||
5829,Karen Dotrice
|
||||
1201,Garry Marshall
|
||||
1041410,Charmian Carr
|
||||
22384,John Amos
|
||||
105637,Morey Amsterdam
|
||||
6613,Minnie Driver
|
||||
57133,Paulo Costanzo
|
||||
18461,Nick Chinlund
|
||||
1216139,Michael Raynor
|
||||
57389,Justin Pierce
|
||||
87525,Alan Carr
|
||||
7056,Emma Thompson
|
||||
154782,Pat Benatar
|
||||
154783,Neil Giraldo
|
||||
174875,Carly Simon
|
||||
929825,Ava DuVernay
|
||||
2302408,Korey Wise
|
||||
20019,Lee Daniels
|
||||
1658802,Andra Day
|
||||
964843,Michelle Obama
|
||||
3889844,Haizel Adofo
|
||||
113461,John Legend
|
||||
206444,Constance Wu
|
||||
1700631,Liza Koshy
|
||||
2503684,Abdullah bin Abdulaziz Al Saud
|
||||
107379,LeBron James
|
||||
66620,Angela Merkel
|
||||
2134341,Theresa May
|
||||
3089883,Gabby Giffords
|
||||
1608713,Mark Kelly
|
||||
1068409,Frank Marshall Davis
|
||||
1068410,Ann Dunham
|
||||
1068411,Stanley Dunham
|
||||
149923,Lester Brown
|
||||
1063969,Yvo de Boer
|
||||
1063970,Paul R. Ehrlich
|
||||
10279,Adolf Hitler
|
||||
89300,Nelson Mandela
|
||||
3451053,Natalya Sindeeva
|
||||
3527796,Aleksandr Vinokurov
|
||||
1745467,Vera Krichevskaya
|
||||
1173480,François Hollande
|
||||
1348088,Laurent Delahousse
|
||||
1977908,Claire Chazal
|
||||
2169865,Birgitta Assheuer
|
||||
2920376,Îlham Ahmed
|
||||
2920377,Zaher al-Saket
|
|
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
docker run -it \
|
||||
-v $PWD:/app \
|
||||
-w /app \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v ~/.ssh/id_rsa:/home/node/.ssh/id_rsa:ro \
|
||||
-v ~/.ssh/known_host:/home/node/.ssh/known_hosts:ro \
|
||||
-p 8888:8888 \
|
||||
--rm \
|
||||
python:3.10 \
|
||||
bash
|
||||
|
||||
# -u 1000:1000 \
|
||||
# -e XDG_CACHE_HOME=/app/.cache \
|
||||
|
@@ -0,0 +1,448 @@
|
||||
import http.client
|
||||
import json
|
||||
import csv
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
# cse6242
|
||||
# All instructions, code comments, etc. contained within this notebook are part of the assignment instructions.
|
||||
# Portions of this file will auto-graded in Gradescope using different sets of parameters / data to ensure that values are not
|
||||
# hard-coded.
|
||||
#
|
||||
# Instructions: Implement all methods in this file that have a return
|
||||
# value of 'NotImplemented'. See the documentation within each method for specific details, including
|
||||
# the expected return value
|
||||
#
|
||||
# Helper Functions:
|
||||
# You are permitted to write additional helper functions/methods or use additional instance variables within
|
||||
# the `Graph` class or `TMDbAPIUtils` class so long as the originally included methods work as required.
|
||||
#
|
||||
# Use:
|
||||
# The `Graph` class is used to represent and store the data for the TMDb co-actor network graph. This class must
|
||||
# also provide some basic analytics, i.e., number of nodes, edges, and nodes with the highest degree.
|
||||
#
|
||||
# The `TMDbAPIUtils` class is used to retrieve Actor/Movie data using themoviedb.org API. We have provided a few necessary methods
|
||||
# to test your code w/ the API, e.g.: get_movie_cast(), get_movie_credits_for_person(). You may add additional
|
||||
# methods and instance variables as desired (see Helper Functions).
|
||||
#
|
||||
# The data that you retrieve from the TMDb API is used to build your graph using the Graph class. After you build your graph using the
|
||||
# TMDb API data, use the Graph class write_edges_file & write_nodes_file methods to produce the separate nodes and edges
|
||||
# .csv files for use with the Argo-Lite graph visualization tool.
|
||||
#
|
||||
# While building the co-actor graph, you will be required to write code to expand the graph by iterating
|
||||
# through a portion of the graph nodes and finding similar artists using the TMDb API. We will not grade this code directly
|
||||
# but will grade the resulting graph data in your Argo-Lite graph snapshot.
|
||||
#
|
||||
#############################################################################################################################
|
||||
|
||||
|
||||
class Graph:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, with_nodes_file=None, with_edges_file=None):
|
||||
"""
|
||||
option 1: init as an empty graph and add nodes
|
||||
option 2: init by specifying a path to nodes & edges files
|
||||
"""
|
||||
self.nodes = []
|
||||
self.edges = []
|
||||
if with_nodes_file and with_edges_file:
|
||||
nodes_CSV = csv.reader(open(with_nodes_file))
|
||||
nodes_CSV = list(nodes_CSV)[1:]
|
||||
self.nodes = [(n[0], n[1]) for n in nodes_CSV]
|
||||
|
||||
edges_CSV = csv.reader(open(with_edges_file))
|
||||
edges_CSV = list(edges_CSV)[1:]
|
||||
self.edges = [(e[0], e[1]) for e in edges_CSV]
|
||||
|
||||
|
||||
def add_node(self, id: str, name: str) -> None:
|
||||
"""
|
||||
add a tuple (id, name) representing a node to self.nodes if it does not already exist
|
||||
The graph should not contain any duplicate nodes
|
||||
"""
|
||||
if (id, name) not in self.nodes:
|
||||
self.nodes.append((id, name))
|
||||
|
||||
# return NotImplemented
|
||||
|
||||
|
||||
def add_edge(self, source: str, target: str) -> None:
|
||||
"""
|
||||
Add an edge between two nodes if it does not already exist.
|
||||
An edge is represented by a tuple containing two strings: e.g.: ('source', 'target').
|
||||
Where 'source' is the id of the source node and 'target' is the id of the target node
|
||||
e.g., for two nodes with ids 'a' and 'b' respectively, add the tuple ('a', 'b') to self.edges
|
||||
"""
|
||||
current_edge = (source, target)
|
||||
current_edge_inverted = (target, source)
|
||||
if (source != target) and (current_edge not in self.edges) and (current_edge_inverted not in self.edges):
|
||||
self.edges.append(current_edge)
|
||||
|
||||
# return NotImplemented
|
||||
|
||||
|
||||
def total_nodes(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of nodes in the graph
|
||||
"""
|
||||
return len(self.nodes)
|
||||
# return NotImplemented
|
||||
|
||||
def total_edges(self) -> int:
|
||||
"""
|
||||
Returns an integer value for the total number of edges in the graph
|
||||
"""
|
||||
return len(self.edges)
|
||||
# return NotImplemented
|
||||
|
||||
def non_leaf_nodes(self):
|
||||
nodes_degrees = {}
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in nodes_degrees:
|
||||
nodes_degrees[idx] += 1
|
||||
else:
|
||||
nodes_degrees[idx] = 1
|
||||
|
||||
non_leaf_nodes = dict((k, v) for k, v in nodes_degrees.items() if v > 1)
|
||||
return len(non_leaf_nodes)
|
||||
|
||||
|
||||
|
||||
def max_degree_nodes(self) -> dict:
|
||||
"""
|
||||
Return the node(s) with the highest degree
|
||||
Return multiple nodes in the event of a tie
|
||||
Format is a dict where the key is the node_id and the value is an integer for the node degree
|
||||
e.g. {'a': 8}
|
||||
or {'a': 22, 'b': 22}
|
||||
"""
|
||||
|
||||
max_degree_nodes = {}
|
||||
|
||||
for edge in self.edges:
|
||||
for idx in edge:
|
||||
if idx in max_degree_nodes:
|
||||
max_degree_nodes[idx] += 1
|
||||
else:
|
||||
max_degree_nodes[idx] = 1
|
||||
|
||||
v = list(max_degree_nodes.values())
|
||||
k = list(max_degree_nodes.keys())
|
||||
max_nodes = {k[v.index(max(v))]: max(v)}
|
||||
print(max_nodes)
|
||||
return max_nodes
|
||||
|
||||
def print_nodes(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.nodes)
|
||||
|
||||
def print_edges(self):
|
||||
"""
|
||||
No further implementation required
|
||||
May be used for de-bugging if necessary
|
||||
"""
|
||||
print(self.edges)
|
||||
|
||||
# Do not modify
|
||||
def write_edges_file(self, path="edges.csv")->None:
|
||||
"""
|
||||
write all edges out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
edges_path = path
|
||||
edges_file = open(edges_path, 'w', encoding='utf-8')
|
||||
|
||||
edges_file.write("source" + "," + "target" + "\n")
|
||||
|
||||
for e in self.edges:
|
||||
edges_file.write(e[0] + "," + e[1] + "\n")
|
||||
|
||||
edges_file.close()
|
||||
print("finished writing edges to csv")
|
||||
|
||||
# Do not modify
|
||||
def write_nodes_file(self, path="nodes.csv")->None:
|
||||
"""
|
||||
write all nodes out as .csv
|
||||
:param path: string
|
||||
:return: None
|
||||
"""
|
||||
nodes_path = path
|
||||
nodes_file = open(nodes_path, 'w', encoding='utf-8')
|
||||
|
||||
nodes_file.write("id,name" + "\n")
|
||||
for n in self.nodes:
|
||||
nodes_file.write(n[0] + "," + n[1] + "\n")
|
||||
nodes_file.close()
|
||||
print("finished writing nodes to csv")
|
||||
|
||||
|
||||
class TMDBAPIUtils:
|
||||
|
||||
# Do not modify
|
||||
def __init__(self, api_key:str):
|
||||
self.api_key=api_key
|
||||
|
||||
def get_movie_cast(self, movie_id:str, limit:int=None, exclude_ids:list=None) -> list:
|
||||
"""
|
||||
Get the movie cast for a given movie id, with optional parameters to exclude an cast member
|
||||
from being returned and/or to limit the number of returned cast members
|
||||
documentation url: https://developers.themoviedb.org/3/movies/get-movie-credits
|
||||
|
||||
:param integer movie_id: a movie_id
|
||||
:param integer limit: maximum number of returned cast members by their 'order' attribute
|
||||
e.g., limit=5 will attempt to return the 5 cast members having 'order' attribute values between 0-4
|
||||
If after excluding, there are fewer cast members than the specified limit, then return the remaining members (excluding the ones whose order values are outside the limit range).
|
||||
If cast members with 'order' attribute in the specified limit range have been excluded, do not include more cast members to reach the limit.
|
||||
If after excluding, the limit is not specified, then return all remaining cast members."
|
||||
e.g., if limit=5 and the actor whose id corresponds to cast member with order=1 is to be excluded,
|
||||
return cast members with order values [0, 2, 3, 4], not [0, 2, 3, 4, 5]
|
||||
:param list exclude_ids: a list of ints containing ids (not cast_ids) of cast members that should be excluded from the returned result
|
||||
e.g., if exclude_ids are [353, 455] then exclude these from any result.
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per cast member with the following structure:
|
||||
[{'id': '97909' # the id of the cast member
|
||||
'character': 'John Doe' # the name of the character played
|
||||
'credit_id': '52fe4249c3a36847f8012927' # id of the credit, ...}, ... ]
|
||||
Note that this is an example of the structure of the list and some of the fields returned by the API.
|
||||
The result of the API call will include many more fields for each cast member.
|
||||
|
||||
Important: the exclude_ids processing should occur prior to limiting output.
|
||||
"""
|
||||
|
||||
connection = http.client.HTTPSConnection('api.themoviedb.org')
|
||||
connection.request("GET", "/3/movie/{0}/credits?api_key={1}&language=en-US".format(movie_id, self.api_key))
|
||||
response = connection.getresponse()
|
||||
if response.status == 200:
|
||||
data = response.read()
|
||||
decoded_data = json.loads(data.decode('UTF-8'))
|
||||
cast = decoded_data['cast']
|
||||
if exclude_ids is not None:
|
||||
cast = [i for i in cast if i['id'] not in exclude_ids]
|
||||
print(cast)
|
||||
if limit is not None:
|
||||
cast = [i for i in cast if i['order'] < limit]
|
||||
print(cast)
|
||||
for c in cast:
|
||||
c['name'] = c['name'].replace(',', '')
|
||||
return cast
|
||||
else:
|
||||
print(response.status.__str__())
|
||||
return None
|
||||
|
||||
def get_movie_credits_for_person(self, person_id:str, vote_avg_threshold:float=None)->list:
|
||||
"""
|
||||
Using the TMDb API, get the movie credits for a person serving in a cast role
|
||||
documentation url: https://developers.themoviedb.org/3/people/get-person-movie-credits
|
||||
|
||||
:param string person_id: the id of a person
|
||||
:param vote_avg_threshold: optional parameter to return the movie credit if it is >=
|
||||
the specified threshold.
|
||||
e.g., if the vote_avg_threshold is 5.0, then only return credits with a vote_avg >= 5.0
|
||||
:rtype: list
|
||||
return a list of dicts, one dict per movie credit with the following structure:
|
||||
[{'id': '97909' # the id of the movie credit
|
||||
'title': 'Long, Stock and Two Smoking Barrels' # the title (not original title) of the credit
|
||||
'vote_avg': 5.0 # the float value of the vote average value for the credit}, ... ]
|
||||
"""
|
||||
|
||||
connection = http.client.HTTPSConnection('api.themoviedb.org')
|
||||
connection.request("GET", "/3/person/{0}/movie_credits?api_key={1}&language=en-US".format(person_id, self.api_key))
|
||||
response = connection.getresponse()
|
||||
if response.status == 200:
|
||||
data = response.read()
|
||||
decoded_data = json.loads(data.decode('UTF-8'))
|
||||
raw_credits = decoded_data['cast']
|
||||
if vote_avg_threshold is not None:
|
||||
filtered_credits = [{"id":idx["id"], "title":idx["title"], "vote_avg":idx["vote_average"]} for idx in raw_credits if idx["vote_average"] >= vote_avg_threshold]
|
||||
print(filtered_credits)
|
||||
return filtered_credits
|
||||
else:
|
||||
unfiltered_credits = [{"id":idx["id"], "title":idx["title"], "vote_avg":idx["vote_average"]} for idx in raw_credits]
|
||||
print(unfiltered_credits)
|
||||
return unfiltered_credits
|
||||
else:
|
||||
print("ERROR: " + response.status.__str__())
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#############################################################################################################################
|
||||
#
|
||||
# BUILDING YOUR GRAPH
|
||||
#
|
||||
# Working with the API: See use of http.request: https://docs.python.org/3/library/http.client.html#examples
|
||||
#
|
||||
# Using TMDb's API, build a co-actor network for the actor's/actress' highest rated movies
|
||||
# In this graph, each node represents an actor
|
||||
# An edge between any two nodes indicates that the two actors/actresses acted in a movie together
|
||||
# i.e., they share a movie credit.
|
||||
# e.g., An edge between Samuel L. Jackson and Robert Downey Jr. indicates that they have acted in one
|
||||
# or more movies together.
|
||||
#
|
||||
# For this assignment, we are interested in a co-actor network of highly rated movies; specifically,
|
||||
# we only want the top 3 co-actors in each movie credit of an actor having a vote average >= 8.0.
|
||||
# Build your co-actor graph on the actor 'Laurence Fishburne' w/ person_id 2975.
|
||||
#
|
||||
# You will need to add extra functions or code to accomplish this. We will not directly call or explicitly grade your
|
||||
# algorithm. We will instead measure the correctness of your output by evaluating the data in your argo-lite graph
|
||||
# snapshot.
|
||||
#
|
||||
# GRAPH SIZE
|
||||
# With each iteration of your graph build, the number of nodes and edges grows approximately at an exponential rate.
|
||||
# Our testing indicates growth approximately equal to e^2x.
|
||||
# Since the TMDB API is a live database, the number of nodes / edges in the final graph will vary slightly depending on when
|
||||
# you execute your graph building code. We take this into account by rebuilding the solution graph every few days and
|
||||
# updating the auto-grader. We establish a bound for lowest & highest encountered numbers of nodes and edges with a
|
||||
# margin of +/- 100 for nodes and +/- 150 for edges. e.g., The allowable range of nodes is set to:
|
||||
#
|
||||
# Min allowable nodes = min encountered nodes - 100
|
||||
# Max allowable nodes = max allowable nodes + 100
|
||||
#
|
||||
# e.g., if the minimum encountered nodes = 507 and the max encountered nodes = 526, then the min/max range is 407-626
|
||||
# The same method is used to calculate the edges with the exception of using the aforementioned edge margin.
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
# BEGIN BUILD CO-ACTOR NETWORK
|
||||
#
|
||||
# INITIALIZE GRAPH
|
||||
# Initialize a Graph object with a single node representing Laurence Fishburne
|
||||
#
|
||||
# BEGIN BUILD BASE GRAPH:
|
||||
# Find all of Laurence Fishburne's movie credits that have a vote average >= 8.0
|
||||
# FOR each movie credit:
|
||||
# | get the movie cast members having an 'order' value between 0-2 (these are the co-actors)
|
||||
# |
|
||||
# | FOR each movie cast member:
|
||||
# | | using graph.add_node(), add the movie cast member as a node (keep track of all new nodes added to the graph)
|
||||
# | | using graph.add_edge(), add an edge between the Laurence Fishburne (actress) node
|
||||
# | | and each new node (co-actor/co-actress)
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END BUILD BASE GRAPH
|
||||
#
|
||||
#
|
||||
# BEGIN LOOP - DO 2 TIMES:
|
||||
# IF first iteration of loop:
|
||||
# | nodes = The nodes added in the BUILD BASE GRAPH (this excludes the original node of Laurence Fishburne!)
|
||||
# ELSE
|
||||
# | nodes = The nodes added in the previous iteration:
|
||||
# ENDIF
|
||||
#
|
||||
# FOR each node in nodes:
|
||||
# | get the movie credits for the actor that have a vote average >= 8.0
|
||||
# |
|
||||
# | FOR each movie credit:
|
||||
# | | try to get the 3 movie cast members having an 'order' value between 0-2
|
||||
# | |
|
||||
# | | FOR each movie cast member:
|
||||
# | | | IF the node doesn't already exist:
|
||||
# | | | | add the node to the graph (track all new nodes added to the graph)
|
||||
# | | | ENDIF
|
||||
# | | |
|
||||
# | | | IF the edge does not exist:
|
||||
# | | | | add an edge between the node (actor) and the new node (co-actor/co-actress)
|
||||
# | | | ENDIF
|
||||
# | | END FOR
|
||||
# | END FOR
|
||||
# END FOR
|
||||
# END LOOP
|
||||
#
|
||||
# Your graph should not have any duplicate edges or nodes
|
||||
# Write out your finished graph as a nodes file and an edges file using:
|
||||
# graph.write_edges_file()
|
||||
# graph.write_nodes_file()
|
||||
#
|
||||
# END BUILD CO-ACTOR NETWORK
|
||||
# ----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# Exception handling and best practices
|
||||
# - You should use the param 'language=en-US' in all API calls to avoid encoding issues when writing data to file.
|
||||
# - If the actor name has a comma char ',' it should be removed to prevent extra columns from being inserted into the .csv file
|
||||
# - Some movie_credits may actually be collections and do not return cast data. Handle this situation by skipping these instances.
|
||||
# - While The TMDb API does not have a rate-limiting scheme in place, consider that making hundreds / thousands of calls
|
||||
# can occasionally result in timeout errors. If you continue to experience 'ConnectionRefusedError : [Errno 61] Connection refused',
|
||||
# - wait a while and then try again. It may be necessary to insert periodic sleeps when you are building your graph.
|
||||
|
||||
|
||||
def return_name()->str:
|
||||
"""
|
||||
Return a string containing your GT Username
|
||||
e.g., gburdell3
|
||||
Do not return your 9 digit GTId
|
||||
"""
|
||||
return "kobrien43"
|
||||
|
||||
|
||||
def return_argo_lite_snapshot()->str:
|
||||
"""
|
||||
Return the shared URL of your published graph in Argo-Lite
|
||||
"""
|
||||
return "https://poloclub.github.io/argo-graph-lite/#1ac32aec-ba9f-4693-83e1-cd4a7e81fb93"
|
||||
|
||||
|
||||
# You should modify __main__ as you see fit to build/test your graph using the TMDBAPIUtils & Graph classes.
|
||||
# Some boilerplate/sample code is provided for demonstration. We will not call __main__ during grading.
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
# init graph object with a single node representing laurence fishburne
|
||||
graph = Graph()
|
||||
graph.add_node(id='2975', name='Laurence Fishburne')
|
||||
|
||||
# build base graph
|
||||
# find all laurence fishburne's movie credits with a vote average >= 8.0
|
||||
tmdb_api_utils = TMDBAPIUtils(api_key='25166b54e76c7ad3aaa306abdfecb190')
|
||||
movie_credits = tmdb_api_utils.get_movie_credits_for_person(person_id='2975', vote_avg_threshold=8.0)
|
||||
print(len(movie_credits))
|
||||
print(movie_credits)
|
||||
|
||||
# for each movie credit get movie cast members having and order value between 0-2 (3 0-base)
|
||||
for movie in movie_credits:
|
||||
movie_cast = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for cast_member in movie_cast:
|
||||
graph.add_node(str(cast_member['id']), cast_member['name'])
|
||||
graph.add_edge(source='2975', target=str(cast_member['id']))
|
||||
|
||||
for i in range(2):
|
||||
if i == 0:
|
||||
current_nodes = graph.nodes[1:]
|
||||
else:
|
||||
current_nodes = [i for i in graph.nodes if i not in current_nodes]
|
||||
|
||||
for node in current_nodes:
|
||||
cast = tmdb_api_utils.get_movie_credits_for_person(person_id=node[0], vote_avg_threshold=8.0)
|
||||
for movie in cast:
|
||||
actors = tmdb_api_utils.get_movie_cast(movie_id=movie['id'], limit=3)
|
||||
for actor in actors:
|
||||
graph.add_node(str(actor['id']), actor['name'])
|
||||
graph.add_edge(str(node[0]), str(actor['id']))
|
||||
|
||||
|
||||
|
||||
# tmdb_api_utils.get_movie_cast(movie_id='100', limit=3, exclude_ids=[973, 974])
|
||||
# tmdb_api_utils.get_movie_credits_for_person(person_id="9709", vote_avg_threshold=5.0)
|
||||
|
||||
# call functions or place code here to build graph (graph building code not graded)
|
||||
# Suggestion: code should contain steps outlined above in BUILD CO-ACTOR NETWORK
|
||||
|
||||
print("Edges: " + str(graph.total_edges()))
|
||||
print("Nodes: " + str(graph.total_nodes()))
|
||||
|
||||
graph.write_edges_file()
|
||||
graph.write_nodes_file()
|
||||
|
||||
# If you have already built & written out your graph, you could read in your nodes & edges files
|
||||
# to perform testing on your graph.
|
||||
graph = Graph(with_edges_file="edges.csv", with_nodes_file="nodes.csv")
|
||||
|
||||
#get non-leaf nodes
|
||||
non_leaf = graph.non_leaf_nodes()
|
||||
print(non_leaf - 10)
|
||||
print("DONE")
|
Reference in New Issue
Block a user