102 lines
3.9 KiB
Plaintext
102 lines
3.9 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"id": "45bdce35",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "ModuleNotFoundError",
|
|
"evalue": "No module named 'sklearn'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[2], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;21;01msklearn\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdatasets\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m fetch_openml\n\u001b[1;32m 3\u001b[0m mushroom \u001b[38;5;241m=\u001b[39m fetch_openml(data_id\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m43922\u001b[39m, as_frame\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[1;32m 5\u001b[0m X \u001b[38;5;241m=\u001b[39m mushroom\u001b[38;5;241m.\u001b[39mdata\n",
|
|
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'sklearn'"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"from sklearn.datasets import fetch_openml\n",
|
|
"\n",
|
|
"mushroom = fetch_openml(data_id=43922, as_frame=True)\n",
|
|
"\n",
|
|
"X = mushroom.data\n",
|
|
"y = mushroom.target\n",
|
|
"\n",
|
|
"print(\"Feature data:\", X.shape)\n",
|
|
"print(\"Target data:\", y.shape)\n",
|
|
"display(X.head())\n",
|
|
"display(y.head())\n",
|
|
"print(y.value_counts())"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"id": "69e1a254",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"ename": "NameError",
|
|
"evalue": "name 'X' is not defined",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
|
"Cell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mMissing cells:\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[43mX\u001b[49m\u001b[38;5;241m.\u001b[39misna()\u001b[38;5;241m.\u001b[39msum()\u001b[38;5;241m.\u001b[39msum())\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mRows with missing cells:\u001b[39m\u001b[38;5;124m\"\u001b[39m, X\u001b[38;5;241m.\u001b[39misna()\u001b[38;5;241m.\u001b[39many(axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\u001b[38;5;241m.\u001b[39msum())\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(X[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstalk_root\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m.\u001b[39mvalue_counts(dropna\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m))\n",
|
|
"\u001b[0;31mNameError\u001b[0m: name 'X' is not defined"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"print(\"Missing cells:\", X.isna().sum().sum())\n",
|
|
"print(\"Rows with missing cells:\", X.isna().any(axis=1).sum())\n",
|
|
"print(X[\"stalk_root\"].value_counts(dropna=False))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"id": "a3459b1e",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"hello\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"a = \"hello\"\n",
|
|
"print(a)"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv (3.9.6)",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"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.9.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|