Soccer players, BMI, and birthday

Acquire data

Data was acquired from SOFIFA.com via the Python scraping program “soccer players.py”.

Extract only relevant data

SetDirectory[NotebookDirectory[]];

data=Import["soccer data.csv"];

Position[data[[1]],"Birthdate"]

birthdates=ToExpression[Table[StringSplit[StringReplace[data[[i,27]],{"("->"",")"->"",","->"","Jan"->"1","Feb"->"2","Mar"->"3","Apr"->"4","May"->"5","Jun"->"6","Jul"->"7","Aug"->"8","Sep"->"9","Oct"->"10","Nov"->"11","Dec"->"12"}],"/"],{i,2,Length[data]}]];

InputForm[birthdates[[1;;10]]]

heights=ToExpression[StringSplit[data[[2;;All,28]],"'"]];

weights=ToExpression[StringReplace[data[[2;;All,29]],"lbs"->""]];

Length[heights]

InputForm[heights[[-1]]]

InputForm[weights[[-1]]]

(*lambdaPis=(Entity["λ Piscium", Entity["Star","LambdaPiscium"], "Entity[\"Star\", \"LambdaPiscium\"]", "star"]);*)

(*firstaries=UnitConvert[StarData[lambdaPis,EntityProperty["Star","RightAscension",{"Date"->Now}]],"Degrees"]*)

birthdates[[1,{3,1,2}]]

Calculate Tropical sun degrees and signs

sundegrees=Round[QuantityMagnitude[Table[(*Mod[*)UnitConvert[SunPosition[(Entity["London", Entity["City",{"London","GreaterLondon","UnitedKingdom"}], "Entity[\"City\", {\"London\", \"GreaterLondon\", \"UnitedKingdom\"}]", "city"]),Join[birthdates[[i,{3,1,2}]],{12,0,0}],CelestialSystem->"Equatorial"][[1]],"Degrees"](*,Quantity[360,"Degrees"]]*),{i,1,Length[birthdates]}]]];

sundegrees=Import["sundegrees.m"];

(*cusplist={};
For[i=1,i≤Length[sundegrees],i++,
If[sundegrees[[i]]==0||sundegrees[[i]]==30||sundegrees[[i]]==60||sundegrees[[i]]==90||sundegrees[[i]]==120||sundegrees[[i]]==150||sundegrees[[i]]==180||sundegrees[[i]]==210||sundegrees[[i]]==240||sundegrees[[i]]==270||sundegrees[[i]]==300||sundegrees[[i]]==330||sundegrees[[i]]==360,AppendTo[cusplist,i]]];*)

(*cusplist*)

sunsigns=ConstantArray[0,Length[sundegrees]];
For[i=1,i≤Length[sundegrees],i++,
If[sundegrees[[i]]>0&&sundegrees[[i]]<30,sunsigns[[i]]=1];
If[sundegrees[[i]]>30&&sundegrees[[i]]<60,sunsigns[[i]]=2];
If[sundegrees[[i]]>60&&sundegrees[[i]]<90,sunsigns[[i]]=3];
If[sundegrees[[i]]>90&&sundegrees[[i]]<120,sunsigns[[i]]=4];
If[sundegrees[[i]]>120&&sundegrees[[i]]<150,sunsigns[[i]]=5];
If[sundegrees[[i]]>150&&sundegrees[[i]]<180,sunsigns[[i]]=6];
If[sundegrees[[i]]>180&&sundegrees[[i]]<210,sunsigns[[i]]=7];
If[sundegrees[[i]]>210&&sundegrees[[i]]<240,sunsigns[[i]]=8];
If[sundegrees[[i]]>240&&sundegrees[[i]]<270,sunsigns[[i]]=9];
If[sundegrees[[i]]>270&&sundegrees[[i]]<300,sunsigns[[i]]=10];
If[sundegrees[[i]]>300&&sundegrees[[i]]<330,sunsigns[[i]]=11];
If[sundegrees[[i]]>330&&sundegrees[[i]]<360,sunsigns[[i]]=12];];

remove=Position[sunsigns,0];

Length[remove]

Remove players with sun sign on cusp

editedsunsigns=Delete[sunsigns,remove];

editedheights=Delete[heights,remove];

editedweights=Delete[weights,remove];

Just heights

