<jupyter_start><jupyter_text><jupyter_code>!pip install -U coremltools
import pandas as pd
adver = pd.read_csv("/content/drive/My Drive/Colab Notebooks/Advertising.csv", usecols=[1, 2, 3, 4])
adver.head()
X, y = adver.iloc[:, :-1], adver.iloc[:, -1]<jupyter_output><empty_output><jupyter_text>**Splitting Data for ML**<jupyter_code>import sklearn.model_selection as ms
X_train, X_test, y_train, y_test = ms.train_test_split(X, y, test_size=0.25, random_state=42)<jupyter_output><empty_output><jupyter_text>**Creating Linear Regression Model**<jupyter_code>import sklearn.linear_model as lm
regr = lm.LinearRegression()
regr.fit(X_train, y_train)
regr.score(X_test, y_test)<jupyter_output><empty_output><jupyter_text>**Predict sales for new input values**<jupyter_code>X_new = [[ 50.0, 150.0, 150.0],
         [250.0,  50.0,  50.0],
         [100.0, 125.0, 125.0]]
regr.predict(X_new)<jupyter_output><empty_output><jupyter_text>**Training and Validating a Support Vector Machine Model**<jupyter_code>import sklearn.svm as svm
svr = svm.LinearSVR(random_state=42)
svr.fit(X_train, y_train)
svr.score(X_test, y_test)
svr.predict(X_new)<jupyter_output><empty_output><jupyter_text>**CoreML Tool and Convertion of ML Models**<jupyter_code>import coremltools
adver.columns
input_features = ['TV', 'radio', 'newspaper']
output_feature = 'sales'
coreml_model = coremltools.converters.sklearn.convert(regr, input_features, output_feature)
coreml_model.save('/content/drive/My Drive/Colab Notebooks/Advertising.mlmodel')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1410006497725796, 'fraction_numerical': 0.029889538661468484, 'mean_word_length': 7.651685393258427, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '371274', 'license': 'MIT', 'n_tokens_mistral': 646, 'n_tokens_neox': 605, 'n_words': 102, 'path': 'Advertising_iOS_CoreML.ipynb', 'repo_name': 'chiru92/Practice-of-CoreML', 'size': '1539'}