ConstantCoder commited on
Commit
92cba7d
·
verified ·
1 Parent(s): 74b60dd

Upload analysis.ipynb

Browse files
Files changed (1) hide show
  1. analysis.ipynb +78 -0
analysis.ipynb ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "id": "336bac24",
7
+ "metadata": {
8
+ "collapsed": true
9
+ },
10
+ "outputs": [
11
+ {
12
+ "ename": "FileNotFoundError",
13
+ "evalue": "[Errno 2] No such file or directory: 'user_actions.json'",
14
+ "output_type": "error",
15
+ "traceback": [
16
+ "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
17
+ "\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)",
18
+ "Cell \u001b[1;32mIn[1], line 9\u001b[0m\n\u001b[0;32m 6\u001b[0m log_file_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124muser_actions.json\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m 8\u001b[0m \u001b[38;5;66;03m# Verileri JSON dosyasından yükle\u001b[39;00m\n\u001b[1;32m----> 9\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(log_file_path, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mr\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;28;01mas\u001b[39;00m f:\n\u001b[0;32m 10\u001b[0m logs \u001b[38;5;241m=\u001b[39m [json\u001b[38;5;241m.\u001b[39mloads(line\u001b[38;5;241m.\u001b[39mstrip()\u001b[38;5;241m.\u001b[39mreplace(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m)) \u001b[38;5;28;01mfor\u001b[39;00m line \u001b[38;5;129;01min\u001b[39;00m f]\n\u001b[0;32m 12\u001b[0m \u001b[38;5;66;03m# DataFrame oluştur\u001b[39;00m\n",
19
+ "File \u001b[1;32m~\\anaconda3\\Lib\\site-packages\\IPython\\core\\interactiveshell.py:310\u001b[0m, in \u001b[0;36m_modified_open\u001b[1;34m(file, *args, **kwargs)\u001b[0m\n\u001b[0;32m 303\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m file \u001b[38;5;129;01min\u001b[39;00m {\u001b[38;5;241m0\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m2\u001b[39m}:\n\u001b[0;32m 304\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 305\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mIPython won\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mt let you open fd=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfile\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m by default \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 306\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mas it is likely to crash IPython. If you know what you are doing, \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 307\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124myou can use builtins\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m open.\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 308\u001b[0m )\n\u001b[1;32m--> 310\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m io_open(file, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs)\n",
20
+ "\u001b[1;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: 'user_actions.json'"
21
+ ]
22
+ }
23
+ ],
24
+ "source": [
25
+ "import pandas as pd\n",
26
+ "import json\n",
27
+ "import os\n",
28
+ "\n",
29
+ "# JSON dosyasının yolu\n",
30
+ "log_file_path = 'user_actions.json'\n",
31
+ "\n",
32
+ "# Verileri JSON dosyasından yükle\n",
33
+ "with open(log_file_path, 'r') as f:\n",
34
+ " logs = [json.loads(line.strip().replace(\"'\", '\"')) for line in f]\n",
35
+ "\n",
36
+ "# DataFrame oluştur\n",
37
+ "df = pd.DataFrame(logs)\n",
38
+ "\n",
39
+ "# Temel analizler\n",
40
+ "print(\"Toplam eylem sayısı:\", len(df))\n",
41
+ "print(\"Eylem türleri dağılımı:\\n\", df['actionType'].value_counts())\n",
42
+ "\n",
43
+ "# Belirli bir türdeki eylemleri filtreleme\n",
44
+ "click_actions = df[df['actionType'] == 'click']\n",
45
+ "print(\"Click eylemleri:\\n\", click_actions)\n"
46
+ ]
47
+ },
48
+ {
49
+ "cell_type": "code",
50
+ "execution_count": null,
51
+ "id": "f32baebc",
52
+ "metadata": {},
53
+ "outputs": [],
54
+ "source": []
55
+ }
56
+ ],
57
+ "metadata": {
58
+ "kernelspec": {
59
+ "display_name": "Python 3 (ipykernel)",
60
+ "language": "python",
61
+ "name": "python3"
62
+ },
63
+ "language_info": {
64
+ "codemirror_mode": {
65
+ "name": "ipython",
66
+ "version": 3
67
+ },
68
+ "file_extension": ".py",
69
+ "mimetype": "text/x-python",
70
+ "name": "python",
71
+ "nbconvert_exporter": "python",
72
+ "pygments_lexer": "ipython3",
73
+ "version": "3.11.7"
74
+ }
75
+ },
76
+ "nbformat": 4,
77
+ "nbformat_minor": 5
78
+ }