<jupyter_start><jupyter_text>Read the CSV and Perform Basic Data Cleaning<jupyter_code>df = pd.read_csv("exoplanet_data.csv")
# Drop the null columns where all values are null
df = df.dropna(axis='columns', how='all')
# Drop the null rows
df = df.dropna()
df.head()<jupyter_output><empty_output><jupyter_text>Select your features (columns)<jupyter_code># Set features. This will also be used as your x values.
selected_features = df[['koi_period', 'koi_time0bk', 'koi_impact', 'koi_duration', 'koi_depth', 'koi_prad','koi_teq','koi_insol',
                        'koi_model_snr','koi_steff','koi_slogg','koi_srad','ra', 'dec','koi_kepmag']]<jupyter_output><empty_output><jupyter_text>Create a Train Test SplitUse `koi_disposition` for the y values<jupyter_code># Assign X (data) and y (target)
X=selected_features
y = df["koi_disposition"]
print(X.shape, y.shape)
#Training the model
from sklearn.model_selection import train_test_split


X_train, X_test, y_train, y_test = train_test_split(
    X, y, random_state=1)

X_train.head()<jupyter_output><empty_output><jupyter_text>Pre-processingScale the data using the MinMaxScaler and perform some feature selection<jupyter_code>from sklearn.preprocessing import LabelEncoder, MinMaxScaler
from tensorflow.keras.utils import to_categorical
X_scaler = MinMaxScaler().fit(X_train)
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)
X_train_scaled.shape<jupyter_output><empty_output><jupyter_text>Hyperparameter TuningUse `GridSearchCV` to tune the model's parameters<jupyter_code># Support vector machine linear classifier
from sklearn.svm import SVC 
model = SVC(kernel='linear')
model.fit(X_train_scaled, y_train)
# Model Accuracy
print('Test Acc: %.3f' % model.score(X_test, y_test))
# Create the GridSearchCV model
from sklearn.model_selection import GridSearchCV
param_grid = {"C":[1,5,10], "gamma": [0.0001,0.001,0.01]}
grid = GridSearchCV(model,param_grid, verbose = 3)

# Train the model with GridSearch

grid.fit(X_train_scaled, y_train)

print(grid.best_params_)
print(grid.best_score_)<jupyter_output>{'C': 10, 'gamma': 0.0001}
0.6234976604399682<jupyter_text>Save the Model<jupyter_code># save your model by updating "your_name" with your name
# and "your_model" with your model variable
# be sure to turn this in to BCS
# if joblib fails to import, try running the command to install in terminal/git-bash

import joblib
filename = 'meri.sav'
joblib.dump(model, filename)

# filename = 'Model_Grid.h5'
# joblib.dump(Model_Grid.h5, filename)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11301636788776305, 'fraction_numerical': 0.017926734216679657, 'mean_word_length': 7.072327044025157, 'pattern_counts': {'":': 2, '<': 24, '<?xml version=': 0, '>': 24, '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': '522794', 'license': 'RSA-MD', 'n_tokens_mistral': 964, 'n_tokens_neox': 923, 'n_words': 216, 'path': 'code/model_gridsearch.ipynb', 'repo_name': 'MerianeFranco/machine-learning-challenge', 'size': '2566'}