helenerollier commited on
Commit
32a1aae
·
verified ·
1 Parent(s): e1efdff

Upload datacreation.ipynb

Browse files
Files changed (1) hide show
  1. datacreation.ipynb +403 -346
datacreation.ipynb CHANGED
@@ -20,13 +20,13 @@
20
  },
21
  {
22
  "cell_type": "code",
23
- "execution_count": 81,
24
  "metadata": {
25
  "colab": {
26
  "base_uri": "https://localhost:8080/"
27
  },
28
  "id": "f48c8f8c",
29
- "outputId": "d0cf9eb7-407a-4275-a05d-a6016d1d3277"
30
  },
31
  "outputs": [
32
  {
@@ -46,8 +46,8 @@
46
  "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.3)\n",
47
  "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.3.3)\n",
48
  "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (0.12.1)\n",
49
- "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (4.62.1)\n",
50
- "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.5.0)\n",
51
  "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (26.0)\n",
52
  "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (11.3.0)\n",
53
  "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (3.3.2)\n",
@@ -85,7 +85,7 @@
85
  },
86
  {
87
  "cell_type": "code",
88
- "execution_count": 82,
89
  "metadata": {
90
  "id": "91d52125"
91
  },
@@ -113,7 +113,7 @@
113
  },
114
  {
115
  "cell_type": "code",
116
- "execution_count": 83,
117
  "metadata": {
118
  "id": "xqO5Y3dnYhxt"
119
  },
@@ -145,12 +145,19 @@
145
  },
146
  {
147
  "cell_type": "code",
148
- "execution_count": 83,
149
  "metadata": {
150
  "id": "l5FkkNhUYTHh"
151
  },
152
  "outputs": [],
153
- "source": []
 
 
 
 
 
 
 
154
  },
155
  {
156
  "cell_type": "markdown",
@@ -163,52 +170,7 @@
163
  },
164
  {
165
  "cell_type": "code",
166
- "source": [
167
- "import pandas as pd\n",
168
- "\n",
169
- "df_books = pd.DataFrame({\n",
170
- " \"title\": [\"Book A\", \"Book B\", \"Book C\"],\n",
171
- " \"price\": [10.99, 12.50, 8.99],\n",
172
- " \"rating\": [4, 5, 3]\n",
173
- "})"
174
- ],
175
- "metadata": {
176
- "id": "j_U7YrVrrN3n"
177
- },
178
- "execution_count": 84,
179
- "outputs": []
180
- },
181
- {
182
- "cell_type": "code",
183
- "source": [
184
- "df_books.to_csv(\"books_data.csv\", index=False)"
185
- ],
186
- "metadata": {
187
- "id": "KJ-lE6ktrQX9"
188
- },
189
- "execution_count": 85,
190
- "outputs": []
191
- },
192
- {
193
- "cell_type": "code",
194
- "source": [
195
- "df_reviews = pd.DataFrame({\n",
196
- " \"title\": [\"Book A\", \"Book B\"],\n",
197
- " \"review\": [\"Great book\", \"Okay book\"],\n",
198
- " \"sentiment_label\": [\"positive\", \"neutral\"]\n",
199
- "})\n",
200
- "\n",
201
- "df_reviews.to_csv(\"synthetic_book_reviews.csv\", index=False)"
202
- ],
203
- "metadata": {
204
- "id": "AqZUPGJtrSET"
205
- },
206
- "execution_count": 86,
207
- "outputs": []
208
- },
209
- {
210
- "cell_type": "code",
211
- "execution_count": 87,
212
  "metadata": {
213
  "id": "lC1U_YHtZifh"
214
  },
@@ -232,12 +194,183 @@
232
  },
233
  {
234
  "cell_type": "code",
235
- "execution_count": 87,
236
  "metadata": {
237
- "id": "O_wIvTxYZqCK"
 
 
 
 
 
238
  },
239
- "outputs": [],
240
- "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  },
242
  {
243
  "cell_type": "markdown",
@@ -259,7 +392,7 @@
259
  },
260
  {
261
  "cell_type": "code",
262
- "execution_count": 88,
263
  "metadata": {
264
  "id": "-gPXGcRPuV_9"
265
  },
@@ -286,7 +419,7 @@
286
  },
287
  {
288
  "cell_type": "code",
289
- "execution_count": 89,
290
  "metadata": {
291
  "id": "mnd5hdAbaNjz"
292
  },
@@ -309,12 +442,14 @@
309
  },
310
  {
311
  "cell_type": "code",
312
- "execution_count": 89,
313
  "metadata": {
314
  "id": "V-G3OCUCgR07"
315
  },
316
  "outputs": [],
317
- "source": []
 
 
318
  },
319
  {
320
  "cell_type": "markdown",
@@ -327,7 +462,7 @@
327
  },
328
  {
329
  "cell_type": "code",
330
- "execution_count": 90,
331
  "metadata": {
332
  "id": "kUtWmr8maZLZ"
333
  },
@@ -353,12 +488,14 @@
353
  },
354
  {
355
  "cell_type": "code",
356
- "execution_count": 90,
357
  "metadata": {
358
  "id": "tafQj8_7gYCG"
359
  },
360
  "outputs": [],
361
- "source": []
 
 
362
  },
363
  {
364
  "cell_type": "markdown",
@@ -380,7 +517,7 @@
380
  },
381
  {
382
  "cell_type": "code",
383
- "execution_count": 91,
384
  "metadata": {
385
  "id": "qkVhYPXGbgEn"
386
  },
@@ -417,38 +554,7 @@
417
  },
418
  {
419
  "cell_type": "code",
420
- "source": [
421
- "import numpy as np\n",
422
- "\n",
423
- "if \"sentiment_label\" not in df_books.columns:\n",
424
- " labels = [\"positive\", \"neutral\", \"negative\"]\n",
425
- " df_books[\"sentiment_label\"] = np.random.choice(labels, size=len(df_books))\n",
426
- ""
427
- ],
428
- "metadata": {
429
- "id": "mNYR6hMcs1P9"
430
- },
431
- "execution_count": 92,
432
- "outputs": []
433
- },
434
- {
435
- "cell_type": "code",
436
- "source": [
437
- "import numpy as np\n",
438
- "\n",
439
- "if \"sentiment_label\" not in df_books.columns:\n",
440
- " labels = [\"positive\", \"neutral\", \"negative\"]\n",
441
- " df_books[\"sentiment_label\"] = np.random.choice(labels, size=len(df_books))"
442
- ],
443
- "metadata": {
444
- "id": "crhSJ861s27Q"
445
- },
446
- "execution_count": 93,
447
- "outputs": []
448
- },
449
- {
450
- "cell_type": "code",
451
- "execution_count": 94,
452
  "metadata": {
453
  "id": "SlJ24AUafoDB"
454
  },
@@ -477,12 +583,14 @@
477
  },
478
  {
479
  "cell_type": "code",
480
- "execution_count": 94,
481
  "metadata": {
482
  "id": "wcN6gtiZg-ws"
483
  },
484
  "outputs": [],
485
- "source": []
 
 
486
  },
487
  {
488
  "cell_type": "markdown",
@@ -495,151 +603,25 @@
495
  },
496
  {
497
  "cell_type": "code",
498
- "source": [
499
- "sales_data = []\n",
500
- "for _, row in df_books.iterrows():\n",
501
- " records = generate_sales_profile(row[\"sentiment_label\"])\n",
502
- " for month, units in records:\n",
503
- " sales_data.append({\n",
504
- " \"title\": row[\"title\"],\n",
505
- " \"month\": month,\n",
506
- " \"units_sold\": units,\n",
507
- " \"sentiment_label\": row[\"sentiment_label\"]\n",
508
- " })"
509
- ],
510
- "metadata": {
511
- "id": "R0XK8LjDtXCe"
512
- },
513
- "execution_count": 95,
514
- "outputs": []
515
- },
516
- {
517
- "cell_type": "code",
518
- "source": [
519
- "df_sales = pd.DataFrame(sales_data)\n",
520
- "df_sales.to_csv(\"synthetic_sales_data.csv\", index=False)\n",
521
- "print(df_sales.head())"
522
- ],
523
- "metadata": {
524
- "id": "f5qTbY8itZPE",
525
- "outputId": "187b94f4-5c87-43b1-f69b-fe1e6ae7d433",
526
- "colab": {
527
- "base_uri": "https://localhost:8080/"
528
- }
529
- },
530
- "execution_count": 96,
531
- "outputs": [
532
- {
533
- "output_type": "stream",
534
- "name": "stdout",
535
- "text": [
536
- " title month units_sold sentiment_label\n",
537
- "0 Book A 2024-10 49 negative\n",
538
- "1 Book A 2024-11 56 negative\n",
539
- "2 Book A 2024-12 71 negative\n",
540
- "3 Book A 2025-01 64 negative\n",
541
- "4 Book A 2025-02 61 negative\n"
542
- ]
543
- }
544
- ]
545
- },
546
- {
547
- "cell_type": "code",
548
- "source": [
549
- "import numpy as np\n",
550
- "\n",
551
- "if \"sentiment_label\" not in df_books.columns:\n",
552
- " labels = [\"positive\", \"neutral\", \"negative\"]\n",
553
- " df_books[\"sentiment_label\"] = np.random.choice(labels, size=len(df_books))"
554
- ],
555
- "metadata": {
556
- "id": "5ebVuc_KtZ_O"
557
- },
558
- "execution_count": 97,
559
- "outputs": []
560
- },
561
- {
562
- "cell_type": "code",
563
- "source": [
564
- " sales_data = []\n",
565
- "for _, row in df_books.iterrows():\n",
566
- " records = generate_sales_profile(row[\"sentiment_label\"])\n",
567
- " for month, units in records:\n",
568
- " sales_data.append({\n",
569
- " \"title\": row[\"title\"],\n",
570
- " \"month\": month,\n",
571
- " \"units_sold\": units,\n",
572
- " \"sentiment_label\": row[\"sentiment_label\"]\n",
573
- " })"
574
- ],
575
- "metadata": {
576
- "id": "VXxCmPTatcug"
577
- },
578
- "execution_count": 98,
579
- "outputs": []
580
- },
581
- {
582
- "cell_type": "code",
583
- "source": [
584
- "df_sales = pd.DataFrame(sales_data)\n",
585
- "df_sales.to_csv(\"synthetic_sales_data.csv\", index=False)\n",
586
- "print(\"✅ synthetic_sales_data.csv created\")\n",
587
- "print(df_sales.head())"
588
- ],
589
- "metadata": {
590
- "id": "l3fLhuNVte15",
591
- "outputId": "b61c06a4-a534-4f4d-e5f6-a348741f7980",
592
- "colab": {
593
- "base_uri": "https://localhost:8080/"
594
- }
595
- },
596
- "execution_count": 99,
597
- "outputs": [
598
- {
599
- "output_type": "stream",
600
- "name": "stdout",
601
- "text": [
602
- "✅ synthetic_sales_data.csv created\n",
603
- " title month units_sold sentiment_label\n",
604
- "0 Book A 2024-10 31 negative\n",
605
- "1 Book A 2024-11 26 negative\n",
606
- "2 Book A 2024-12 22 negative\n",
607
- "3 Book A 2025-01 34 negative\n",
608
- "4 Book A 2025-02 24 negative\n"
609
- ]
610
- }
611
- ]
612
- },
613
- {
614
- "cell_type": "code",
615
- "source": [],
616
- "metadata": {
617
- "id": "B3owNJclthJm"
618
- },
619
- "execution_count": 99,
620
- "outputs": []
621
- },
622
- {
623
- "cell_type": "code",
624
- "execution_count": 100,
625
  "metadata": {
626
  "colab": {
627
  "base_uri": "https://localhost:8080/"
628
  },
629
  "id": "MzbZvLcAhGaH",
630
- "outputId": "4858910f-6703-4d9c-bdda-76cf5cfef58e"
631
  },
632
  "outputs": [
633
  {
634
  "output_type": "stream",
635
  "name": "stdout",
636
  "text": [
637
- " title month units_sold sentiment_label\n",
638
- "0 Book A 2024-10 31 negative\n",
639
- "1 Book A 2024-11 26 negative\n",
640
- "2 Book A 2024-12 22 negative\n",
641
- "3 Book A 2025-01 34 negative\n",
642
- "4 Book A 2025-02 24 negative\n"
643
  ]
644
  }
645
  ],
@@ -669,7 +651,7 @@
669
  },
670
  {
671
  "cell_type": "code",
672
- "execution_count": 101,
673
  "metadata": {
674
  "id": "b3cd2a50"
675
  },
@@ -680,16 +662,156 @@
680
  " \"A compelling and heartwarming read that stayed with me long after I finished.\",\n",
681
  " \"Brilliantly written! The characters were unforgettable and the plot was engaging.\",\n",
682
  " \"One of the best books I've read this year — inspiring and emotionally rich.\",\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
683
  " ],\n",
684
  " \"neutral\": [\n",
685
  " \"An average book — not great, but not bad either.\",\n",
686
  " \"Some parts really stood out, others felt a bit flat.\",\n",
687
  " \"It was okay overall. A decent way to pass the time.\",\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
688
  " ],\n",
689
  " \"negative\": [\n",
690
  " \"I struggled to get through this one — it just didn’t grab me.\",\n",
691
  " \"The plot was confusing and the characters felt underdeveloped.\",\n",
692
  " \"Disappointing. I had high hopes, but they weren't met.\",\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  " ]\n",
694
  "}"
695
  ]
@@ -705,103 +827,18 @@
705
  },
706
  {
707
  "cell_type": "code",
708
- "source": [
709
- "random.choices(review_pool, k=10)"
710
- ],
711
- "metadata": {
712
- "id": "inTizEVgvS2I",
713
- "outputId": "5692f777-aeda-4452-8f42-0db5ff094ddf",
714
- "colab": {
715
- "base_uri": "https://localhost:8080/"
716
- }
717
- },
718
- "execution_count": 102,
719
- "outputs": [
720
- {
721
- "output_type": "execute_result",
722
- "data": {
723
- "text/plain": [
724
- "[\"Disappointing. I had high hopes, but they weren't met.\",\n",
725
- " \"Disappointing. I had high hopes, but they weren't met.\",\n",
726
- " 'I struggled to get through this one — it just didn’t grab me.',\n",
727
- " 'I struggled to get through this one — it just didn’t grab me.',\n",
728
- " 'I struggled to get through this one — it just didn’t grab me.',\n",
729
- " 'The plot was confusing and the characters felt underdeveloped.',\n",
730
- " \"Disappointing. I had high hopes, but they weren't met.\",\n",
731
- " 'I struggled to get through this one — it just didn’t grab me.',\n",
732
- " 'I struggled to get through this one — it just didn’t grab me.',\n",
733
- " \"Disappointing. I had high hopes, but they weren't met.\"]"
734
- ]
735
- },
736
- "metadata": {},
737
- "execution_count": 102
738
- }
739
- ]
740
- },
741
- {
742
- "cell_type": "code",
743
- "source": [
744
- "import numpy as np\n",
745
- "\n",
746
- "if \"popularity_score\" not in df_books.columns:\n",
747
- " df_books[\"popularity_score\"] = np.random.randint(1, 101, size=len(df_books))"
748
- ],
749
- "metadata": {
750
- "id": "wphd_MYCvg4R"
751
- },
752
- "execution_count": 103,
753
- "outputs": []
754
- },
755
- {
756
- "cell_type": "code",
757
- "source": [
758
- "import random\n",
759
- "\n",
760
- "if \"popularity_score\" not in df_books.columns:\n",
761
- " df_books[\"popularity_score\"] = np.random.randint(1, 101, size=len(df_books))\n",
762
- "\n",
763
- "review_rows = []\n",
764
- "for _, row in df_books.iterrows():\n",
765
- " title = row['title']\n",
766
- " sentiment_label = row['sentiment_label']\n",
767
- " review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
768
- " sampled_reviews = random.choices(review_pool, k=10)\n",
769
- "\n",
770
- " for review_text in sampled_reviews:\n",
771
- " review_rows.append({\n",
772
- " \"title\": title,\n",
773
- " \"sentiment_label\": sentiment_label,\n",
774
- " \"review_text\": review_text,\n",
775
- " \"rating\": row['rating'],\n",
776
- " \"popularity_score\": row['popularity_score']\n",
777
- " })"
778
- ],
779
- "metadata": {
780
- "id": "fBFOohZ2vhyT"
781
- },
782
- "execution_count": 104,
783
- "outputs": []
784
- },
785
- {
786
- "cell_type": "code",
787
- "source": [],
788
  "metadata": {
789
- "id": "OJsnG5h-vkGN"
790
  },
791
- "execution_count": 104,
792
- "outputs": []
793
- },
794
- {
795
- "cell_type": "code",
796
  "source": [
797
  "review_rows = []\n",
798
  "for _, row in df_books.iterrows():\n",
799
  " title = row['title']\n",
800
  " sentiment_label = row['sentiment_label']\n",
801
  " review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
802
- "\n",
803
- " sampled_reviews = random.choices(review_pool, k=10) # ✅ FIX HERE\n",
804
- "\n",
805
  " for review_text in sampled_reviews:\n",
806
  " review_rows.append({\n",
807
  " \"title\": title,\n",
@@ -810,12 +847,7 @@
810
  " \"rating\": row['rating'],\n",
811
  " \"popularity_score\": row['popularity_score']\n",
812
  " })"
813
- ],
814
- "metadata": {
815
- "id": "yHoawsbnvYIV"
816
- },
817
- "execution_count": 105,
818
- "outputs": []
819
  },
820
  {
821
  "cell_type": "markdown",
@@ -828,7 +860,7 @@
828
  },
829
  {
830
  "cell_type": "code",
831
- "execution_count": 106,
832
  "metadata": {
833
  "id": "ZUKUqZsuumsp"
834
  },
@@ -838,24 +870,15 @@
838
  "df_reviews.to_csv(\"synthetic_book_reviews.csv\", index=False)"
839
  ]
840
  },
