Anni123 commited on
Commit
2ef16f8
1 Parent(s): eb4fa7f

Delete z.ipynb

Browse files
Files changed (1) hide show
  1. z.ipynb +0 -101
z.ipynb DELETED
@@ -1,101 +0,0 @@
1
- {
2
- "cells": [
3
- {
4
- "cell_type": "code",
5
- "execution_count": 14,
6
- "metadata": {},
7
- "outputs": [],
8
- "source": [
9
- "from collections import Counter\n",
10
- "\n",
11
- "def consistency(arr):\n",
12
- " len_ans = len(arr)\n",
13
- " arr_acounts = Counter(arr)\n",
14
- " ans_freq_tuple = arr_acounts.most_common(len_ans)\n",
15
- " most_frequent_item, _ = ans_freq_tuple[0]\n",
16
- " ans_dict = {}\n",
17
- " for ans_freq in ans_freq_tuple:\n",
18
- " ans, times = ans_freq\n",
19
- " ans_dict[ans] = times/len_ans\n",
20
- " return most_frequent_item, ans_dict"
21
- ]
22
- },
23
- {
24
- "cell_type": "code",
25
- "execution_count": 15,
26
- "metadata": {},
27
- "outputs": [
28
- {
29
- "data": {
30
- "text/plain": [
31
- "('A', {'A': 0.6, 'B': 0.2, 'C': 0.2})"
32
- ]
33
- },
34
- "execution_count": 15,
35
- "metadata": {},
36
- "output_type": "execute_result"
37
- }
38
- ],
39
- "source": [
40
- "ans = [\"A\",\"A\",\"A\",\"B\",\"C\"]\n",
41
- "\n",
42
- "consistency(ans)"
43
- ]
44
- },
45
- {
46
- "cell_type": "code",
47
- "execution_count": 10,
48
- "metadata": {},
49
- "outputs": [
50
- {
51
- "name": "stdout",
52
- "output_type": "stream",
53
- "text": [
54
- "[('A', 3), ('B', 1), ('C', 1)]\n"
55
- ]
56
- }
57
- ],
58
- "source": [
59
- "print(arr_acounts.most_common(len(ans)))"
60
- ]
61
- },
62
- {
63
- "cell_type": "code",
64
- "execution_count": null,
65
- "metadata": {},
66
- "outputs": [],
67
- "source": [
68
- "ans_dict = {}\n",
69
- "ans_freq_tuple = arr_acounts.most_common(len(ans))\n",
70
- "for ans_freq in ans_freq_tuple:\n",
71
- " ans, times = ans_freq\n",
72
- " ans_dict[ans] = times/len(arr)"
73
- ]
74
- }
75
- ],
76
- "metadata": {
77
- "interpreter": {
78
- "hash": "1e4907852c31268ef23280febd46201e788a9f549728e852c50dbb06a5d70124"
79
- },
80
- "kernelspec": {
81
- "display_name": "Python 3.8.17 ('qual')",
82
- "language": "python",
83
- "name": "python3"
84
- },
85
- "language_info": {
86
- "codemirror_mode": {
87
- "name": "ipython",
88
- "version": 3
89
- },
90
- "file_extension": ".py",
91
- "mimetype": "text/x-python",
92
- "name": "python",
93
- "nbconvert_exporter": "python",
94
- "pygments_lexer": "ipython3",
95
- "version": "3.8.17"
96
- },
97
- "orig_nbformat": 4
98
- },
99
- "nbformat": 4,
100
- "nbformat_minor": 2
101
- }