This page allows you to use machine learning on a dataset and then show predictions.
Data analysis |
Training
The following outlines the training of a wellness dataset which gives the top results:
- Female life expectancy (Training: Deaths all ages, All mortality among 15-44 year olds, Early deaths from CHD (<75)). Go!
- Female life expectancy (Training: Male life expectancy, Deaths all ages, Deaths from alcohol conditions). Go!
- Female life expectancy (Training: Deaths all ages, Deaths from alcohol conditions, Patients with a psychiatric hospitalisation). Go!
- Female life expectancy (Training: Deaths all ages, Deaths from alcohol conditions, Child obesity in primary). Go!
- Female life expectancy (Training: Deaths all ages, Deaths from alcohol conditions, Immunisation uptake at 24 months-5 in 1). Go!
- Female life expectancy (Training: Deaths all ages, People claiming pension credits (aged 60+), Immunisation uptake at 24 months-5 in 1). Go!
- Female life expectancy (Training: Early deaths from cancer (<75), Patients with emergency hospitalisations, People claiming pension credits (aged 60+)). Go!
- Female life expectancy (Training: New cancer registrations, People claiming pension credits (aged 60+), Pop growth (2005-2015)). Go!
- Male life expectancy (Training: Deaths all ages, Deaths from alcohol conditions, Working age population employment deprived). Go!
- Male life expectancy (Training: Deaths from alcohol conditions, Crime rate, Population within 500 metres of a derelict site). Go!
- Male life expectancy (Training: All mortality among 15-44 year olds, People claiming pension credits (aged 60+), Crime rate). Go!
- Male life expectancy (Training: All mortality among 15-44 year olds, People claiming pension credits (aged 60+), Immunisation uptake at 24 months-MMR). Go!
- Male life expectancy (Training: Early deaths from cancer (<75), Deaths from alcohol conditions, Young people not in employment education/training). Go!
- Deaths all ages (Training: Male life expectancy, Children Living in Poverty, Child dental health in primary 1). Go!
- Deaths all ages (Training: Male life expectancy, Population within 500 metres of a derelict site, Child obesity in primary). Go!
- Deaths all ages (Training: Female life expectancy, Early deaths from cancer (<75), Child dental health in primary 1). Go!
- Deaths all ages (Training: Female life expectancy, Children looked after by local authority, Working age adults with low/no educational qual). Go!
- Deaths all ages (Training: Early deaths from CHD (<75), Population within 500 metres of a derelict site, Child dental health in primary 1). Go!
- Deaths all ages (Training: People claiming pension credits (aged 60+), Domestic Abuse, Child dental health in primary 1). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Active travel to work, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Patients (65+) with multiple emergency hospitalisations, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Population prescribed drugs for anxiety/depression/psychosis, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Single adult dwellings, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Prisoner population, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Referrals Childrens Reporter-violence-related off, Child obesity in primary). Go!
- All mortality among 15-44 year olds (Training: Early deaths from CHD (<75), Child obesity in primary, Bowel screening uptake). Go!
- Early deaths from CHD (<75) (Training: All mortality among 15-44 year olds, Estimated smoking attributable deaths, Referrals Childrens Reporter-violence-related off). Go!
- Early deaths from CHD (<75) (Training: All mortality among 15-44 year olds, Population income deprived, Child dental health in primary 1). Go!
- Early deaths from CHD (<75) (Training: Female life expectancy, All mortality among 15-44 year olds, Patients hospitalised with (COPD)). Go!
- Early deaths from CHD (<75) (Training: Female life expectancy, All mortality among 15-44 year olds, Deaths from suicide). Go!
- Early deaths from CHD (<75) (Training: Female life expectancy, All mortality among 15-44 year olds, Adults incapacity benefit/severe disability allow/employment allow). Go!
- Early deaths from cancer (<75) (Training: Deaths all ages, Estimated smoking attributable deaths, Referrals Childrens Reporter-violence-related off). Go!
- Early deaths from cancer (<75) (Training: Deaths all ages, Secondary school attendance, Crime rate). Go!
- Early deaths from cancer (<75) (Training: Deaths all ages, Young people not in employment education/training, Breast screening uptake). Go!
- Early deaths from cancer (<75) (Training: Deaths all ages, Drug crimes recorded, Breast screening uptake). Go!
- Early deaths from cancer (<75) (Training: All mortality among 15-44 year olds, Estimated smoking attributable deaths, Crime rate). Go!
- Early deaths from cancer (<75) (Training: All mortality among 15-44 year olds, People aged 65+ with high care needs cared at home, Domestic Abuse). Go!
- Early deaths from cancer (<75) (Training: All mortality among 15-44 year olds, People living in 15% most access deprived areas, Teenage pregnancies). Go!
- Early deaths from cancer (<75) (Training: Estimated smoking attributable deaths, People aged 65+ with high care needs cared at home, Child dental health in primary 1). Go!
- Early deaths from cancer (<75) (Training: Estimated smoking attributable deaths, Single adult dwellings, Child dental health in primary 1). Go!
- Early deaths from cancer (<75) (Training: Deaths from alcohol conditions, New cancer registrations, Adults incapacity benefit/severe disability allow/employment allow). Go!
- Early deaths from cancer (<75) (Training: Road traffic accident casualties, Teenage pregnancies, Child dental health in primary 1). Go!
- Early deaths from cancer (<75) (Training: Adults incapacity benefit/severe disability allow/employment allow, Secondary school attendance, Bowel screening uptake). Go!
- Early deaths from cancer (<75) (Training: Adults incapacity benefit/severe disability allow/employment allow, Violent crimes recorded, Child dental health in primary 1). Go!
- Early deaths from cancer (<75) (Training: Average tariff score of all pupils on S4 roll, Teenage pregnancies, Child dental health in primary 1). Go!
- Estimated smoking attributable deaths (Training: Deaths all ages, New cancer registrations, Patients hospitalised with asthma). Go!
- Estimated smoking attributable deaths (Training: Deaths all ages, New cancer registrations, Patients with emergency hospitalisations). Go!
- Estimated smoking attributable deaths (Training: Deaths all ages, New cancer registrations, Adults incapacity benefit/severe disability allow/employment allow). Go!
- Estimated smoking attributable deaths (Training: Deaths all ages, New cancer registrations, Population within 500 metres of a derelict site). Go!
- Estimated smoking attributable deaths (Training: Deaths all ages, Patients hospitalised with asthma, Average tariff score of all pupils on S4 roll). Go!
- Estimated smoking attributable deaths (Training: Early deaths from cancer (<75), Smoking prevalence (adults 16+), Bowel screening uptake). Go!
- Estimated smoking attributable deaths (Training: Smoking prevalence (adults 16+), Working age adults with low/no educational qual, Bowel screening uptake). Go!
- Smoking prevalence (adults 16+) (Training: All mortality among 15-44 year olds, Drug crimes recorded, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Early deaths from CHD (<75), Patients with emergency hospitalisations, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Early deaths from CHD (<75), Drug crimes recorded, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Active travel to work, Patients (65+) with multiple emergency hospitalisations). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Patients hospitalised with (COPD), Road traffic accident casualties). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Patients hospitalised with (COPD), Working age adults with low/no educational qual). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Patients with emergency hospitalisations, Patients (65+) with multiple emergency hospitalisations). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Patients (65+) with multiple emergency hospitalisations, People aged 65+ with high care needs cared at home). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Deaths from suicide, Working age adults with low/no educational qual). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Deaths from suicide, Breast screening uptake). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, People claiming pension credits (aged 60+), Child dental health in primary 7). Go!
- Smoking prevalence (adults 16+) (Training: Estimated smoking attributable deaths, Child dental health in primary 1, Breast screening uptake). Go!
- Smoking prevalence (adults 16+) (Training: Alcohol-related hospital stays, Patients hospitalised with coronary heart disease, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Alcohol-related hospital stays, Drug crimes recorded, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Drug-related hospital stays, Patients hospitalised with (COPD), Low birth weight). Go!
- Smoking prevalence (adults 16+) (Training: Drug-related hospital stays, Low birth weight, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: New cancer registrations, Population income deprived, Breast screening uptake). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with (COPD), Patients hospitalised with asthma, Violent crimes recorded). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with (COPD), Patients hospitalised with asthma, Low birth weight). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with (COPD), Road traffic accident casualties, Domestic Abuse). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with (COPD), Patients with a psychiatric hospitalisation, Children looked after by local authority). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with coronary heart disease, Mothers smoking during pregnancy, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with asthma, Children looked after by local authority, Referrals Childrens Reporter-violence-related off). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with asthma, Children looked after by local authority, Child dental health in primary 7). Go!
- Smoking prevalence (adults 16+) (Training: Patients hospitalised with asthma, Secondary school attendance, Working age adults with low/no educational qual). Go!
- Smoking prevalence (adults 16+) (Training: Adults incapacity benefit/severe disability allow/employment allow, Working age population claiming Out of Work benefits, Child dental health in primary 7). Go!
- Smoking prevalence (adults 16+) (Training: Adults incapacity benefit/severe disability allow/employment allow, Child dental health in primary 7, Immunisation uptake at 24 months-5 in 1). Go!
- Smoking prevalence (adults 16+) (Training: Children looked after by local authority, Referrals Childrens Reporter-violence-related off, Pop growth (2005-2015)). Go!
- Smoking prevalence (adults 16+) (Training: Children looked after by local authority, Population within 500 metres of a derelict site, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Population income deprived, Child dental health in primary 7, Immunisation uptake at 24 months-5 in 1). Go!
- Smoking prevalence (adults 16+) (Training: Population income deprived, Child dental health in primary 7, Immunisation uptake at 24 months-MMR). Go!
- Smoking prevalence (adults 16+) (Training: Working age population employment deprived, Child dental health in primary 7, Immunisation uptake at 24 months-5 in 1). Go!
- Smoking prevalence (adults 16+) (Training: Working age population claiming Out of Work benefits, Population within 500 metres of a derelict site, Child dental health in primary 7). Go!
- Smoking prevalence (adults 16+) (Training: Working age population claiming Out of Work benefits, Child dental health in primary 7, Breast screening uptake). Go!
- Smoking prevalence (adults 16+) (Training: Working age population claiming Out of Work benefits, Child dental health in primary 7, Immunisation uptake at 24 months-5 in 1). Go!
- Smoking prevalence (adults 16+) (Training: Drug crimes recorded, Mothers smoking during pregnancy, Child dental health in primary 1). Go!
- Smoking prevalence (adults 16+) (Training: Drug crimes recorded, Child dental health in primary 1, Immunisation uptake at 24 months-MMR). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients (65+) with multiple emergency hospitalisations, Bowel screening uptake). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients hospitalised with asthma, Patients (65+) with multiple emergency hospitalisations). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients (65+) with multiple emergency hospitalisations, Working age adults with low/no educational qual). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients (65+) with multiple emergency hospitalisations, Prisoner population). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients (65+) with multiple emergency hospitalisations, Referrals Childrens Reporter-violence-related off). Go!
- Alcohol-related hospital stays (Training: Male life expectancy, Patients (65+) with multiple emergency hospitalisations, Breast screening uptake). Go!
- Alcohol-related hospital stays (Training: Early deaths from cancer (<75), Deaths from alcohol conditions, Drug crimes recorded). Go!
- Alcohol-related hospital stays (Training: Deaths from alcohol conditions, Single adult dwellings, Primary school attendance). Go!
- Alcohol-related hospital stays (Training: Deaths from alcohol conditions, People claiming pension credits (aged 60+), Child dental health in primary 7). Go!
- Alcohol-related hospital stays (Training: Deaths from alcohol conditions, Prisoner population, Low birth weight). Go!
- Alcohol-related hospital stays (Training: Deaths from alcohol conditions, Prisoner population, Immunisation uptake at 24 months-MMR). Go!
- Deaths from alcohol conditions (Training: Alcohol-related hospital stays, Patients hospitalised with asthma, Breast screening uptake). Go!
- Deaths from alcohol conditions (Training: Alcohol-related hospital stays, Adults incapacity benefit/severe disability allow/employment allow, Violent crimes recorded). Go!
- Deaths from alcohol conditions (Training: Alcohol-related hospital stays, Working age population claiming Out of Work benefits, Violent crimes recorded). Go!
- Drug-related hospital stays (Training: Early deaths from cancer (<75), Patients with a psychiatric hospitalisation, Children looked after by local authority). Go!
- Drug-related hospital stays (Training: Patients with a psychiatric hospitalisation, Children looked after by local authority, Crime rate). Go!
- Drug-related hospital stays (Training: Patients with a psychiatric hospitalisation, Children looked after by local authority, Domestic Abuse). Go!
- Drug-related hospital stays (Training: Patients with a psychiatric hospitalisation, Children looked after by local authority, Child dental health in primary 1). Go!
- Drug-related hospital stays (Training: Patients with a psychiatric hospitalisation, Children looked after by local authority, Breast screening uptake). Go!
- Drug-related hospital stays (Training: Deaths from suicide, Children looked after by local authority, Young people not in employment education/training). Go!
- Drug-related hospital stays (Training: Children looked after by local authority, Young people not in employment education/training, Babies exclusively breastfed at 6-8 weeks). Go!
- Drug-related hospital stays (Training: Children looked after by local authority, Domestic Abuse, Mothers smoking during pregnancy). Go!
- Drug-related hospital stays (Training: Children looked after by local authority, Mothers smoking during pregnancy, Babies exclusively breastfed at 6-8 weeks). Go!
- Drug-related hospital stays (Training: Secondary school attendance, Population within 500 metres of a derelict site, Mothers smoking during pregnancy). Go!
- Active travel to work (Training: Prisoner population, Population within 500 metres of a derelict site, People living in 15% most access deprived areas). Go!
- Active travel to work (Training: Prisoner population, People living in 15% most access deprived areas, Teenage pregnancies). Go!
- Active travel to work (Training: Prisoner population, People living in 15% most access deprived areas, Low birth weight). Go!
- Active travel to work (Training: Prisoner population, People living in 15% most access deprived areas, Child dental health in primary 1). Go!
- Active travel to work (Training: Prisoner population, People living in 15% most access deprived areas, Child dental health in primary 7). Go!
- Active travel to work (Training: Referrals Childrens Reporter-violence-related off, Domestic Abuse, People living in 15% most access deprived areas). Go!
- Active travel to work (Training: Referrals Childrens Reporter-violence-related off, Violent crimes recorded, People living in 15% most access deprived areas). Go!
- Active travel to work (Training: Domestic Abuse, Violent crimes recorded, People living in 15% most access deprived areas). Go!
- Active travel to work (Training: Domestic Abuse, Drug crimes recorded, People living in 15% most access deprived areas). Go!
- Active travel to work (Training: Domestic Abuse, People living in 15% most access deprived areas, Adults rating neighbourhood as a very good place to live). Go!
- Active travel to work (Training: Violent crimes recorded, People living in 15% most access deprived areas, Low birth weight). Go!
- Active travel to work (Training: Drug crimes recorded, People living in 15% most access deprived areas, Adults rating neighbourhood as a very good place to live). Go!
- Active travel to work (Training: People living in 15% most access deprived areas, Teenage pregnancies, Child dental health in primary 7). Go!
- Active travel to work (Training: People living in 15% most access deprived areas, Mothers smoking during pregnancy, Low birth weight). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Male life expectancy, Young people not in employment education/training, Prisoner population). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Male life expectancy, Children Living in Poverty, Immunisation uptake at 24 months-5 in 1). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Deaths all ages, Children Living in Poverty, Low birth weight). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Smoking prevalence (adults 16+), Working age population claiming Out of Work benefits). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Patients hospitalised with coronary heart disease, Working age population claiming Out of Work benefits). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Secondary school attendance, Working age population employment deprived). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Working age population employment deprived, Drug crimes recorded). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Working age population claiming Out of Work benefits, People living in 15% most access deprived areas). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Working age population claiming Out of Work benefits, Child dental health in primary 1). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Working age population claiming Out of Work benefits, Bowel screening uptake). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Early deaths from cancer (<75), Working age population claiming Out of Work benefits, Immunisation uptake at 24 months-5 in 1). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Alcohol-related hospital stays, Working age population employment deprived, Violent crimes recorded). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Alcohol-related hospital stays, Working age population employment deprived, Drug crimes recorded). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Alcohol-related hospital stays, Working age population employment deprived, Breast screening uptake). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Alcohol-related hospital stays, Working age population claiming Out of Work benefits, Drug crimes recorded). Go!
- Adults incapacity benefit/severe disability allow/employment allow (Training: Alcohol-related hospital stays, Working age population claiming Out of Work benefits, Breast screening uptake). Go!
Coding
Here is the coding:
import numpy as np import pandas as pd import sys x1 = "Patients hospitalised with (COPD)" x2= "Patients hospitalised with asthma" x3= "Drug-related hospital stays" x4= "Deaths from alcohol conditions" fdata="well.csv" print "Training data:\t\t",x1,",",x2,",",x3 print "Training against:\t",x4 print "Data set:\t\t",fdata print "======================" ver=pd.read_csv(fdata) from sklearn.cross_validation import train_test_split from sklearn.ensemble import RandomForestRegressor type1= ver[x1].dtype type2= ver[x2].dtype type3= ver[x3].dtype type4= ver[x4].dtype if (type1==object or type2==object or type3==object or type4==object): print "One of the data values is an object" sys.exit(1) train, test, y_train, y_test = train_test_split(ver[[x1,x2,x3]],ver[x4],test_size=0.3, random_state=1) ind = ver.columns[0] model= RandomForestRegressor() model.fit(train,y_train) predictions =model.predict(ver[[x1,x2,x3]]) success=0 failure=0 r = float(float(ver[x4].max())-float(ver[x4].min())) print "Range of values:\t",r limit=r/5 print "Success limit:\t\t",limit print "==============================================\n" c=len(predictions) print ('%22s %8s %8s %8s %8s' % ("Index","Pred","Actual","Diff","Success")) print "=====================================================" for x in range(0,c): error = abs(predictions[x]-ver[x4][x]) if (error<=limit): str = "Success" success=success+1 else: str="Failed!" failure = failure+1 print('%22s %8.2f %8.2f %8.2f %8s' % (ver[ind][x][:22],predictions[x],ver[x4][x],error,str) ) print ('Success: %3d Fail: %3d' % (success,failure)) print "\n\n\nTraining data:" print train print "Training data (y):" print y_train