Skip to content

Commit

Permalink
add analyze ds market
Browse files Browse the repository at this point in the history
  • Loading branch information
khuyentran1401 committed Oct 24, 2021
2 parents e16ee94 + 8a1ab2c commit 880bd2f
Show file tree
Hide file tree
Showing 37 changed files with 5,209 additions and 1,499 deletions.
32 changes: 16 additions & 16 deletions data_science_tools/Datapane_new_features/iris_project.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"deepnote_cell_type": "code"
},
"source": "!pip install datapane",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -40,8 +40,8 @@
"deepnote_cell_type": "code"
},
"source": "from sklearn.datasets import load_iris\nimport plotly.express as px \nimport datapane as dp ",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -55,7 +55,6 @@
"deepnote_cell_type": "code"
},
"source": "import os\n\nTOKEN = os.environ[\"DATAPANE_TOKEN\"]\ndp.login(TOKEN)",
"execution_count": null,
"outputs": [
{
"name": "stdout",
Expand All @@ -70,7 +69,8 @@
},
"metadata": {}
}
]
],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -87,7 +87,6 @@
"deepnote_cell_type": "code"
},
"source": "X, y = load_iris(as_frame=True, return_X_y=True)\nX.head(10)",
"execution_count": null,
"outputs": [
{
"output_type": "execute_result",
Expand Down Expand Up @@ -429,7 +428,8 @@
},
"metadata": {}
}
]
],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -446,8 +446,8 @@
"deepnote_cell_type": "code"
},
"source": "fig = px.scatter(data_frame=X,\n x='sepal length (cm)',\n y='sepal width (cm)')",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -465,8 +465,8 @@
"deepnote_cell_type": "code"
},
"source": "table = dp.DataTable(X)\nplot = dp.Plot(fig)",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -479,8 +479,8 @@
"deepnote_cell_type": "code"
},
"source": "group = dp.Group(table, plot,\n columns=2)",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -493,14 +493,14 @@
"deepnote_cell_type": "code"
},
"source": "dp.Report(group).publish(name='Iris', description='Show Iris data')",
"execution_count": null,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": "Publishing report and associated data - please wait..\nReport successfully published at https://datapane.com/u/khuyentran1401/reports/iris/\n"
}
]
],
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down
32 changes: 15 additions & 17 deletions data_science_tools/Hyperdash.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"tags": [],
"cell_id": "00000-0d62bc9e-286e-448d-8d2b-486fa48f69e4",
"deepnote_cell_type": "markdown"
},
"outputs": [],
"execution_count": null
}
},
{
"cell_type": "markdown",
Expand All @@ -30,8 +28,8 @@
"deepnote_cell_type": "code"
},
"source": "!pip install --upgrade pip && pip install hyperdash",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -40,8 +38,8 @@
"deepnote_cell_type": "code"
},
"source": "!hd signup",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -50,8 +48,8 @@
"deepnote_cell_type": "code"
},
"source": "!hyperdash login",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -68,8 +66,8 @@
"deepnote_cell_type": "code"
},
"source": "import numpy as np \nimport pandas as pd \n\ndisease = pd.read_csv('heart.csv')\ndisease.describe()\n\n#Split the data into train and test set\nfrom sklearn.model_selection import train_test_split\n\ntrain, test = train_test_split(disease, test_size = 0.2, random_state = 1)\n\nX_train = train.drop(['target','fbs'],axis=1)\ny_train = train['target']\n\nX_test = train.drop(['target','fbs'],axis=1)\ny_test = train['target']",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
Expand All @@ -78,8 +76,8 @@
"deepnote_cell_type": "code"
},
"source": "from hyperdash import Experiment\nfrom sklearn.linear_model import SGDClassifier\nfrom sklearn.model_selection import cross_val_predict\nfrom sklearn.metrics import confusion_matrix\n\n#Declare your Experiment object each run\nexp = Experiment('SGDClassifier')\n\n#Record the value of the hyperparameter alpha\nalpha = exp.param('alpha', 0.01)\n\nsgd_model = SGDClassifier(random_state=1, alpha = alpha)\nsgd_model.fit(X_train, y_train)\n\n#Evaluate with cross validation score\nfrom sklearn.model_selection import cross_val_score\n\nscore = cross_val_score(sgd_model, X_train, y_train).mean()\nexp.metric('Accuracy', score)\n\n#Evaluate with confusion matrix\n\nsgd_predictions = cross_val_predict(sgd_model, X_train, y_train)\ntn, fp, fn, tp = confusion_matrix(y_train, sgd_predictions).ravel()\n\nexp.metric('True Negative', tn)\nexp.metric('False Positive', fp)\nexp.metric('False Negative', fn)\nexp.metric('True Positive', tp) \n\nexp.end()\n",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -96,8 +94,8 @@
"deepnote_cell_type": "code"
},
"source": "from sklearn.ensemble import RandomForestClassifier\nfrom sklearn import metrics\nfrom hyperdash import monitor\n\n@monitor('RandomForestClassifier')\ndef random_forest(exp):\n \n n_estimators = 100\n forest_clf = RandomForestClassifier(random_state=1, n_estimators= n_estimators)\n forest_predictions = cross_val_predict(forest_clf, X_train, y_train )\n f1 = metrics.f1_score\n exp.metric('f1', f1)",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand All @@ -114,8 +112,8 @@
"deepnote_cell_type": "code"
},
"source": "from hyperdash import Experiment\nexp = Experiment(\"Dogs vs. Cats\")\n\n# Parameters\nestimators = exp.param(\"Estimators\", 500)\nepochs = exp.param(\"Epochs\", 5)\nbatch = exp.param(\"Batch Size\", 64)\n\nfor epoch in xrange(1, epochs + 1):\n accuracy = 1. - 1./epoch\n loss = float(epochs - epoch)/epochs\n print(\"Training model (epoch {})\".format(epoch))\n time.sleep(1)\n\n # Metrics\n exp.metric(\"Accuracy\", accuracy)\n exp.metric(\"Loss\", loss)\n\nexp.end()",
"execution_count": null,
"outputs": []
"outputs": [],
"execution_count": null
},
{
"cell_type": "markdown",
Expand Down
Loading

0 comments on commit 880bd2f

Please sign in to comment.