great-ai/docs/surveys/surveys.ipynb

309 lines
8.3 KiB
Text

{
"cells": [
{
"id": "7af82b40",
"cell_type": "markdown",
"source": [
"## Local setup\n",
"\n",
"Use Python 3.12 or 3.13 and install this checkout with `uv pip install --editable '.[notebooks]'`.\n",
"See **Run notebooks locally** in the repository README for the kernel, execution order,\n",
"and full-data options. Run related notebooks from the same working directory\n",
"to share the default `.cache/` model store and `tracing_database.json` database.\n"
],
"metadata": {}
},
{
"id": "ba5f79ca",
"cell_type": "code",
"metadata": {},
"execution_count": null,
"source": [
"from docs.notebook_support import SURVEY_DIR"
],
"outputs": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"best_practices = pd.read_csv(SURVEY_DIR / \"Best practices assessment.csv\")\n",
"best_practices"
],
"id": "cell-2"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"m = {\n",
" \"Strongly agree\": 4 / 4,\n",
" \"Agree\": 3 / 4,\n",
" \"Neither agree nor disagree\": 2 / 4,\n",
" \"Disagree\": 1 / 4,\n",
" \"Strongly disagree\": 0 / 4,\n",
"}\n",
"\n",
"best_practices_dicts = [v.to_dict() for _, v in best_practices.iterrows()]\n",
"\n",
"best_practice_score_ds = []\n",
"best_practice_score_se = []\n",
"\n",
"for d in best_practices_dicts:\n",
" ds_experience = int(d[\"How many years of data science experience do you have?\"])\n",
" del d[\"How many years of data science experience do you have?\"]\n",
"\n",
" se_experience = int(\n",
" d[\"How many years of software engineering experience do you have?\"]\n",
" )\n",
" del d[\"How many years of software engineering experience do you have?\"]\n",
"\n",
" scores = [m[v] for v in d.values() if v != \"Not applicable\"]\n",
" score = sum(scores) / len(scores)\n",
" best_practice_score_ds.append((ds_experience, score))\n",
" best_practice_score_se.append((se_experience, score))\n",
"\n",
"best_practices[\n",
" \"How many years of software engineering experience do you have?\"\n",
"].median(), best_practices[\n",
" \"How many years of data science experience do you have?\"\n",
"].median()"
],
"id": "cell-3"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"from scipy import stats\n",
"\n",
"best_practice_score_ds = sorted(best_practice_score_ds)\n",
"plt.scatter(\n",
" [x for x, y in best_practice_score_ds], [y for x, y in best_practice_score_ds]\n",
")\n",
"stats.pearsonr(\n",
" [x for x, y in best_practice_score_ds], [y for x, y in best_practice_score_ds]\n",
")"
],
"id": "cell-4"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import re\n",
"\n",
"best_practice_score_se = sorted(best_practice_score_se)\n",
"\n",
"%matplotlib inline\n",
"plt.rcParams[\"figure.facecolor\"] = \"white\"\n",
"plt.rcParams[\"font.size\"] = 24\n",
"plt.rcParams[\"figure.figsize\"] = (14, 10)\n",
"\n",
"X = [x for x, y in best_practice_score_se]\n",
"Y = [y for x, y in best_practice_score_se]\n",
"\n",
"print(sum(Y) / len(Y))\n",
"sc = plt.scatter(X, Y, c=\"black\", s=[x * 50 for x, y in best_practice_score_ds])\n",
"plt.ylabel(\"Ratio of implemented deployment best practices\")\n",
"plt.xlabel(\"Years of professional software engineering experience\")\n",
"\n",
"\n",
"def best_fit(X, Y):\n",
" xbar = sum(X) / len(X)\n",
" ybar = sum(Y) / len(Y)\n",
" n = len(X)\n",
"\n",
" numer = sum([xi * yi for xi, yi in zip(X, Y)]) - n * xbar * ybar\n",
" denum = sum([xi**2 for xi in X]) - n * xbar**2\n",
"\n",
" b = numer / denum\n",
" a = ybar - b * xbar\n",
" return a, b\n",
"\n",
"\n",
"a, b = best_fit(X, Y)\n",
"yfit = [a + b * xi for xi in X]\n",
"plt.plot(X, yfit, \"b\", label=\"Best fit\")\n",
"plt.legend(\n",
" sc.legend_elements(\"sizes\", num=5)[0],\n",
" [\n",
" re.sub(r\"[^\\d]*(\\d+)[^\\d]*\", lambda v: f\"{int(v.group(1)) // 40} years (DS)\", t)\n",
" for t in sc.legend_elements(\"sizes\", num=5)[1]\n",
" ],\n",
")\n",
"plt.tight_layout()\n",
"\n",
"plt.savefig(\"best-practices.png\", dpi=150)\n",
"\n",
"stats.pearsonr(\n",
" [x for x, y in best_practice_score_se], [y for x, y in best_practice_score_se]\n",
")"
],
"id": "cell-5"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tam = pd.read_csv(SURVEY_DIR / \"Technology acceptance model questionnaire.csv\")\n",
"tam"
],
"id": "cell-6"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pingouin\n",
"\n",
"pu = [\n",
" \"I believe the use of GreatAI improves the quality of AI deployments.\",\n",
" \"I believe the use of GreatAI would increase my productivity.\",\n",
" \"I believe the use of GreatAI can lead to robust and trustworthy deployments.\",\n",
" \"Overall, I found GreatAI useful when working with AI.\",\n",
"]\n",
"pingouin.cronbach_alpha(tam[pu])"
],
"id": "cell-7"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"peou = [\n",
" \"I found the GreatAI easy to learn.\",\n",
" \"I found it is easy to employ GreatAI in practice.\",\n",
" \"I found it is easy to integrate GreatAI into an existing project.\",\n",
" \"Overall, I found GreatAI easy to use.\",\n",
"]\n",
"pingouin.cronbach_alpha(tam[peou])"
],
"id": "cell-8"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"itu = [\n",
" \"Assuming GreatAI is applicable to my task, I predict that I will use it on a regular basis in the future.\",\n",
" \"Overall, I intend to use the GreatAI in my personal or professional projects.\",\n",
"]\n",
"pingouin.cronbach_alpha(tam[itu])"
],
"id": "cell-9"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tam[\"pu\"] = tam[pu].mean(axis=1)\n",
"tam[\"peou\"] = tam[peou].mean(axis=1)\n",
"tam[\"itu\"] = tam[itu].mean(axis=1)\n",
"tam[[\"pu\", \"peou\", \"itu\"]]"
],
"id": "cell-10"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tam[[\"pu\", \"peou\", \"itu\"]].mean()"
],
"id": "cell-11"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tam[[\"pu\", \"peou\", \"itu\"]].median()"
],
"id": "cell-12"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tam[[\"pu\", \"peou\", \"itu\"]].std()"
],
"id": "cell-13"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"stats.pearsonr(tam[\"peou\"], tam[\"pu\"])"
],
"id": "cell-14"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"stats.pearsonr(tam[\"peou\"], tam[\"itu\"])"
],
"id": "cell-15"
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"stats.pearsonr(tam[\"pu\"], tam[\"itu\"])"
],
"id": "cell-16"
}
],
"metadata": {
"kernelspec": {
"display_name": "GreatAI (local)",
"language": "python",
"name": "great-ai-local"
},
"language_info": {
"name": "python",
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}