841
- {
842
- "cell_type": "markdown",
843
- "source": [
844
- "### *c. inputs for R*"
845
- ],
846
- "metadata": {
847
- "id": "_602pYUS3gY5"
848
- }
849
- },
850
  {
851
  "cell_type": "code",
852
- "execution_count": 107,
853
  "metadata": {
854
  "colab": {
855
  "base_uri": "https://localhost:8080/"
856
  },
857
  "id": "3946e521",
858
- "outputId": "bb81b360-789d-409e-f3f1-f9445656af2d"
859
  },
860
  "outputs": [
861
  {
@@ -868,6 +891,14 @@
868
  }
869
  ],
870
  "source": [
 
 
 
 
 
 
 
 
871
  "import numpy as np\n",
872
  "\n",
873
  "def _safe_num(s):\n",
@@ -981,12 +1012,38 @@
981
  },
982
  {
983
  "cell_type": "code",
984
- "execution_count": 107,
985
  "metadata": {
986
- "id": "xfE8NMqOurKo"
 
 
 
 
987
  },
988
- "outputs": [],
989
- "source": []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
990
  }
991
  ],
992
  "metadata": {
 
20
  },
21
  {
22
  "cell_type": "code",
23
+ "execution_count": 1,
24
  "metadata": {
25
  "colab": {
26
  "base_uri": "https://localhost:8080/"
27
  },
28
  "id": "f48c8f8c",
29
+ "outputId": "13d0dd5e-82c6-489f-b1f0-e970186a4eb7"
30
  },
31
  "outputs": [
32
  {
 
46
  "Requirement already satisfied: tzdata>=2022.7 in /usr/local/lib/python3.12/dist-packages (from pandas) (2025.3)\n",
47
  "Requirement already satisfied: contourpy>=1.0.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.3.3)\n",
48
  "Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (0.12.1)\n",
49
+ "Requirement already satisfied: fonttools>=4.22.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (4.61.1)\n",
50
+ "Requirement already satisfied: kiwisolver>=1.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (1.4.9)\n",
51
  "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (26.0)\n",
52
  "Requirement already satisfied: pillow>=8 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (11.3.0)\n",
53
  "Requirement already satisfied: pyparsing>=2.3.1 in /usr/local/lib/python3.12/dist-packages (from matplotlib) (3.3.2)\n",
 
85
  },
86
  {
87
  "cell_type": "code",
88
+ "execution_count": 2,
89
  "metadata": {
90
  "id": "91d52125"
91
  },
 
113
  },
114
  {
115
  "cell_type": "code",
116
+ "execution_count": 3,
117
  "metadata": {
118
  "id": "xqO5Y3dnYhxt"
119
  },
 
145
  },
146
  {
147
  "cell_type": "code",
148
+ "execution_count": 4,
149
  "metadata": {
150
  "id": "l5FkkNhUYTHh"
151
  },
152
  "outputs": [],
153
+ "source": [
154
+ "# 🗂️ Create DataFrame\n",
155
+ "df_books = pd.DataFrame({\n",
156
+ " \"title\": titles,\n",
157
+ " \"price\": prices,\n",
158
+ " \"rating\": ratings\n",
159
+ "})"
160
+ ]
161
  },
162
  {
163
  "cell_type": "markdown",
 
170
  },
171
  {
172
  "cell_type": "code",
173
+ "execution_count": 5,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
  "metadata": {
175
  "id": "lC1U_YHtZifh"
176
  },
 
194
  },
195
  {
196
  "cell_type": "code",
197
+ "execution_count": 6,
198
  "metadata": {
199
+ "colab": {
200
+ "base_uri": "https://localhost:8080/",
201
+ "height": 0
202
+ },
203
+ "id": "O_wIvTxYZqCK",
204
+ "outputId": "349b36b0-c008-4fd5-d4a4-dba38ae18337"
205
  },
206
+ "outputs": [
207
+ {
208
+ "output_type": "execute_result",
209
+ "data": {
210
+ "text/plain": [
211
+ " title price rating\n",
212
+ "0 A Light in the Attic 51.77 Three\n",
213
+ "1 Tipping the Velvet 53.74 One\n",
214
+ "2 Soumission 50.10 One\n",
215
+ "3 Sharp Objects 47.82 Four\n",
216
+ "4 Sapiens: A Brief History of Humankind 54.23 Five"
217
+ ],
218
+ "text/html": [
219
+ "\n",
220
+ " <div id=\"df-04c87660-4415-45e9-ad3b-3fa19d9402c2\" class=\"colab-df-container\">\n",
221
+ " <div>\n",
222
+ "<style scoped>\n",
223
+ " .dataframe tbody tr th:only-of-type {\n",
224
+ " vertical-align: middle;\n",
225
+ " }\n",
226
+ "\n",
227
+ " .dataframe tbody tr th {\n",
228
+ " vertical-align: top;\n",
229
+ " }\n",
230
+ "\n",
231
+ " .dataframe thead th {\n",
232
+ " text-align: right;\n",
233
+ " }\n",
234
+ "</style>\n",
235
+ "<table border=\"1\" class=\"dataframe\">\n",
236
+ " <thead>\n",
237
+ " <tr style=\"text-align: right;\">\n",
238
+ " <th></th>\n",
239
+ " <th>title</th>\n",
240
+ " <th>price</th>\n",
241
+ " <th>rating</th>\n",
242
+ " </tr>\n",
243
+ " </thead>\n",
244
+ " <tbody>\n",
245
+ " <tr>\n",
246
+ " <th>0</th>\n",
247
+ " <td>A Light in the Attic</td>\n",
248
+ " <td>51.77</td>\n",
249
+ " <td>Three</td>\n",
250
+ " </tr>\n",
251
+ " <tr>\n",
252
+ " <th>1</th>\n",
253
+ " <td>Tipping the Velvet</td>\n",
254
+ " <td>53.74</td>\n",
255
+ " <td>One</td>\n",
256
+ " </tr>\n",
257
+ " <tr>\n",
258
+ " <th>2</th>\n",
259
+ " <td>Soumission</td>\n",
260
+ " <td>50.10</td>\n",
261
+ " <td>One</td>\n",
262
+ " </tr>\n",
263
+ " <tr>\n",
264
+ " <th>3</th>\n",
265
+ " <td>Sharp Objects</td>\n",
266
+ " <td>47.82</td>\n",
267
+ " <td>Four</td>\n",
268
+ " </tr>\n",
269
+ " <tr>\n",
270
+ " <th>4</th>\n",
271
+ " <td>Sapiens: A Brief History of Humankind</td>\n",
272
+ " <td>54.23</td>\n",
273
+ " <td>Five</td>\n",
274
+ " </tr>\n",
275
+ " </tbody>\n",
276
+ "</table>\n",
277
+ "</div>\n",
278
+ " <div class=\"colab-df-buttons\">\n",
279
+ "\n",
280
+ " <div class=\"colab-df-container\">\n",
281
+ " <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-04c87660-4415-45e9-ad3b-3fa19d9402c2')\"\n",
282
+ " title=\"Convert this dataframe to an interactive table.\"\n",
283
+ " style=\"display:none;\">\n",
284
+ "\n",
285
+ " <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
286
+ " <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
287
+ " </svg>\n",
288
+ " </button>\n",
289
+ "\n",
290
+ " <style>\n",
291
+ " .colab-df-container {\n",
292
+ " display:flex;\n",
293
+ " gap: 12px;\n",
294
+ " }\n",
295
+ "\n",
296
+ " .colab-df-convert {\n",
297
+ " background-color: #E8F0FE;\n",
298
+ " border: none;\n",
299
+ " border-radius: 50%;\n",
300
+ " cursor: pointer;\n",
301
+ " display: none;\n",
302
+ " fill: #1967D2;\n",
303
+ " height: 32px;\n",
304
+ " padding: 0 0 0 0;\n",
305
+ " width: 32px;\n",
306
+ " }\n",
307
+ "\n",
308
+ " .colab-df-convert:hover {\n",
309
+ " background-color: #E2EBFA;\n",
310
+ " box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
311
+ " fill: #174EA6;\n",
312
+ " }\n",
313
+ "\n",
314
+ " .colab-df-buttons div {\n",
315
+ " margin-bottom: 4px;\n",
316
+ " }\n",
317
+ "\n",
318
+ " [theme=dark] .colab-df-convert {\n",
319
+ " background-color: #3B4455;\n",
320
+ " fill: #D2E3FC;\n",
321
+ " }\n",
322
+ "\n",
323
+ " [theme=dark] .colab-df-convert:hover {\n",
324
+ " background-color: #434B5C;\n",
325
+ " box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
326
+ " filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
327
+ " fill: #FFFFFF;\n",
328
+ " }\n",
329
+ " </style>\n",
330
+ "\n",
331
+ " <script>\n",
332
+ " const buttonEl =\n",
333
+ " document.querySelector('#df-04c87660-4415-45e9-ad3b-3fa19d9402c2 button.colab-df-convert');\n",
334
+ " buttonEl.style.display =\n",
335
+ " google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
336
+ "\n",
337
+ " async function convertToInteractive(key) {\n",
338
+ " const element = document.querySelector('#df-04c87660-4415-45e9-ad3b-3fa19d9402c2');\n",
339
+ " const dataTable =\n",
340
+ " await google.colab.kernel.invokeFunction('convertToInteractive',\n",
341
+ " [key], {});\n",
342
+ " if (!dataTable) return;\n",
343
+ "\n",
344
+ " const docLinkHtml = 'Like what you see? Visit the ' +\n",
345
+ " '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
346
+ " + ' to learn more about interactive tables.';\n",
347
+ " element.innerHTML = '';\n",
348
+ " dataTable['output_type'] = 'display_data';\n",
349
+ " await google.colab.output.renderOutput(dataTable, element);\n",
350
+ " const docLink = document.createElement('div');\n",
351
+ " docLink.innerHTML = docLinkHtml;\n",
352
+ " element.appendChild(docLink);\n",
353
+ " }\n",
354
+ " </script>\n",
355
+ " </div>\n",
356
+ "\n",
357
+ "\n",
358
+ " </div>\n",
359
+ " </div>\n"
360
+ ],
361
+ "application/vnd.google.colaboratory.intrinsic+json": {
362
+ "type": "dataframe",
363
+ "variable_name": "df_books",
364
+ "summary": "{\n \"name\": \"df_books\",\n \"rows\": 1000,\n \"fields\": [\n {\n \"column\": \"title\",\n \"properties\": {\n \"dtype\": \"string\",\n \"num_unique_values\": 999,\n \"samples\": [\n \"The Grownup\",\n \"Persepolis: The Story of a Childhood (Persepolis #1-2)\",\n \"Ayumi's Violin\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"price\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14.446689669952772,\n \"min\": 10.0,\n \"max\": 59.99,\n \"num_unique_values\": 903,\n \"samples\": [\n 19.73,\n 55.65,\n 46.31\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"rating\",\n \"properties\": {\n \"dtype\": \"category\",\n \"num_unique_values\": 5,\n \"samples\": [\n \"One\",\n \"Two\",\n \"Four\"\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}"
365
+ }
366
+ },
367
+ "metadata": {},
368
+ "execution_count": 6
369
+ }
370
+ ],
371
+ "source": [
372
+ "df_books.head()"
373
+ ]
374
  },
375
  {
376
  "cell_type": "markdown",
 
392
  },
393
  {
394
  "cell_type": "code",
395
+ "execution_count": 7,
396
  "metadata": {
397
  "id": "-gPXGcRPuV_9"
398
  },
 
419
  },
420
  {
421
  "cell_type": "code",
422
+ "execution_count": 8,
423
  "metadata": {
424
  "id": "mnd5hdAbaNjz"
425
  },
 
442
  },
443
  {
444
  "cell_type": "code",
445
+ "execution_count": 9,
446
  "metadata": {
447
  "id": "V-G3OCUCgR07"
448
  },
449
  "outputs": [],
450
+ "source": [
451
+ "df_books[\"popularity_score\"] = df_books[\"rating\"].apply(generate_popularity_score)"
452
+ ]
453
  },
454
  {
455
  "cell_type": "markdown",
 
462
  },
463
  {
464
  "cell_type": "code",
465
+ "execution_count": 10,
466
  "metadata": {
467
  "id": "kUtWmr8maZLZ"
468
  },
 
488
  },
489
  {
490
  "cell_type": "code",
491
+ "execution_count": 11,
492
  "metadata": {
493
  "id": "tafQj8_7gYCG"
494
  },
495
  "outputs": [],
496
+ "source": [
497
+ "df_books[\"sentiment_label\"] = df_books[\"popularity_score\"].apply(get_sentiment)"
498
+ ]
499
  },
500
  {
501
  "cell_type": "markdown",
 
517
  },
518
  {
519
  "cell_type": "code",
520
+ "execution_count": 12,
521
  "metadata": {
522
  "id": "qkVhYPXGbgEn"
523
  },
 
554
  },
555
  {
556
  "cell_type": "code",
557
+ "execution_count": 13,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
558
  "metadata": {
559
  "id": "SlJ24AUafoDB"
560
  },
 
583
  },
584
  {
585
  "cell_type": "code",
586
+ "execution_count": 14,
587
  "metadata": {
588
  "id": "wcN6gtiZg-ws"
589
  },
590
  "outputs": [],
591
+ "source": [
592
+ "df_sales = pd.DataFrame(sales_data)"
593
+ ]
594
  },
595
  {
596
  "cell_type": "markdown",
 
603
  },
604
  {
605
  "cell_type": "code",
606
+ "execution_count": 15,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
  "metadata": {
608
  "colab": {
609
  "base_uri": "https://localhost:8080/"
610
  },
611
  "id": "MzbZvLcAhGaH",
612
+ "outputId": "c692bb04-7263-4115-a2ba-c72fe0180722"
613
  },
614
  "outputs": [
615
  {
616
  "output_type": "stream",
617
  "name": "stdout",
618
  "text": [
619
+ " title month units_sold sentiment_label\n",
620
+ "0 A Light in the Attic 2024-08 100 neutral\n",
621
+ "1 A Light in the Attic 2024-09 109 neutral\n",
622
+ "2 A Light in the Attic 2024-10 102 neutral\n",
623
+ "3 A Light in the Attic 2024-11 107 neutral\n",
624
+ "4 A Light in the Attic 2024-12 108 neutral\n"
625
  ]
626
  }
627
  ],
 
651
  },
652
  {
653
  "cell_type": "code",
654
+ "execution_count": 16,
655
  "metadata": {
656
  "id": "b3cd2a50"
657
  },
 
662
  " \"A compelling and heartwarming read that stayed with me long after I finished.\",\n",
663
  " \"Brilliantly written! The characters were unforgettable and the plot was engaging.\",\n",
664
  " \"One of the best books I've read this year — inspiring and emotionally rich.\",\n",
665
+ " \"The author's storytelling was vivid and powerful. Highly recommended!\",\n",
666
+ " \"An absolute masterpiece. I couldn't put it down from start to finish.\",\n",
667
+ " \"Gripping, intelligent, and beautifully crafted — I loved every page.\",\n",
668
+ " \"The emotional depth and layered narrative were just perfect.\",\n",
669
+ " \"A thought-provoking journey with stunning character development.\",\n",
670
+ " \"Everything about this book just clicked. A top-tier read!\",\n",
671
+ " \"A flawless blend of emotion, intrigue, and style. Truly impressive.\",\n",
672
+ " \"Absolutely stunning work of fiction. Five stars from me.\",\n",
673
+ " \"Remarkably executed with breathtaking prose.\",\n",
674
+ " \"The pacing was perfect and I was hooked from page one.\",\n",
675
+ " \"Heartfelt and hopeful — a story well worth telling.\",\n",
676
+ " \"A vivid journey through complex emotions and stunning imagery.\",\n",
677
+ " \"This book had soul. Every word felt like it mattered.\",\n",
678
+ " \"It delivered more than I ever expected. Powerful and wise.\",\n",
679
+ " \"The characters leapt off the page and into my heart.\",\n",
680
+ " \"I could see every scene clearly in my mind — beautifully descriptive.\",\n",
681
+ " \"Refreshing, original, and impossible to forget.\",\n",
682
+ " \"A radiant celebration of resilience and love.\",\n",
683
+ " \"Powerful themes handled with grace and insight.\",\n",
684
+ " \"An unforgettable literary experience.\",\n",
685
+ " \"The best book club pick we’ve had all year.\",\n",
686
+ " \"A layered, lyrical narrative that resonates deeply.\",\n",
687
+ " \"Surprising, profound, and deeply humane.\",\n",
688
+ " \"One of those rare books I wish I could read again for the first time.\",\n",
689
+ " \"Both epic and intimate — a perfect balance.\",\n",
690
+ " \"It reads like a love letter to the human spirit.\",\n",
691
+ " \"Satisfying and uplifting with a memorable ending.\",\n",
692
+ " \"This novel deserves every bit of praise it gets.\",\n",
693
+ " \"Introspective, emotional, and elegantly composed.\",\n",
694
+ " \"A tour de force in contemporary fiction.\",\n",
695
+ " \"Left me smiling, teary-eyed, and completely fulfilled.\",\n",
696
+ " \"A novel with the rare ability to entertain and enlighten.\",\n",
697
+ " \"Incredibly moving. I highlighted so many lines.\",\n",
698
+ " \"A smart, sensitive take on relationships and identity.\",\n",
699
+ " \"You feel wiser by the end of it.\",\n",
700
+ " \"A gorgeously crafted tale about hope and second chances.\",\n",
701
+ " \"Poignant and real — a beautiful escape.\",\n",
702
+ " \"Brims with insight and authenticity.\",\n",
703
+ " \"Compelling characters and a satisfying plot.\",\n",
704
+ " \"An empowering and important read.\",\n",
705
+ " \"Elegantly crafted and deeply humane.\",\n",
706
+ " \"Taut storytelling that never lets go.\",\n",
707
+ " \"Each chapter offered a new treasure.\",\n",
708
+ " \"Lyrical writing that stays with you.\",\n",
709
+ " \"A wonderful blend of passion and thoughtfulness.\",\n",
710
+ " \"Uplifting, honest, and completely engrossing.\",\n",
711
+ " \"This one made me believe in storytelling again.\"\n",
712
  " ],\n",
713
  " \"neutral\": [\n",
714
  " \"An average book — not great, but not bad either.\",\n",
715
  " \"Some parts really stood out, others felt a bit flat.\",\n",
716
  " \"It was okay overall. A decent way to pass the time.\",\n",
717
+ " \"The writing was fine, though I didn’t fully connect with the story.\",\n",
718
+ " \"Had a few memorable moments but lacked depth in some areas.\",\n",
719
+ " \"A mixed experience — neither fully engaging nor forgettable.\",\n",
720
+ " \"There was potential, but it didn't quite come together for me.\",\n",
721
+ " \"A reasonable effort that just didn’t leave a lasting impression.\",\n",
722
+ " \"Serviceable but not something I'd go out of my way to recommend.\",\n",
723
+ " \"Not much to dislike, but not much to rave about either.\",\n",
724
+ " \"It had its strengths, though they didn’t shine consistently.\",\n",
725
+ " \"I’m on the fence — parts were enjoyable, others not so much.\",\n",
726
+ " \"The book had a unique concept but lacked execution.\",\n",
727
+ " \"A middle-of-the-road read.\",\n",
728
+ " \"Engaging at times, but it lost momentum.\",\n",
729
+ " \"Would have benefited from stronger character development.\",\n",
730
+ " \"It passed the time, but I wouldn't reread it.\",\n",
731
+ " \"The plot had some holes that affected immersion.\",\n",
732
+ " \"Mediocre pacing made it hard to stay invested.\",\n",
733
+ " \"Satisfying in parts, underwhelming in others.\",\n",
734
+ " \"Neutral on this one — didn’t love it or hate it.\",\n",
735
+ " \"Fairly forgettable but with glimpses of promise.\",\n",
736
+ " \"The themes were solid, but not well explored.\",\n",
737
+ " \"Competent, just not compelling.\",\n",
738
+ " \"Had moments of clarity and moments of confusion.\",\n",
739
+ " \"I didn’t regret reading it, but I wouldn’t recommend it.\",\n",
740
+ " \"Readable, yet uninspired.\",\n",
741
+ " \"There was a spark, but it didn’t ignite.\",\n",
742
+ " \"A slow burn that didn’t quite catch fire.\",\n",
743
+ " \"I expected more nuance given the premise.\",\n",
744
+ " \"A safe, inoffensive choice.\",\n",
745
+ " \"Some parts lagged, others piqued my interest.\",\n",
746
+ " \"Decent, but needed polish.\",\n",
747
+ " \"Moderately engaging but didn’t stick the landing.\",\n",
748
+ " \"It simply lacked that emotional punch.\",\n",
749
+ " \"Just fine — no better, no worse.\",\n",
750
+ " \"Some thoughtful passages amid otherwise dry writing.\",\n",
751
+ " \"I appreciated the ideas more than the execution.\",\n",
752
+ " \"Struggled with cohesion.\",\n",
753
+ " \"Solidly average.\",\n",
754
+ " \"Good on paper, flat in practice.\",\n",
755
+ " \"A few bright spots, but mostly dim.\",\n",
756
+ " \"The kind of book that fades from memory.\",\n",
757
+ " \"It scratched the surface but didn’t dig deep.\",\n",
758
+ " \"Standard fare with some promise.\",\n",
759
+ " \"Okay, but not memorable.\",\n",
760
+ " \"Had potential that went unrealized.\",\n",
761
+ " \"Could have been tighter, sharper, deeper.\",\n",
762
+ " \"A blend of mediocrity and mild interest.\",\n",
763
+ " \"I kept reading, but barely.\"\n",
764
  " ],\n",
765
  " \"negative\": [\n",
766
  " \"I struggled to get through this one — it just didn’t grab me.\",\n",
767
  " \"The plot was confusing and the characters felt underdeveloped.\",\n",
768
  " \"Disappointing. I had high hopes, but they weren't met.\",\n",
769
+ " \"Uninspired writing and a story that never quite took off.\",\n",
770
+ " \"Unfortunately, it was dull and predictable throughout.\",\n",
771
+ " \"The pacing dragged and I couldn’t find anything compelling.\",\n",
772
+ " \"This felt like a chore to read — lacked heart and originality.\",\n",
773
+ " \"Nothing really worked for me in this book.\",\n",
774
+ " \"A frustrating read that left me unsatisfied.\",\n",
775
+ " \"I kept hoping it would improve, but it never did.\",\n",
776
+ " \"The characters didn’t feel real, and the dialogue was forced.\",\n",
777
+ " \"I couldn't connect with the story at all.\",\n",
778
+ " \"A slow, meandering narrative with little payoff.\",\n",
779
+ " \"Tried too hard to be deep, but just felt empty.\",\n",
780
+ " \"The tone was uneven and confusing.\",\n",
781
+ " \"Way too repetitive and lacking progression.\",\n",
782
+ " \"The ending was abrupt and unsatisfying.\",\n",
783
+ " \"No emotional resonance — I felt nothing throughout.\",\n",
784
+ " \"I expected much more, but this fell flat.\",\n",
785
+ " \"Poorly edited and full of clichés.\",\n",
786
+ " \"The premise was interesting, but poorly executed.\",\n",
787
+ " \"Just didn’t live up to the praise.\",\n",
788
+ " \"A disjointed mess from start to finish.\",\n",
789
+ " \"Overly long and painfully dull.\",\n",
790
+ " \"Dialogue that felt robotic and unrealistic.\",\n",
791
+ " \"A hollow shell of what it could’ve been.\",\n",
792
+ " \"It lacked a coherent structure.\",\n",
793
+ " \"More confusing than complex.\",\n",
794
+ " \"Reading it felt like a task, not a treat.\",\n",
795
+ " \"There was no tension, no emotion — just words.\",\n",
796
+ " \"Characters with no motivation or development.\",\n",
797
+ " \"The plot twists were nonsensical.\",\n",
798
+ " \"Regret buying this book.\",\n",
799
+ " \"Nothing drew me in, nothing made me stay.\",\n",
800
+ " \"Too many subplots and none were satisfying.\",\n",
801
+ " \"Tedious and unimaginative.\",\n",
802
+ " \"Like reading a rough draft.\",\n",
803
+ " \"Disjointed, distant, and disappointing.\",\n",
804
+ " \"A lot of buildup with no payoff.\",\n",
805
+ " \"I don’t understand the hype.\",\n",
806
+ " \"This book simply didn’t work.\",\n",
807
+ " \"Forgettable in every sense.\",\n",
808
+ " \"More effort should’ve gone into editing.\",\n",
809
+ " \"The story lost its way early on.\",\n",
810
+ " \"It dragged endlessly.\",\n",
811
+ " \"I kept checking how many pages were left.\",\n",
812
+ " \"This lacked vision and clarity.\",\n",
813
+ " \"I expected substance — got fluff.\",\n",
814
+ " \"It failed to make me care.\"\n",
815
  " ]\n",
816
  "}"
817
  ]
 
827
  },
828
  {
829
  "cell_type": "code",
830
+ "execution_count": 17,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  "metadata": {
832
+ "id": "l2SRc3PjuTGM"
833
  },
834
+ "outputs": [],
 
 
 
 
835
  "source": [
836
  "review_rows = []\n",
837
  "for _, row in df_books.iterrows():\n",
838
  " title = row['title']\n",
839
  " sentiment_label = row['sentiment_label']\n",
840
  " review_pool = synthetic_reviews_by_sentiment[sentiment_label]\n",
841
+ " sampled_reviews = random.sample(review_pool, 10)\n",
 
 
842
  " for review_text in sampled_reviews:\n",
843
  " review_rows.append({\n",
844
  " \"title\": title,\n",
 
847
  " \"rating\": row['rating'],\n",
848
  " \"popularity_score\": row['popularity_score']\n",
849
  " })"
850
+ ]
 
 
 
 
 
851
  },
852
  {
853
  "cell_type": "markdown",
 
860
  },
861
  {
862
  "cell_type": "code",
863
+ "execution_count": 18,
864
  "metadata": {
865
  "id": "ZUKUqZsuumsp"
866
  },
 
870
  "df_reviews.to_csv(\"synthetic_book_reviews.csv\", index=False)"
871
  ]
872
  },
 
 
 
 
 
 
 
 
 
