Loading the Cora dataset and using black-box Wolfram machine learning to predict edges.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Content-type: application/vnd.wolfram.mathematica *) | |
(*** Wolfram Notebook File ***) | |
(* http://www.wolfram.com/nb *) | |
(* CreatedBy='Mathematica 12.3' *) | |
(*CacheID: 234*) | |
(* Internal cache information: | |
NotebookFileLineBreakTest | |
NotebookFileLineBreakTest | |
NotebookDataPosition[ 158, 7] | |
NotebookDataLength[ 22860, 588] | |
NotebookOptionsPosition[ 18927, 525] | |
NotebookOutlinePosition[ 19338, 542] | |
CellTagsIndexPosition[ 19295, 539] | |
WindowFrame->Normal*) | |
(* Beginning of Notebook Content *) | |
Notebook[{ | |
Cell[CellGroupData[{ | |
Cell["Cora", "Section", | |
CellChangeTimes->{{3.835244711362664*^9, | |
3.835244712051331*^9}},ExpressionUUID->"e50d87b7-751d-4d38-9bf8-\ | |
f18b65d38ac1"], | |
Cell[TextData[{ | |
"A straightforward ML example using Mathematica to learning connectivity in \ | |
the Cora dataset.\n", | |
ButtonBox["You can learn about the Cora dataset here.", | |
BaseStyle->"Hyperlink", | |
ButtonData->{ | |
URL["https://graphsandnetworks.com/the-cora-dataset/"], None}, | |
ButtonNote->"https://graphsandnetworks.com/the-cora-dataset/"] | |
}], "Text", | |
CellChangeTimes->{{3.840278942671349*^9, 3.8402790281281757`*^9}, { | |
3.840279071991165*^9, | |
3.8402790719917297`*^9}},ExpressionUUID->"70045339-7f7c-4f52-8d71-\ | |
cd614034dfdb"], | |
Cell[CellGroupData[{ | |
Cell["Data Setup", "Subsection", | |
CellChangeTimes->{{3.8352447268379517`*^9, | |
3.835244733373962*^9}},ExpressionUUID->"2c23c5d9-2640-4827-b0d2-\ | |
758d327ce1c5"], | |
Cell["\<\ | |
Download the two Cora files (Cora.cites and Cora.content) via the link above.\ | |
\ | |
\>", "Text", | |
CellChangeTimes->{{3.840279086484741*^9, | |
3.840279124409667*^9}},ExpressionUUID->"005772b6-3cef-4fdb-8b7c-\ | |
857dc3e95fb5"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
"basePath", " ", "=", " ", | |
"\"\</Users/swa/Library/Mobile \ | |
Documents/com~apple~CloudDocs/Lab/Graphs/Graph Analytics/cora\>\""}], | |
";"}]], "Input", | |
CellChangeTimes->{{3.835313369785378*^9, 3.83531337586771*^9}, { | |
3.840278899181736*^9, 3.84027892872694*^9}}, | |
CellLabel-> | |
"In[300]:=",ExpressionUUID->"e689a470-f5f6-4ec5-b37c-08e31d8e7a60"], | |
Cell["\<\ | |
The edges are contained in the TSV-formatted \ | |
\[OpenCurlyDoubleQuote]cora.cites\[CloseCurlyDoubleQuote] file:\ | |
\>", "Text", | |
CellChangeTimes->{{3.840279142153163*^9, | |
3.840279175599724*^9}},ExpressionUUID->"87e9404b-28af-4982-a096-\ | |
616e024df57c"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{"coraCites", " ", "=", " ", | |
RowBox[{"Import", "[", | |
RowBox[{ | |
RowBox[{"FileNameJoin", "[", | |
RowBox[{"{", | |
RowBox[{"basePath", ",", " ", "\"\<cora.cites\>\""}], "}"}], "]"}], | |
",", "\"\<TSV\>\""}], "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.835241918785122*^9, 3.835241955134404*^9}, { | |
3.835313361458379*^9, 3.835313389189355*^9}, {3.8353134617813463`*^9, | |
3.835313474983191*^9}}, | |
CellLabel-> | |
"In[301]:=",ExpressionUUID->"13163f66-7ef9-48b6-bcc5-e9f407b00dd9"], | |
Cell["A sample shows that the edges are just tuples:", "Text", | |
CellChangeTimes->{{3.840279184464767*^9, | |
3.840279201874585*^9}},ExpressionUUID->"30cf8561-946e-4070-82d6-\ | |
88d7a6c58e66"], | |
Cell[CellGroupData[{ | |
Cell[BoxData[ | |
RowBox[{"coraCites", "//", "Short"}]], "Input", | |
CellChangeTimes->{{3.835241979091977*^9, 3.83524198187146*^9}}, | |
CellLabel-> | |
"In[302]:=",ExpressionUUID->"95d1be26-63a4-42c0-9b79-cf151565585e"], | |
Cell[BoxData[ | |
TagBox[ | |
RowBox[{"{", | |
RowBox[{ | |
RowBox[{"{", | |
RowBox[{"35", ",", "1033"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"35", ",", "103482"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"35", ",", "103515"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"35", ",", "1050679"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"35", ",", "1103960"}], "}"}], ",", | |
RowBox[{"\[LeftSkeleton]", "5420", "\[RightSkeleton]"}], ",", | |
RowBox[{"{", | |
RowBox[{"853116", ",", "853155"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"853118", ",", "1140289"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"853155", ",", "853118"}], "}"}], ",", | |
RowBox[{"{", | |
RowBox[{"954315", ",", "1155073"}], "}"}]}], "}"}], | |
Short]], "Output", | |
CellChangeTimes->{3.8353212453706903`*^9, 3.835322219165339*^9, | |
3.840279179675748*^9}, | |
CellLabel-> | |
"Out[302]//Short=",ExpressionUUID->"bcdc104b-19f2-47f8-a1f2-ec51aa153410"] | |
}, Open ]], | |
Cell["\<\ | |
The node content sits in the \[OpenCurlyDoubleQuote]cora.content\ | |
\[CloseCurlyDoubleQuote] files and can be imported in a similar fashion:\ | |
\>", "Text", | |
CellChangeTimes->{{3.840279206979391*^9, | |
3.840279229020603*^9}},ExpressionUUID->"21ec914e-3025-4dbc-ac0f-\ | |
580dd6df028a"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{"coraContent", " ", "=", " ", | |
RowBox[{"Import", "[", | |
RowBox[{ | |
RowBox[{"FileNameJoin", "[", | |
RowBox[{"{", | |
RowBox[{"basePath", ",", " ", "\"\<cora.content\>\""}], "}"}], "]"}], | |
",", "\"\<TSV\>\""}], "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.8352419929647417`*^9, 3.835242008298353*^9}, { | |
3.835313485648366*^9, 3.8353134886812773`*^9}}, | |
CellLabel-> | |
"In[303]:=",ExpressionUUID->"69ad32ac-8e9b-4ad7-9eb0-f2849ccfbead"], | |
Cell["\<\ | |
The textual content is already encoded and the last entry represent the label \ | |
(of the encoded article)\ | |
\>", "Text", | |
CellChangeTimes->{{3.840279256691017*^9, | |
3.840279287468698*^9}},ExpressionUUID->"0ec1c063-af70-4267-a5de-\ | |
e508e5c19d1d"], | |
Cell[CellGroupData[{ | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{"coraContent", "[", | |
RowBox[{"[", "1", "]"}], "]"}], "//", "Short"}]], "Input", | |
CellChangeTimes->{{3.83524201207064*^9, 3.835242028493445*^9}}, | |
CellLabel-> | |
"In[304]:=",ExpressionUUID->"8f969764-78f9-46a3-bf1d-b407169cbca6"], | |
Cell[BoxData[ | |
TagBox[ | |
RowBox[{"{", | |
RowBox[{ | |
"31336", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", | |
"0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", | |
",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", | |
",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", | |
RowBox[{"\[LeftSkeleton]", "1379", "\[RightSkeleton]"}], ",", "0", ",", | |
"0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", | |
",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", ",", "0", | |
",", "0", ",", "0", ",", "0", ",", "0", ",", "1", ",", "0", ",", "0", ",", | |
"0", ",", "0", ",", "0", ",", "0", ",", "\<\"Neural_Networks\"\>"}], | |
"}"}], | |
Short]], "Output", | |
CellChangeTimes->{3.835321247064432*^9, 3.835322220959375*^9, | |
3.840279237303339*^9}, | |
CellLabel-> | |
"Out[304]//Short=",ExpressionUUID->"277092c4-c271-47fd-9d20-5af9e9fa6c1c"] | |
}, Open ]], | |
Cell["The graph from the edges is simply", "Text", | |
CellChangeTimes->{{3.835244917660832*^9, 3.8352449241663723`*^9}, { | |
3.840279297912177*^9, | |
3.840279305145192*^9}},ExpressionUUID->"2dd0f311-b29d-46ac-8c23-\ | |
91a347703ddc"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{"g", " ", "=", " ", | |
RowBox[{"Graph", "[", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"#", "[", | |
RowBox[{"[", "1", "]"}], "]"}], "->", | |
RowBox[{"#", "[", | |
RowBox[{"[", "2", "]"}], "]"}]}], "&"}], "/@", " ", "coraCites"}], | |
"]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.835244835295635*^9, 3.835244891560503*^9}}, | |
CellLabel->"In[6]:=",ExpressionUUID->"5c798afd-a94f-4f04-a716-0a588a4e66ad"] | |
}, Open ]], | |
Cell[CellGroupData[{ | |
Cell["Learning", "Subsection", | |
CellChangeTimes->{{3.835244825305636*^9, | |
3.8352448267855177`*^9}},ExpressionUUID->"45086ae9-994f-45ab-b7c9-\ | |
d0614cf52b37"], | |
Cell["This gets the content of a single node", "Text", | |
CellChangeTimes->{{3.8353135141231537`*^9, | |
3.8353135226443033`*^9}},ExpressionUUID->"529c2d82-f379-4378-b2f1-\ | |
bee13de3ce72"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"getContent", "[", "vertexId_", "]"}], ":=", | |
RowBox[{"Module", "[", | |
RowBox[{ | |
RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"found", " ", "=", " ", | |
RowBox[{"Select", "[", | |
RowBox[{"coraContent", ",", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"#", "[", | |
RowBox[{"[", "1", "]"}], "]"}], "==", "vertexId"}], "&"}]}], | |
"]"}]}], ";", "\[IndentingNewLine]", | |
RowBox[{"If", "[", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"Length", "[", "found", "]"}], "===", "0"}], ",", "None", | |
",", | |
RowBox[{"Drop", "[", | |
RowBox[{ | |
RowBox[{"found", "[", | |
RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "]"}]}], "]"}]}]}], | |
"\[IndentingNewLine]", "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.835270666403668*^9, 3.835270798676573*^9}}, | |
CellLabel->"In[7]:=",ExpressionUUID->"1709c9c5-66ae-4b38-8d48-a03fd434cdc6"], | |
Cell["In order to reduce dimensionality we\[CloseCurlyQuote]ll fetch a \ | |
reducer", "Text", | |
CellChangeTimes->{{3.83532079428675*^9, | |
3.8353208094244127`*^9}},ExpressionUUID->"46dce468-207e-4a39-bf5b-\ | |
8bd2c90ac43f"], | |
Cell[BoxData[{ | |
RowBox[{ | |
RowBox[{"sampleContent", " ", "=", | |
RowBox[{"getContent", " ", "/@", " ", | |
RowBox[{"RandomSample", "[", | |
RowBox[{ | |
RowBox[{"VertexList", "[", "g", "]"}], ",", " ", "1000"}], "]"}]}]}], | |
";"}], "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"reducer", " ", "=", " ", | |
RowBox[{"DimensionReduction", "[", "sampleContent", "]"}]}], | |
";"}], "\[IndentingNewLine]"}], "Input", | |
CellChangeTimes->{{3.835320570635035*^9, 3.835320602361497*^9}, { | |
3.8353206835306883`*^9, 3.835320756690742*^9}, 3.835320911444306*^9}, | |
CellLabel->"In[8]:=",ExpressionUUID->"4ba0f1a8-ea90-4cf9-a186-2ba68f28729f"], | |
Cell["\<\ | |
For a given tuple this will return one record combining the data contained in \ | |
the corresponding nodes\ | |
\>", "Text", | |
CellChangeTimes->{{3.835313536902627*^9, | |
3.835313564289261*^9}},ExpressionUUID->"7dab7b0e-bbb7-4043-9f0e-\ | |
196ca1e5323a"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"sampleRecord", "[", "couple_", "]"}], ":=", " ", | |
RowBox[{"Module", "[", | |
RowBox[{ | |
RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"rec1", " ", "=", | |
RowBox[{"reducer", "[", " ", | |
RowBox[{"getContent", "[", | |
RowBox[{"couple", "[", | |
RowBox[{"[", "1", "]"}], "]"}], "]"}], "]"}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"rec2", " ", "=", " ", | |
RowBox[{"reducer", "[", | |
RowBox[{"getContent", "[", | |
RowBox[{"couple", "[", | |
RowBox[{"[", "2", "]"}], "]"}], "]"}], "]"}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"Catenate", "[", | |
RowBox[{"{", | |
RowBox[{"rec1", ",", "rec2"}], "}"}], "]"}]}]}], | |
"\[IndentingNewLine]", "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.835245143749955*^9, 3.835245220769546*^9}, { | |
3.8352678879587173`*^9, 3.835267900298689*^9}, {3.8352679439285393`*^9, | |
3.835268017064815*^9}, {3.835268064532206*^9, 3.835268077389447*^9}, { | |
3.835268128532774*^9, 3.8352681326452227`*^9}, {3.835269936356524*^9, | |
3.835269976380426*^9}, {3.83527083441861*^9, 3.835270861315167*^9}, { | |
3.835320821407092*^9, 3.835320831683584*^9}, {3.8353218857475233`*^9, | |
3.835321893075775*^9}, 3.835322210691416*^9}, | |
CellLabel->"In[10]:=",ExpressionUUID->"7306d4c4-0c56-4ec7-ba3c-931b5262e410"], | |
Cell["Tells you whether the tuple represents an edge in the graph", "Text", | |
CellChangeTimes->{{3.835313570281711*^9, | |
3.835313585427693*^9}},ExpressionUUID->"50619aec-d7d1-4ccc-bb1c-\ | |
257a98832e12"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"areConnected", "[", "couple_", "]"}], ":=", | |
RowBox[{"MemberQ", "[", | |
RowBox[{ | |
RowBox[{"AdjacencyList", "[", | |
RowBox[{"g", ",", " ", | |
RowBox[{"couple", "[", | |
RowBox[{"[", "1", "]"}], "]"}]}], "]"}], ",", | |
RowBox[{"couple", "[", | |
RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.83526923354375*^9, 3.8352692926992807`*^9}}, | |
CellLabel->"In[11]:=",ExpressionUUID->"d1b587c5-35b9-440d-907f-b18c0b751c43"], | |
Cell["\<\ | |
Returns the specified amount of tuples, each tuple being an edge in the graph\ | |
\ | |
\>", "Text", | |
CellChangeTimes->{{3.835313592491695*^9, | |
3.835313632071947*^9}},ExpressionUUID->"1ac7cbd1-efa7-4e92-8d17-\ | |
843ab554a214"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"sampleConnectedIds", "[", | |
RowBox[{"amount_Integer", ":", "100"}], "]"}], ":=", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"{", | |
RowBox[{ | |
RowBox[{"#", "[", | |
RowBox[{"[", "1", "]"}], "]"}], ",", | |
RowBox[{"#", "[", | |
RowBox[{"[", "2", "]"}], "]"}]}], "}"}], "&"}], "/@", " ", | |
RowBox[{"RandomChoice", "[", | |
RowBox[{ | |
RowBox[{"EdgeList", "[", "g", "]"}], ",", "amount"}], "]"}]}]}], | |
";"}]], "Input", | |
CellChangeTimes->{{3.835269422532752*^9, 3.835269522120784*^9}, { | |
3.835269560319724*^9, 3.835269591648279*^9}}, | |
CellLabel->"In[12]:=",ExpressionUUID->"762fd7c0-8736-440e-b908-abb2b947e7be"], | |
Cell["The same for disconnected nodes", "Text", | |
CellChangeTimes->{{3.8353136368334*^9, | |
3.835313646362722*^9}},ExpressionUUID->"ac00f167-55fb-4737-a7f7-\ | |
dea2c3f61378"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"sampleDisconnectedIds", "[", | |
RowBox[{"amount_Integer", ":", "100"}], "]"}], ":=", | |
RowBox[{"Module", "[", | |
RowBox[{ | |
RowBox[{"{", | |
RowBox[{"couple", ",", "found"}], "}"}], ",", "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"found", "=", | |
RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", | |
RowBox[{"While", "[", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"Length", "[", "found", "]"}], "<", "amount"}], ",", | |
"\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"couple", "=", | |
RowBox[{"RandomChoice", "[", | |
RowBox[{ | |
RowBox[{"VertexList", "[", "g", "]"}], ",", "2"}], "]"}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"If", "[", | |
RowBox[{ | |
RowBox[{"areConnected", "[", "couple", "]"}], ",", ",", | |
RowBox[{"AppendTo", "[", | |
RowBox[{"found", ",", " ", "couple"}], "]"}]}], "]"}], ";"}]}], | |
"\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", "found"}]}], | |
"\[IndentingNewLine]", "]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.835269564929947*^9, 3.835269617514697*^9}, { | |
3.835269709339705*^9, 3.835269842968732*^9}}, | |
CellLabel->"In[13]:=",ExpressionUUID->"129a9505-6104-45ca-b69b-3176cd38ba4e"], | |
Cell["\<\ | |
Finally, this samples data suitable for machine learning. The binary \ | |
classification corresponds to a 1 if there is an edge for the combined data \ | |
and 0 otherwise\ | |
\>", "Text", | |
CellChangeTimes->{{3.835313652591679*^9, | |
3.835313728515477*^9}},ExpressionUUID->"4586f4fb-3388-4a4b-af7f-\ | |
bdea69972749"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"sample", "[", "amount_", "]"}], ":=", | |
RowBox[{"Module", "[", | |
RowBox[{ | |
RowBox[{"{", | |
RowBox[{ | |
"positiveCount", ",", "negativeCount", ",", "negativeCouples", ",", | |
"positiveCouples", ",", "positives", ",", "negatives"}], "}"}], ",", | |
"\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"positiveCount", " ", "=", " ", | |
RowBox[{"Floor", "[", | |
RowBox[{"amount", "/", "2"}], "]"}]}], ";", "\[IndentingNewLine]", | |
RowBox[{"negativeCount", " ", "=", " ", | |
RowBox[{"amount", "-", "positiveCount"}]}], ";", "\[IndentingNewLine]", | |
RowBox[{"negativeCouples", " ", "=", " ", | |
RowBox[{"sampleDisconnectedIds", "[", "negativeCount", "]"}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"positiveCouples", " ", "=", " ", | |
RowBox[{"sampleConnectedIds", "[", "positiveCount", "]"}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"positives", " ", "=", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"#", "->", "1"}], "&"}], "/@", | |
RowBox[{"(", " ", | |
RowBox[{"sampleRecord", "/@", "positiveCouples"}], ")"}]}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"negatives", " ", "=", | |
RowBox[{ | |
RowBox[{ | |
RowBox[{"#", "->", "0"}], "&"}], "/@", | |
RowBox[{"(", " ", | |
RowBox[{"sampleRecord", "/@", "negativeCouples"}], ")"}]}]}], ";", | |
"\[IndentingNewLine]", | |
RowBox[{"RandomSample", "[", | |
RowBox[{ | |
RowBox[{"Catenate", "[", | |
RowBox[{"{", | |
RowBox[{"positives", ",", " ", "negatives"}], "}"}], "]"}], ",", | |
"amount"}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",\ | |
CellChangeTimes->{{3.835270111049645*^9, 3.835270135948462*^9}, { | |
3.835270168479568*^9, 3.8352703002447567`*^9}, {3.835270358863873*^9, | |
3.8352704274332113`*^9}, {3.835270881783421*^9, 3.835270882061245*^9}, { | |
3.835313231542742*^9, 3.835313239332418*^9}, {3.835321911185541*^9, | |
3.835321931207776*^9}}, | |
CellLabel->"In[14]:=",ExpressionUUID->"b902d8bc-ff29-4ee1-9add-be208e1e0919"], | |
Cell["\<\ | |
Sampling the train, test and validation data. Note that we ensured in the \ | |
sampling that there are as many positives as negatives.\ | |
\>", "Text", | |
CellChangeTimes->{{3.835313756349188*^9, | |
3.835313799528089*^9}},ExpressionUUID->"3dcaedf8-cc39-4e70-9270-\ | |
da1d689a09a2"], | |
Cell[BoxData[{ | |
RowBox[{ | |
RowBox[{"trainData", "=", | |
RowBox[{"sample", "[", "3000", "]"}]}], ";"}], "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"validationData", " ", "=", " ", | |
RowBox[{"sample", "[", "300", "]"}]}], ";"}], "\[IndentingNewLine]", | |
RowBox[{ | |
RowBox[{"testData", " ", "=", " ", | |
RowBox[{"sample", "[", "500", "]"}]}], | |
";"}], "\[IndentingNewLine]"}], "Input", | |
CellChangeTimes->{{3.835270945631131*^9, 3.835271004584528*^9}, { | |
3.835313282973976*^9, 3.8353132948502207`*^9}, {3.835320250478181*^9, | |
3.835320261297968*^9}, {3.835321451305562*^9, 3.8353214613618727`*^9}, { | |
3.8353220844839373`*^9, 3.835322103234531*^9}}, | |
CellLabel->"In[15]:=",ExpressionUUID->"accec531-1dcf-446f-8548-67257b49b013"], | |
Cell[BoxData[ | |
RowBox[{ | |
RowBox[{"cl", " ", "=", " ", | |
RowBox[{"Classify", "[", | |
RowBox[{"trainData", ",", | |
RowBox[{"ValidationSet", "\[Rule]", " ", "validationData"}], ",", " ", | |
RowBox[{"PerformanceGoal", "\[Rule]", "\"\<TrainingSpeed\>\""}], ",", | |
" ", | |
RowBox[{ | |
"TrainingProgressReporting", "\[Rule]", "\"\<ProgressIndicator\>\""}]}], | |
"]"}]}], ";"}]], "Input", | |
CellChangeTimes->{{3.8352710094789047`*^9, 3.835271064862146*^9}, { | |
3.835313872163392*^9, 3.835313880071866*^9}, {3.835313924110414*^9, | |
3.8353139246276093`*^9}}, | |
CellLabel->"In[18]:=",ExpressionUUID->"1f6e58ca-2b1f-4a03-b1fc-2c5054ab2147"], | |
Cell[CellGroupData[{ | |
Cell[BoxData[ | |
RowBox[{"ClassifierMeasurements", "[", | |
RowBox[{"cl", ",", "testData", ",", "\"\<Accuracy\>\""}], "]"}]], "Input", | |
CellChangeTimes->{{3.835271126015388*^9, 3.8352711372365637`*^9}}, | |
CellLabel->"In[19]:=",ExpressionUUID->"d12cf1a3-2483-4fe7-8083-cef417ceff0e"], | |
Cell[BoxData["0.662`"], "Output", | |
CellChangeTimes->{3.835321439668338*^9, 3.83532364502763*^9}, | |
CellLabel->"Out[19]=",ExpressionUUID->"af8f84eb-a2ac-4e85-a4b8-27ac5a6853f8"] | |
}, Open ]] | |
}, Open ]] | |
}, Open ]] | |
}, | |
WindowSize->{1227, 1134}, | |
WindowMargins->{{Automatic, 73}, {Automatic, 66}}, | |
DockedCells->{}, | |
FrontEndVersion->"12.3 for Mac OS X x86 (64-bit) (July 9, 2021)", | |
StyleDefinitions->"Default.nb", | |
ExpressionUUID->"9013506f-e450-4a96-93f8-8a31eff00491" | |
] | |
(* End of Notebook Content *) | |
(* Internal cache information *) | |
(*CellTagsOutline | |
CellTagsIndex->{} | |
*) | |
(*CellTagsIndex | |
CellTagsIndex->{} | |
*) | |
(*NotebookFileOutline | |
Notebook[{ | |
Cell[CellGroupData[{ | |
Cell[580, 22, 149, 3, 67, "Section",ExpressionUUID->"e50d87b7-751d-4d38-9bf8-f18b65d38ac1"], | |
Cell[732, 27, 538, 12, 58, "Text",ExpressionUUID->"70045339-7f7c-4f52-8d71-cd614034dfdb"], | |
Cell[CellGroupData[{ | |
Cell[1295, 43, 160, 3, 54, "Subsection",ExpressionUUID->"2c23c5d9-2640-4827-b0d2-758d327ce1c5"], | |
Cell[1458, 48, 229, 6, 35, "Text",ExpressionUUID->"005772b6-3cef-4fdb-8b7c-857dc3e95fb5"], | |
Cell[1690, 56, 386, 10, 30, "Input",ExpressionUUID->"e689a470-f5f6-4ec5-b37c-08e31d8e7a60"], | |
Cell[2079, 68, 260, 6, 35, "Text",ExpressionUUID->"87e9404b-28af-4982-a096-616e024df57c"], | |
Cell[2342, 76, 535, 13, 30, "Input",ExpressionUUID->"13163f66-7ef9-48b6-bcc5-e9f407b00dd9"], | |
Cell[2880, 91, 188, 3, 35, "Text",ExpressionUUID->"30cf8561-946e-4070-82d6-88d7a6c58e66"], | |
Cell[CellGroupData[{ | |
Cell[3093, 98, 210, 4, 30, "Input",ExpressionUUID->"95d1be26-63a4-42c0-9b79-cf151565585e"], | |
Cell[3306, 104, 943, 27, 67, "Output",ExpressionUUID->"bcdc104b-19f2-47f8-a1f2-ec51aa153410"] | |
}, Open ]], | |
Cell[4264, 134, 288, 6, 35, "Text",ExpressionUUID->"21ec914e-3025-4dbc-ac0f-580dd6df028a"], | |
Cell[4555, 142, 492, 12, 30, "Input",ExpressionUUID->"69ad32ac-8e9b-4ad7-9eb0-f2849ccfbead"], | |
Cell[5050, 156, 254, 6, 35, "Text",ExpressionUUID->"0ec1c063-af70-4267-a5de-e508e5c19d1d"], | |
Cell[CellGroupData[{ | |
Cell[5329, 166, 264, 6, 30, "Input",ExpressionUUID->"8f969764-78f9-46a3-bf1d-b407169cbca6"], | |
Cell[5596, 174, 949, 18, 67, "Output",ExpressionUUID->"277092c4-c271-47fd-9d20-5af9e9fa6c1c"] | |
}, Open ]], | |
Cell[6560, 195, 227, 4, 35, "Text",ExpressionUUID->"2dd0f311-b29d-46ac-8c23-91a347703ddc"], | |
Cell[6790, 201, 471, 13, 30, "Input",ExpressionUUID->"5c798afd-a94f-4f04-a716-0a588a4e66ad"] | |
}, Open ]], | |
Cell[CellGroupData[{ | |
Cell[7298, 219, 158, 3, 54, "Subsection",ExpressionUUID->"45086ae9-994f-45ab-b7c9-d0614cf52b37"], | |
Cell[7459, 224, 184, 3, 35, "Text",ExpressionUUID->"529c2d82-f379-4378-b2f1-bee13de3ce72"], | |
Cell[7646, 229, 996, 27, 94, "Input",ExpressionUUID->"1709c9c5-66ae-4b38-8d48-a03fd434cdc6"], | |
Cell[8645, 258, 217, 4, 35, "Text",ExpressionUUID->"46dce468-207e-4a39-bf5b-8bd2c90ac43f"], | |
Cell[8865, 264, 635, 14, 73, "Input",ExpressionUUID->"4ba0f1a8-ea90-4cf9-a186-2ba68f28729f"], | |
Cell[9503, 280, 253, 6, 35, "Text",ExpressionUUID->"7dab7b0e-bbb7-4043-9f0e-196ca1e5323a"], | |
Cell[9759, 288, 1400, 31, 115, "Input",ExpressionUUID->"7306d4c4-0c56-4ec7-ba3c-931b5262e410"], | |
Cell[11162, 321, 201, 3, 35, "Text",ExpressionUUID->"50619aec-d7d1-4ccc-bb1c-257a98832e12"], | |
Cell[11366, 326, 525, 13, 30, "Input",ExpressionUUID->"d1b587c5-35b9-440d-907f-b18c0b751c43"], | |
Cell[11894, 341, 229, 6, 35, "Text",ExpressionUUID->"1ac7cbd1-efa7-4e92-8d17-843ab554a214"], | |
Cell[12126, 349, 689, 19, 30, "Input",ExpressionUUID->"762fd7c0-8736-440e-b908-abb2b947e7be"], | |
Cell[12818, 370, 171, 3, 35, "Text",ExpressionUUID->"ac00f167-55fb-4737-a7f7-dea2c3f61378"], | |
Cell[12992, 375, 1312, 32, 178, "Input",ExpressionUUID->"129a9505-6104-45ca-b69b-3176cd38ba4e"], | |
Cell[14307, 409, 314, 7, 35, "Text",ExpressionUUID->"4586f4fb-3388-4a4b-af7f-bdea69972749"], | |
Cell[14624, 418, 2111, 49, 199, "Input",ExpressionUUID->"b902d8bc-ff29-4ee1-9add-be208e1e0919"], | |
Cell[16738, 469, 281, 6, 35, "Text",ExpressionUUID->"3dcaedf8-cc39-4e70-9270-da1d689a09a2"], | |
Cell[17022, 477, 732, 15, 94, "Input",ExpressionUUID->"accec531-1dcf-446f-8548-67257b49b013"], | |
Cell[17757, 494, 649, 14, 30, "Input",ExpressionUUID->"1f6e58ca-2b1f-4a03-b1fc-2c5054ab2147"], | |
Cell[CellGroupData[{ | |
Cell[18431, 512, 278, 4, 30, "Input",ExpressionUUID->"d12cf1a3-2483-4fe7-8083-cef417ceff0e"], | |
Cell[18712, 518, 175, 2, 34, "Output",ExpressionUUID->"af8f84eb-a2ac-4e85-a4b8-27ac5a6853f8"] | |
}, Open ]] | |
}, Open ]] | |
}, Open ]] | |
} | |
] | |
*) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment