Skip to content

Instantly share code, notes, and snippets.

@nickinack
Created November 20, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickinack/3c253518d652c20d96e0cc18923a569e to your computer and use it in GitHub Desktop.
Save nickinack/3c253518d652c20d96e0cc18923a569e to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": 3
},
"orig_nbformat": 2
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def fitness_func(chromosome):\n",
" columns = []\n",
" for i in range(len(x_train.columns)):\n",
" if i in chromosome:\n",
" columns.append(x_train.columns[i])\n",
" dist.append(columns)\n",
" training_set = x_train[columns]\n",
" print(training_set)\n",
" test_set = x_test[columns]\n",
" lg = LinearRegression().fit(training_set.values, y_train.values)\n",
" preds = lg.predict(test_set.values)\n",
" return 100 / np.sqrt(mean_squared_error(y_test.values, preds))\n",
" "
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment