|
| 1 | +# Author/ Learner: Nguyen Truong Thinh |
| 2 | +# Contact me: [email protected] || +84393280504 |
| 3 | +# |
| 4 | +# Use case: Create a Logistic Regression model that can be used to convert into |
| 5 | +# the Core ML Format via CoreML Tool . |
| 6 | +# The model will be trained & converted on the popular UCI ML Pima Indians Diabetes dataset. |
| 7 | + |
| 8 | +import coremltools |
| 9 | + |
| 10 | +from usecases.tabular_classifier.logistic_regression.logistic_regression_classifier import trained_model |
| 11 | + |
| 12 | +coreml_model = coremltools.converters.sklearn.convert(trained_model, ['Pregnancies', 'Glucose', |
| 13 | + 'BloodPressure', 'SkinThickness', 'Insulin', |
| 14 | + 'BMI', 'DiabetesPedigreeFunction', 'Age'], |
| 15 | + 'Outcome') |
| 16 | + |
| 17 | +coreml_model.author = 'Nguyen Truong Thinh' |
| 18 | +coreml_model.short_description = 'A logistic regression model trained on the Kaggle.com version of th Pima Indians ' \ |
| 19 | + 'diabetes dataset.' |
| 20 | +# Features description |
| 21 | +coreml_model.input_description['Pregnancies'] = 'Number of pregnancies.' |
| 22 | +coreml_model.input_description['Glucose'] = 'Plasma glucose concentration after 2 hours in an oral glucose tolerance ' \ |
| 23 | + 'test.' |
| 24 | +coreml_model.input_description['BloodPressure'] = 'Diastolic blood pressure.' |
| 25 | +coreml_model.input_description['SkinThickness'] = 'Thickness of the triceps skin folds.' |
| 26 | +coreml_model.input_description['BMI'] = 'Body mass index.' |
| 27 | +coreml_model.input_description[ |
| 28 | + 'DiabetesPedigreeFunction'] = 'A function that determines the risk of diabetes based on family history.' |
| 29 | +coreml_model.input_description['Age'] = 'The age of the subject.' |
| 30 | +# Description of target variable |
| 31 | +coreml_model.output_description['Outcome'] = 'A binary value, 1 indicates the patient has type-2 diabetes.' |
| 32 | +coreml_model.save('diabetes_indian.mlpackage') |
0 commit comments