873
  {
874
  "cell_type": "code",
875
+ "execution_count": 19,
876
  "metadata": {
877
  "colab": {
878
  "base_uri": "https://localhost:8080/"
879
  },
880
  "id": "3946e521",
881
+ "outputId": "514d7bef-0488-4933-b03c-953b9e8a7f66"
882
  },
883
  "outputs": [
884
  {
 
891
  }
892
  ],
893
  "source": [
894
+ "\n",
895
+ "# ============================================================\n",
896
+ "# ✅ Create \"R-ready\" derived inputs (root-level files)\n",
897
+ "# ============================================================\n",
898
+ "# These two files make the R notebook robust and fast:\n",
899
+ "# 1) synthetic_title_level_features.csv -> regression-ready, one row per title\n",
900
+ "# 2) synthetic_monthly_revenue_series.csv -> forecasting-ready, one row per month\n",
901
+ "\n",
902
  "import numpy as np\n",
903
  "\n",
904
  "def _safe_num(s):\n",
 
1012
  },
1013
  {
1014
  "cell_type": "code",
1015
+ "execution_count": 20,
1016
  "metadata": {
1017
+ "colab": {
1018
+ "base_uri": "https://localhost:8080/"
1019
+ },
1020
+ "id": "xfE8NMqOurKo",
1021
+ "outputId": "191730ba-d5e2-4df7-97d2-99feb0b704af"
1022
  },
1023
+ "outputs": [
1024
+ {
1025
+ "output_type": "stream",
1026
+ "name": "stdout",
1027
+ "text": [
1028
+ " title sentiment_label \\\n",
1029
+ "0 A Light in the Attic neutral \n",
1030
+ "1 A Light in the Attic neutral \n",
1031
+ "2 A Light in the Attic neutral \n",
1032
+ "3 A Light in the Attic neutral \n",
1033
+ "4 A Light in the Attic neutral \n",
1034
+ "\n",
1035
+ " review_text rating popularity_score \n",
1036
+ "0 Had potential that went unrealized. Three 3 \n",
1037
+ "1 The themes were solid, but not well explored. Three 3 \n",
1038
+ "2 It simply lacked that emotional punch. Three 3 \n",
1039
+ "3 Serviceable but not something I'd go out of my... Three 3 \n",
1040
+ "4 Standard fare with some promise. Three 3 \n"
1041
+ ]
1042
+ }
1043
+ ],
1044
+ "source": [
1045
+ "print(df_reviews.head())"
1046
+ ]
1047
  }
1048
  ],
1049
  "metadata": {