editedheightinches=Table[editedheights[[i,1]]*12+editedheights[[i,2]],{i,1,Length[editedheights]}];

analysisdata=Transpose[{editedsunsigns,editedheightinches}];

Length[analysisdata]

gathereddata=SortBy[GatherBy[analysisdata,First],First];

Box Whisker Chart

plotdata=Table[gathereddata[[i]][[All,2]],{i,1,12}];

BoxWhiskerChart[plotdata]

BoxWhiskerChart[plotdata,(*{"Diamond",{"MeanDiamond",1,Pink}},"*)"Notched",BarOrigin->Left]

{Histogram[plotdata,Automatic,"PDF"],SmoothHistogram[plotdata]}

analysisdata

LocationEquivalenceTest[plotdata]

ANOVA

Needs["ANOVA`"]

ANOVA[analysisdata,PostTests->Bonferroni]

Just weights

analysisdata=Transpose[{editedsunsigns,editedweights}];

Length[analysisdata]

gathereddata=SortBy[GatherBy[analysisdata,First],First];

Box Whisker Chart

plotdata=Table[gathereddata[[i]][[All,2]],{i,1,12}];

BoxWhiskerChart[plotdata]

BoxWhiskerChart[plotdata,{"Diamond",{"MeanDiamond",1,Pink}},BarOrigin->Left]

plotdata

analysisdata

LocationEquivalenceTest[plotdata]

ANOVA

Needs["ANOVA`"]

ANOVA[analysisdata,PostTests->Bonferroni]

Calculate BMI from https://www.cdc.gov/healthyweight/assessing/bmi/adult_bmi/index.html#InterpretedAdults

Formula: weight (lb) / [height (in)]^2 x 703
Calculate BMI by dividing weight in pounds (lbs) by height in inches (in) squared and multiplying by a conversion factor of 703.

Example: Weight = 150 lbs, Height = 5’5″ (65″)
Calculation: [150 ÷ (65)^2] x 703 = 24.96

editedheightinches=Table[editedheights[[i,1]]*12+editedheights[[i,2]],{i,1,Length[editedheights]}];

bmi=N[Table[(editedweights[[i]]/(editedheightinches[[i]]^2))*703,{i,1,Length[editedweights]}]];

analysisdata=Transpose[{editedsunsigns,bmi}];

Length[analysisdata]

gathereddata=SortBy[GatherBy[analysisdata,First],First];

Box Whisker Chart

plotdata=Table[gathereddata[[i]][[All,2]],{i,1,12}];

BoxWhiskerChart[plotdata]

BoxWhiskerChart[plotdata,{"Diamond",{"MeanDiamond",1,Pink}},BarOrigin->Left,ChartLabels->{"Aries","Taurus","Gemini","Cancer","Leo","Virgo","Libra","Scorpio","Sagittarius","Capricorn","Aquarius","Pisces"},ChartLabels->"BMI for soccer players with different Sun signs"]

ANOVA

Needs["ANOVA`"]

ANOVA[analysisdata,PostTests->Bonferroni]

Neural net to recognize faces as sun signs

Position[data[[1]],"Photo"]

imageURLs=data[[2;;All,5]]

i

images=Table[Import[imageURLs[[i]]],{i,1,Length[imageURLs]}];

images=Import["images.m"];

remove2=Position[Table[ImageQ[images[[i]]],{i,1,Length[images]}],False];

remove3=Union[remove,remove2];

(*Export["images.m",images]*)

editedimages=Delete[images,remove3];

editedsunsigns3=Delete[sunsigns,remove3];

netdata=Table[editedimages[[i]]->editedsunsigns3[[i]],{i,1,Length[editedimages]}];

testindices=RandomSample[Range[Length[netdata]],Round[0.2*Length[netdata]]];

trainindices=Complement[Range[Length[netdata]],testindices];

c=Classify[netdata[[trainindices]],PerformanceGoal->"Quality",TargetDevice->"GPU"];

ClassifierMeasurements[c,netdata[[testindices]], "ConfusionMatrixPlot"]

Length[remove3]

ClassifierMeasurements[c,netdata[[testindices]], "AccuracyRejectionPlot"]

ClassifierMeasurements[c,netdata[[testindices]], "Accuracy"]

trainingNet=NetGraph[<|"lenet"->lenet,"loss"->CrossEntropyLossLayer["Index"]|>,
{NetPort["Input"]->"lenet"->NetPort["loss","Input"],NetPort["Target"]->NetPort["loss","Target"]}]

mnistEncoder=NetEncoder[{"Image",{48,48},"ColorSpace"->"CMYK"}]

mnistDecoder=NetDecoder[{"Class",Range[1,12]}]

uninitializedLenet=NetChain[{ConvolutionLayer[20,5],ElementwiseLayer[Ramp],PoolingLayer[2,2],ConvolutionLayer[50,5],ElementwiseLayer[Ramp],PoolingLayer[2,2],FlattenLayer[],LinearLayer[500],ElementwiseLayer[Ramp],LinearLayer[12],SoftmaxLayer[]},"Input"->mnistEncoder,"Output"->mnistDecoder]

lenet=NetInitialize[uninitializedLenet]

Length[testindices]

trainedlenet=NetTrain[(*NetModel["LeNet"]*)lenet,netdata[[trainindices]],ValidationSet->netdata[[testindices[[1;;2500]]]],MaxTrainingRounds->100,TargetDevice->"GPU"]

measurements=ClassifierMeasurements[trainedlenet,netdata[[testindices[[2501;;All]]]]]

measurements["Accuracy"]

measurements["ConfusionMatrixPlot"]

measurements["AccuracyRejectionPlot"]

Repeat everything but use  Sidereal placements

Calculate Tropical sun degrees and signs

(*Export["sundegrees.m",sundegrees]*)

sundegrees=Import["sundegrees.m"];

sidsundegrees=Round[Mod[sundegrees-23.7,360]];

(*cusplist={};
For[i=1,i≤Length[sundegrees],i++,
If[sundegrees[[i]]==0||sundegrees[[i]]==30||sundegrees[[i]]==60||sundegrees[[i]]==90||sundegrees[[i]]==120||sundegrees[[i]]==150||sundegrees[[i]]==180||sundegrees[[i]]==210||sundegrees[[i]]==240||sundegrees[[i]]==270||sundegrees[[i]]==300||sundegrees[[i]]==330||sundegrees[[i]]==360,AppendTo[cusplist,i]]];*)

(*cusplist*)

{13,38,47}

sidsunsigns=ConstantArray[0,Length[sidsundegrees]];
For[i=1,i≤Length[sidsundegrees],i++,
If[sidsundegrees[[i]]>0&&sidsundegrees[[i]]<30,sidsunsigns[[i]]=1];
If[sidsundegrees[[i]]>30&&sidsundegrees[[i]]<60,sidsunsigns[[i]]=2];
If[sidsundegrees[[i]]>60&&sidsundegrees[[i]]<90,sidsunsigns[[i]]=3];
If[sidsundegrees[[i]]>90&&sidsundegrees[[i]]<120,sidsunsigns[[i]]=4];
If[sidsundegrees[[i]]>120&&sidsundegrees[[i]]<150,sidsunsigns[[i]]=5];
If[sidsundegrees[[i]]>150&&sidsundegrees[[i]]<180,sidsunsigns[[i]]=6];
If[sidsundegrees[[i]]>180&&sidsundegrees[[i]]<210,sidsunsigns[[i]]=7];
If[sidsundegrees[[i]]>210&&sidsundegrees[[i]]<240,sidsunsigns[[i]]=8];
If[sidsundegrees[[i]]>240&&sidsundegrees[[i]]<270,sidsunsigns[[i]]=9];
If[sidsundegrees[[i]]>270&&sidsundegrees[[i]]<300,sidsunsigns[[i]]=10];
If[sidsundegrees[[i]]>300&&sidsundegrees[[i]]<330,sidsunsigns[[i]]=11];
If[sidsundegrees[[i]]>330&&sidsundegrees[[i]]<360,sidsunsigns[[i]]=12];];

remove=Position[sidsunsigns,0];

Length[remove]

Remove players with sun sign on cusp

editedsunsigns=Delete[sidsunsigns,remove]

editedheights=Delete[heights,remove]

editedweights=Delete[weights,remove]

Calculate BMI from https://www.cdc.gov/healthyweight/assessing/bmi/adult_bmi/index.html#InterpretedAdults

Formula: weight (lb) / [height (in)]^2 x 703
Calculate BMI by dividing weight in pounds (lbs) by height in inches (in) squared and multiplying by a conversion factor of 703.

Example: Weight = 150 lbs, Height = 5’5″ (65″)
Calculation: [150 ÷ (65)^2] x 703 = 24.96

editedheightinches=Table[editedheights[[i,1]]*12+editedheights[[i,2]],{i,1,Length[editedheights]}];

bmi=N[Table[(editedweights[[i]]/(editedheightinches[[i]]^2))*703,{i,1,Length[editedweights]}]];

analysisdata=Transpose[{editedsunsigns,bmi}];

Length[analysisdata]

gathereddata=SortBy[GatherBy[analysisdata,First],First];

Box Whisker Chart

plotdata=Table[gathereddata[[i]][[All,2]],{i,1,12}];

BoxWhiskerChart[plotdata]

BoxWhiskerChart[plotdata,{"Diamond",{"MeanDiamond",1,Pink}},BarOrigin->Right]

ANOVA

Needs["ANOVA`"]

ANOVA[analysisdata,PostTests->Bonferroni]

Neural net to recognize faces as sun signs

Position[data[[1]],"Photo"]

imageURLs=data[[2;;All,5]]

i

images=Table[Import[imageURLs[[i]]],{i,1,Length[imageURLs]}];

images=Import["images.m"];

remove2=Position[Table[ImageQ[images[[i]]],{i,1,Length[images]}],False];

Length[remove2]

remove3=Union[remove,remove2];

(*Export["images.m",images]*)

Length[remove3]

ColorConvert[images[[1]],"RGB"]

editedimages=Delete[images,remove3];

Table[Export["\\soccerpics\\"<>ToString[i]<>".jpg",ColorConvert[editedimages[[i]],"RGB"]],{i,1,Length[editedimages]}];

editedimages3=Table[ColorConvert[editedimages[[i]],"RGB"],{i,1,Length[editedimages]}]

Length[editedimages]

editedsidsunsigns3=Delete[sidsunsigns,remove3];

i

netdata=Table[Import["\soccerpics\\"<>ToString[i]<>".jpg"]->editedsidsunsigns3[[i]],{i,1,Length[editedimages]}];

ClearAll[images,editedimages]

Union[Values[netdata]]

testindices=RandomSample[Range[Length[netdata]],Round[0.2*Length[netdata]]];

trainindices=Complement[Range[Length[netdata]],testindices];

Length[testindices]

train=netdata[[trainindices]];

validation=netdata[[trainindices[[1;;2000]]]];

c=Classify[train,TargetDevice->"GPU",ValidationSet->validation, PerformanceGoal->"Quality"];

ClassifierMeasurements[c,netdata[[testindices[[2001;;All]]]], "ConfusionMatrixPlot"]

ClassifierMeasurements[c,netdata[[testindices[[2001;;All]]]], "Accuracy"]

c

ImageDimensions[editedimages[[1]]]

Length[remove3]

ImageData[editedimages[[1]]]

mnistEncoder=NetEncoder[{"Image",{48,48},"ColorSpace"->"RGB"}]

mnistDecoder=NetDecoder[{"Class",Range[1,12]}]

uninitializedLenet=NetChain[{ConvolutionLayer[20,5],ElementwiseLayer[Ramp],PoolingLayer[5,5],ConvolutionLayer[100,5],ElementwiseLayer[Ramp],PoolingLayer[4,4],FlattenLayer[],LinearLayer[500],ElementwiseLayer[Ramp],LinearLayer[12],SoftmaxLayer[]},"Input"->mnistEncoder,"Output"->mnistDecoder]

lenet=NetInitialize[uninitializedLenet]

Length[testindices]

trainedlenet=NetTrain[(*NetModel["LeNet"]*)lenet,train,ValidationSet->netdata[[trainindices[[1;;2000]]]],BatchSize->500,MaxTrainingRounds->2000,TargetDevice->"GPU"]

Internal`$LastInternalFailure

measurements=ClassifierMeasurements[trainedlenet,netdata[[testindices[[2001;;All]]]]]

measurements["Accuracy"]

measurements["ConfusionMatrixPlot"]

N[191/Length[netdata[[testindices[[1001;;All]]]]]]

measurements["TruePositiveExamples"]

Length[testindices]