<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.
X=df.drop('koi_disposition', axis=1)
y=df['koi_disposition']<jupyter_output><empty_output><jupyter_text>Create a Train Test SplitUse `koi_disposition` for the y values<jupyter_code>from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42, stratify=y)
X_train.head()<jupyter_output><empty_output><jupyter_text>Pre-processingScale the data using the MinMaxScaler and perform some feature selection<jupyter_code># Scale your data
X_scaler = MinMaxScaler().fit(X_train)
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)<jupyter_output><empty_output><jupyter_text>Train the Model<jupyter_code>from sklearn.svm import SVC
model2 = SVC(kernel='rbf')
model2.fit(X_train_scaled, y_train)
print(f"Training Data Score: {model2.score(X_train_scaled, y_train)}")
print(f"Testing Data Score: {model2.score(X_test_scaled, y_test)}")<jupyter_output>Training Data Score: 0.8340644669082586
Testing Data Score: 0.8375286041189931<jupyter_text>Hyperparameter TuningUse `GridSearchCV` to tune the model's parameters<jupyter_code># Create the GridSearchCV model
from sklearn.model_selection import GridSearchCV
param_grid = {'C': [1, 10, 100, 1000],
             'gamma': [.0001, 0.001, 0.01, 0.1]}
grid = GridSearchCV(model2, param_grid, verbose=3)
grid.fit(X_train_scaled, y_train)
# Train the model with GridSearch
print(grid.best_params_)
print(grid.best_score_)<jupyter_output>{'C': 1000, 'gamma': 0.1}
0.8888037680378986<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 = 'svc.sav'
joblib.dump(grid, filename)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10589754627636677, 'fraction_numerical': 0.0383125269048644, 'mean_word_length': 7.704119850187266, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '463006', 'license': 'Apache-2.0', 'n_tokens_mistral': 901, 'n_tokens_neox': 833, 'n_words': 202, 'path': 'starter_code/model_2.ipynb', 'repo_name': 'rbourdeau1/machine-learning-challenge', 'size': '2323'}