Christopher Capobianco
commited on
Commit
•
564354e
1
Parent(s):
431ca06
Add notebooks, requirements.txt and packages.txt
Browse files- notebooks/llama-3-fine-tune-gguf.ipynb +1 -0
- notebooks/llama-3-fine-tune-math-problems.ipynb +1 -0
- notebooks/llama-3-fine-tune-merge.ipynb +1 -0
- notebooks/llama-3-fine-tune-quantization.ipynb +1 -0
- notebooks/movie_recommendation.ipynb +1229 -0
- notebooks/music_model.ipynb +161 -0
- notebooks/stock_market_analysis.ipynb +1083 -0
- notebooks/stock_market_prediction.ipynb +0 -0
- notebooks/weather_classification.ipynb +0 -0
- packages.txt +1 -0
- requirements.txt +14 -0
notebooks/llama-3-fine-tune-gguf.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":202404401,"sourceType":"kernelVersion"}],"dockerImageVersionId":30787,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"%cd /kaggle/working\n!git clone --depth=1 https://github.com/ggerganov/llama.cpp.git\n%cd /kaggle/working/llama.cpp\n!sed -i 's|MK_LDFLAGS += -lcuda|MK_LDFLAGS += -L/usr/local/nvidia/lib64 -lcuda|' Makefile\n!LLAMA_CUDA=1 conda run -n base make -j > /dev/null","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:02:29.787915Z","iopub.execute_input":"2024-10-21T06:02:29.788543Z","iopub.status.idle":"2024-10-21T06:12:44.585370Z","shell.execute_reply.started":"2024-10-21T06:02:29.788500Z","shell.execute_reply":"2024-10-21T06:12:44.584243Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!python convert_hf_to_gguf.py /kaggle/input/llama-3-fine-tune-merge/llama-3.1-8b-chat-math-teacher/ \\\n --outfile /root/.cache/llama-3.1-8b-chat-math-teacher.gguf \\\n --outtype f16\n!rm -rf /kaggle/working/*\n!cp /root/.cache/llama-3.1-8b-chat-math-teacher.gguf /kaggle/working/","metadata":{"execution":{"iopub.status.busy":"2024-10-21T06:16:28.365798Z","iopub.execute_input":"2024-10-21T06:16:28.366128Z","iopub.status.idle":"2024-10-21T06:18:13.507912Z","shell.execute_reply.started":"2024-10-21T06:16:28.366093Z","shell.execute_reply":"2024-10-21T06:18:13.506745Z"},"trusted":true},"execution_count":null,"outputs":[]}]}
|
notebooks/llama-3-fine-tune-math-problems.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells":[{"cell_type":"code","execution_count":1,"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.execute_input":"2024-10-20T05:15:35.864396Z","iopub.status.busy":"2024-10-20T05:15:35.863473Z","iopub.status.idle":"2024-10-20T05:15:45.149676Z","shell.execute_reply":"2024-10-20T05:15:45.148906Z","shell.execute_reply.started":"2024-10-20T05:15:35.864342Z"},"trusted":true},"outputs":[],"source":["from transformers import (\n"," AutoModelForCausalLM,\n"," AutoTokenizer,\n"," BitsAndBytesConfig,\n"," HfArgumentParser,\n"," TrainingArguments,\n"," pipeline,\n"," logging,\n",")\n","from peft import (\n"," LoraConfig,\n"," PeftModel,\n"," prepare_model_for_kbit_training,\n"," get_peft_model,\n",")\n","import os, torch, wandb\n","from datasets import load_dataset\n","from trl import SFTTrainer, setup_chat_format"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:29:05.099594Z","iopub.status.busy":"2024-10-20T05:29:05.099135Z","iopub.status.idle":"2024-10-20T05:29:08.829349Z","shell.execute_reply":"2024-10-20T05:29:08.828348Z","shell.execute_reply.started":"2024-10-20T05:29:05.099552Z"},"trusted":true},"outputs":[],"source":["from huggingface_hub import login\n","from kaggle_secrets import UserSecretsClient\n","user_secrets = UserSecretsClient()\n","\n","hf_token = user_secrets.get_secret(\"HF_TOKEN\")\n","\n","login(token = hf_token)\n","\n","wb_token = user_secrets.get_secret(\"wandb\")\n","\n","wandb.login(key=wb_token)\n","run = wandb.init(\n"," project='Fine-tune Llama 3 8B on Mathematical Word Problems', \n"," job_type=\"training\", \n"," anonymous=\"allow\"\n",")"]},{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:15:45.405144Z","iopub.status.busy":"2024-10-20T05:15:45.404830Z","iopub.status.idle":"2024-10-20T05:15:45.409442Z","shell.execute_reply":"2024-10-20T05:15:45.408553Z","shell.execute_reply.started":"2024-10-20T05:15:45.405112Z"},"trusted":true},"outputs":[],"source":["base_model = \"/kaggle/input/llama-3.1/transformers/8b-instruct/2\"\n","dataset_name = \"microsoft/orca-math-word-problems-200k\"\n","new_model = \"llama-3.1-8b-chat-math-teacher\""]},{"cell_type":"code","execution_count":4,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:15:45.412376Z","iopub.status.busy":"2024-10-20T05:15:45.411921Z","iopub.status.idle":"2024-10-20T05:15:45.418455Z","shell.execute_reply":"2024-10-20T05:15:45.417527Z","shell.execute_reply.started":"2024-10-20T05:15:45.412338Z"},"trusted":true},"outputs":[],"source":["torch_dtype = torch.float16\n","attn_implementation = \"eager\""]},{"cell_type":"code","execution_count":5,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:15:45.419811Z","iopub.status.busy":"2024-10-20T05:15:45.419500Z","iopub.status.idle":"2024-10-20T05:15:45.428504Z","shell.execute_reply":"2024-10-20T05:15:45.427628Z","shell.execute_reply.started":"2024-10-20T05:15:45.419780Z"},"trusted":true},"outputs":[],"source":["# QLoRA config\n","bnb_config = BitsAndBytesConfig(\n"," load_in_4bit=True,\n"," bnb_4bit_quant_type=\"nf4\",\n"," bnb_4bit_compute_dtype=torch_dtype,\n"," bnb_4bit_use_double_quant=True,\n",")"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:19:33.334065Z","iopub.status.busy":"2024-10-20T05:19:33.332939Z","iopub.status.idle":"2024-10-20T05:20:18.698489Z","shell.execute_reply":"2024-10-20T05:20:18.697745Z","shell.execute_reply.started":"2024-10-20T05:19:33.334006Z"},"trusted":true},"outputs":[],"source":["# Load model\n","model = AutoModelForCausalLM.from_pretrained(\n"," base_model,\n"," quantization_config=bnb_config,\n"," device_map=\"auto\",\n"," attn_implementation=attn_implementation\n",")"]},{"cell_type":"code","execution_count":8,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:20:23.623910Z","iopub.status.busy":"2024-10-20T05:20:23.623492Z","iopub.status.idle":"2024-10-20T05:20:24.294298Z","shell.execute_reply":"2024-10-20T05:20:24.293468Z","shell.execute_reply.started":"2024-10-20T05:20:23.623870Z"},"trusted":true},"outputs":[],"source":["# Load tokenizer\n","tokenizer = AutoTokenizer.from_pretrained(base_model)\n","model, tokenizer = setup_chat_format(model, tokenizer)"]},{"cell_type":"code","execution_count":9,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:20:32.472505Z","iopub.status.busy":"2024-10-20T05:20:32.471630Z","iopub.status.idle":"2024-10-20T05:20:33.257761Z","shell.execute_reply":"2024-10-20T05:20:33.256711Z","shell.execute_reply.started":"2024-10-20T05:20:32.472461Z"},"trusted":true},"outputs":[],"source":["# LoRA config\n","peft_config = LoraConfig(\n"," r=16,\n"," lora_alpha=32,\n"," lora_dropout=0.05,\n"," bias=\"none\",\n"," task_type=\"CAUSAL_LM\",\n"," target_modules=['up_proj', 'down_proj', 'gate_proj', 'k_proj', 'q_proj', 'v_proj', 'o_proj']\n",")\n","model = get_peft_model(model, peft_config)"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:20:40.458399Z","iopub.status.busy":"2024-10-20T05:20:40.457863Z","iopub.status.idle":"2024-10-20T05:20:44.412895Z","shell.execute_reply":"2024-10-20T05:20:44.411800Z","shell.execute_reply.started":"2024-10-20T05:20:40.458348Z"},"trusted":true},"outputs":[],"source":["# Importing the dataset\n","dataset = load_dataset(dataset_name, split=\"all\")\n","dataset = dataset.shuffle(seed=42).select(range(1000)) # Only use 1000 samples for quick demo\n","\n","def format_chat_template(row):\n"," row_json = [{\"role\": \"user\", \"content\": row[\"question\"]},\n"," {\"role\": \"assistant\", \"content\": row[\"answer\"]}]\n"," row[\"text\"] = tokenizer.apply_chat_template(row_json, tokenize=False)\n"," return row\n","\n","dataset = dataset.map(\n"," format_chat_template,\n"," num_proc=4,\n",")\n","\n","dataset['text'][3]"]},{"cell_type":"code","execution_count":11,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:21:15.549983Z","iopub.status.busy":"2024-10-20T05:21:15.548983Z","iopub.status.idle":"2024-10-20T05:21:15.566472Z","shell.execute_reply":"2024-10-20T05:21:15.565431Z","shell.execute_reply.started":"2024-10-20T05:21:15.549934Z"},"trusted":true},"outputs":[],"source":["dataset = dataset.train_test_split(test_size=0.2)"]},{"cell_type":"code","execution_count":18,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:29:56.567672Z","iopub.status.busy":"2024-10-20T05:29:56.566941Z","iopub.status.idle":"2024-10-20T05:29:56.595910Z","shell.execute_reply":"2024-10-20T05:29:56.595117Z","shell.execute_reply.started":"2024-10-20T05:29:56.567628Z"},"trusted":true},"outputs":[],"source":["training_arguments = TrainingArguments(\n"," output_dir=new_model,\n"," per_device_train_batch_size=1,\n"," per_device_eval_batch_size=1,\n"," gradient_accumulation_steps=2,\n"," optim=\"paged_adamw_32bit\",\n"," num_train_epochs=1,\n"," eval_strategy=\"steps\",\n"," eval_steps=0.2,\n"," logging_steps=1,\n"," warmup_steps=10,\n"," logging_strategy=\"steps\",\n"," learning_rate=2e-4,\n"," fp16=False,\n"," bf16=False,\n"," group_by_length=True,\n"," report_to=\"wandb\"\n",")"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:30:01.680282Z","iopub.status.busy":"2024-10-20T05:30:01.679557Z","iopub.status.idle":"2024-10-20T05:30:03.062818Z","shell.execute_reply":"2024-10-20T05:30:03.061888Z","shell.execute_reply.started":"2024-10-20T05:30:01.680235Z"},"trusted":true},"outputs":[],"source":["trainer = SFTTrainer(\n"," model=model,\n"," train_dataset=dataset[\"train\"],\n"," eval_dataset=dataset[\"test\"],\n"," peft_config=peft_config,\n"," max_seq_length=512,\n"," dataset_text_field=\"text\",\n"," tokenizer=tokenizer,\n"," args=training_arguments,\n"," packing= False,\n",")"]},{"cell_type":"code","execution_count":20,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T05:30:06.284325Z","iopub.status.busy":"2024-10-20T05:30:06.283458Z","iopub.status.idle":"2024-10-20T06:12:45.133545Z","shell.execute_reply":"2024-10-20T06:12:45.132593Z","shell.execute_reply.started":"2024-10-20T05:30:06.284279Z"},"trusted":true},"outputs":[{"data":{"text/html":["\n"," <div>\n"," \n"," <progress value='400' max='400' style='width:300px; height:20px; vertical-align: middle;'></progress>\n"," [400/400 42:31, Epoch 1/1]\n"," </div>\n"," <table border=\"1\" class=\"dataframe\">\n"," <thead>\n"," <tr style=\"text-align: left;\">\n"," <th>Step</th>\n"," <th>Training Loss</th>\n"," <th>Validation Loss</th>\n"," </tr>\n"," </thead>\n"," <tbody>\n"," <tr>\n"," <td>80</td>\n"," <td>0.438500</td>\n"," <td>0.620739</td>\n"," </tr>\n"," <tr>\n"," <td>160</td>\n"," <td>0.396200</td>\n"," <td>0.606882</td>\n"," </tr>\n"," <tr>\n"," <td>240</td>\n"," <td>0.606400</td>\n"," <td>0.591038</td>\n"," </tr>\n"," <tr>\n"," <td>320</td>\n"," <td>0.565300</td>\n"," <td>0.583970</td>\n"," </tr>\n"," <tr>\n"," <td>400</td>\n"," <td>0.944000</td>\n"," <td>0.576970</td>\n"," </tr>\n"," </tbody>\n","</table><p>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"name":"stderr","output_type":"stream","text":["/opt/conda/lib/python3.10/site-packages/peft/utils/save_and_load.py:257: UserWarning: Setting `save_embedding_layers` to `True` as the embedding layer has been resized during finetuning.\n"," warnings.warn(\n"]}],"source":["history = trainer.train()"]},{"cell_type":"code","execution_count":21,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T06:12:45.135502Z","iopub.status.busy":"2024-10-20T06:12:45.135185Z","iopub.status.idle":"2024-10-20T06:12:46.781460Z","shell.execute_reply":"2024-10-20T06:12:46.780763Z","shell.execute_reply.started":"2024-10-20T06:12:45.135469Z"},"trusted":true},"outputs":[{"data":{"application/vnd.jupyter.widget-view+json":{"model_id":"","version_major":2,"version_minor":0},"text/plain":["VBox(children=(Label(value='0.028 MB of 0.028 MB uploaded\\r'), FloatProgress(value=1.0, max=1.0)))"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":["<style>\n"," table.wandb td:nth-child(1) { padding: 0 10px; text-align: left ; width: auto;} td:nth-child(2) {text-align: left ; width: 100%}\n"," .wandb-row { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; width: 100% }\n"," .wandb-col { display: flex; flex-direction: column; flex-basis: 100%; flex: 1; padding: 10px; }\n"," </style>\n","<div class=\"wandb-row\"><div class=\"wandb-col\"><h3>Run history:</h3><br/><table class=\"wandb\"><tr><td>eval/loss</td><td>█▆▃▂▁</td></tr><tr><td>eval/runtime</td><td>▃▅▆▁█</td></tr><tr><td>eval/samples_per_second</td><td>▁▁▁▁▁</td></tr><tr><td>eval/steps_per_second</td><td>▁▁▁▁▁</td></tr><tr><td>train/epoch</td><td>▁▁▁▁▁▂▂▂▂▂▂▂▃▃▃▃▄▄▄▄▄▄▄▅▅▅▅▅▆▆▇▇▇▇▇█████</td></tr><tr><td>train/global_step</td><td>▁▁▂▂▂▂▂▂▂▂▂▃▃▃▃▃▄▄▄▄▄▅▅▆▆▆▆▆▆▆▇▇▇▇▇█████</td></tr><tr><td>train/grad_norm</td><td>▄▃▅▃▃▁▂▃▂▂▃▁▂▃▂▃▅▇▂▂▂▄█▂▂▃▄▃▅▇▂▂▃▃▃▁▁▂▃▅</td></tr><tr><td>train/learning_rate</td><td>▂████▇▇▇▇▇▆▆▆▆▆▆▆▆▅▅▄▄▄▄▄▄▃▃▃▃▃▃▃▃▃▂▂▁▁▁</td></tr><tr><td>train/loss</td><td>▅▆▄▅▂▅▂▂▅▅▃▄▅▃▅▅▂▃▄▂▄▇▃▁▄▃▇▂▃▃▂▃▃▁▃▆▁▄▁█</td></tr></table><br/></div><div class=\"wandb-col\"><h3>Run summary:</h3><br/><table class=\"wandb\"><tr><td>eval/loss</td><td>0.57697</td></tr><tr><td>eval/runtime</td><td>195.8812</td></tr><tr><td>eval/samples_per_second</td><td>1.021</td></tr><tr><td>eval/steps_per_second</td><td>1.021</td></tr><tr><td>total_flos</td><td>1.1602099108503552e+16</td></tr><tr><td>train/epoch</td><td>1</td></tr><tr><td>train/global_step</td><td>400</td></tr><tr><td>train/grad_norm</td><td>1.6999</td></tr><tr><td>train/learning_rate</td><td>0</td></tr><tr><td>train/loss</td><td>0.944</td></tr><tr><td>train_loss</td><td>0.57197</td></tr><tr><td>train_runtime</td><td>2557.7609</td></tr><tr><td>train_samples_per_second</td><td>0.313</td></tr><tr><td>train_steps_per_second</td><td>0.156</td></tr></table><br/></div></div>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":[" View run <strong style=\"color:#cdcd00\">zesty-snowball-1</strong> at: <a href='https://wandb.ai/ccapo-astro-siaa-research/Fine-tune%20Llama%203%208B%20on%20Mathematical%20Word%20Problems/runs/n7jezz5x' target=\"_blank\">https://wandb.ai/ccapo-astro-siaa-research/Fine-tune%20Llama%203%208B%20on%20Mathematical%20Word%20Problems/runs/n7jezz5x</a><br/> View project at: <a href='https://wandb.ai/ccapo-astro-siaa-research/Fine-tune%20Llama%203%208B%20on%20Mathematical%20Word%20Problems' target=\"_blank\">https://wandb.ai/ccapo-astro-siaa-research/Fine-tune%20Llama%203%208B%20on%20Mathematical%20Word%20Problems</a><br/>Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 0 other file(s)"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"},{"data":{"text/html":["Find logs at: <code>./wandb/run-20241020_052905-n7jezz5x/logs</code>"],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{},"output_type":"display_data"}],"source":["wandb.finish()\n","model.config.use_cache = True"]},{"cell_type":"code","execution_count":29,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T06:25:32.333755Z","iopub.status.busy":"2024-10-20T06:25:32.332841Z","iopub.status.idle":"2024-10-20T06:26:06.729107Z","shell.execute_reply":"2024-10-20T06:26:06.728129Z","shell.execute_reply.started":"2024-10-20T06:25:32.333693Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["\n","Let's denote Parisa's current age as P and her mother's current age as M.\n","\n","According to the first condition, the age difference between Parisa and her mother is 40 years, so we can write:\n","\n","M = P + 40 (1)\n","\n","According to the second condition, after 15 years, the age of her mother will be three times that of Parisa. So we can write:\n","\n","M + 15 = 3 * (P + 15) (2)\n","\n","Now, let's substitute the expression for M from equation (1) into equation (2):\n","\n","(P + 40) + 15 = 3 * (P + 15)\n","\n","Now, let's solve for P:\n","\n","P + 40 + 15 = 3P + 45\n","\n","Combine like terms:\n","\n","P + 55 = 3P + 45\n","\n","Subtract P from both sides:\n","\n","55 = 2P + 45\n","\n","Subtract 45 from both sides:\n","\n","10 = 2P\n","\n","Divide both sides by 2:\n","\n","P = 5\n","\n","So, Parisa is currently 5 years old.\n","\n"]}],"source":["messages = [\n"," {\n"," \"role\": \"user\",\n"," \"content\": \"This year, the age difference between Parisa and her mother is 40 years, and after 15 years, the age of her mother will be three times that of Parisa. Find the age of Parisa this year.\"\n"," }\n","]\n","\n","prompt = tokenizer.apply_chat_template(messages, tokenize=False, \n"," add_generation_prompt=True)\n","\n","inputs = tokenizer(prompt, return_tensors='pt', padding=True, \n"," truncation=True).to(\"cuda\")\n","\n","outputs = model.generate(**inputs, max_length=300, \n"," num_return_sequences=1)\n","\n","text = tokenizer.decode(outputs[0], skip_special_tokens=True)\n","\n","print(text.split(\"assistant\")[1])"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-20T06:13:27.806915Z","iopub.status.busy":"2024-10-20T06:13:27.806495Z","iopub.status.idle":"2024-10-20T06:14:46.231972Z","shell.execute_reply":"2024-10-20T06:14:46.231004Z","shell.execute_reply.started":"2024-10-20T06:13:27.806870Z"},"trusted":true},"outputs":[],"source":["trainer.model.save_pretrained(new_model)\n","trainer.model.push_to_hub(new_model, use_temp_dir=False)"]}],"metadata":{"kaggle":{"accelerator":"gpu","dataSources":[{"isSourceIdPinned":true,"modelId":91102,"modelInstanceId":68809,"sourceId":104449,"sourceType":"modelInstanceVersion"}],"dockerImageVersionId":30787,"isGpuEnabled":true,"isInternetEnabled":true,"language":"python","sourceType":"notebook"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"}},"nbformat":4,"nbformat_minor":4}
|
notebooks/llama-3-fine-tune-merge.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:02:45.320064Z","iopub.status.busy":"2024-10-21T05:02:45.319624Z","iopub.status.idle":"2024-10-21T05:02:46.019192Z","shell.execute_reply":"2024-10-21T05:02:46.018223Z","shell.execute_reply.started":"2024-10-21T05:02:45.320020Z"},"trusted":true},"outputs":[],"source":["from huggingface_hub import login\n","from kaggle_secrets import UserSecretsClient\n","user_secrets = UserSecretsClient()\n","\n","hf_token = user_secrets.get_secret(\"HF_TOKEN\")\n","login(token = hf_token)"]},{"cell_type":"code","execution_count":2,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:02:46.024625Z","iopub.status.busy":"2024-10-21T05:02:46.024248Z","iopub.status.idle":"2024-10-21T05:02:46.028844Z","shell.execute_reply":"2024-10-21T05:02:46.027966Z","shell.execute_reply.started":"2024-10-21T05:02:46.024574Z"},"trusted":true},"outputs":[],"source":["base_model = \"/kaggle/input/llama-3.1/transformers/8b-instruct/2\"\n","new_model = \"/kaggle/input/llama-3-fine-tune-math-problems/llama-3.1-8b-chat-math-teacher/\""]},{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:02:46.030396Z","iopub.status.busy":"2024-10-21T05:02:46.030104Z","iopub.status.idle":"2024-10-21T05:02:53.155455Z","shell.execute_reply":"2024-10-21T05:02:53.154615Z","shell.execute_reply.started":"2024-10-21T05:02:46.030364Z"},"trusted":true},"outputs":[],"source":["from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline\n","from peft import PeftModel\n","import torch\n","from trl import setup_chat_format"]},{"cell_type":"markdown","metadata":{},"source":["## Note\n","Depending on the base model size, the following commands may require a GPU with more memory or multiple GPUs"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:02:53.158650Z","iopub.status.busy":"2024-10-21T05:02:53.157906Z","iopub.status.idle":"2024-10-21T05:04:28.373624Z","shell.execute_reply":"2024-10-21T05:04:28.372521Z","shell.execute_reply.started":"2024-10-21T05:02:53.158601Z"},"trusted":true},"outputs":[],"source":["# Reload tokenizer and model\n","tokenizer = AutoTokenizer.from_pretrained(base_model)\n","\n","base_model_reload = AutoModelForCausalLM.from_pretrained(\n"," base_model,\n"," return_dict=True,\n"," low_cpu_mem_usage=True,\n"," torch_dtype=torch.float16,\n"," device_map=\"auto\",\n"," trust_remote_code=True,\n"," offload_buffers=True,\n",")\n","\n","base_model_reload, tokenizer = setup_chat_format(base_model_reload, tokenizer)\n","\n","# Merge adapter with base model\n","model = PeftModel.from_pretrained(base_model_reload, new_model)\n","\n","model = model.merge_and_unload()"]},{"cell_type":"code","execution_count":7,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:07:43.870798Z","iopub.status.busy":"2024-10-21T05:07:43.869721Z","iopub.status.idle":"2024-10-21T05:08:04.414201Z","shell.execute_reply":"2024-10-21T05:08:04.413170Z","shell.execute_reply.started":"2024-10-21T05:07:43.870731Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["<|im_start|>user\n","Find the sum of all multiples of 9 that are less than 100.<|im_end|>\n","<|im_start|>assistant\n","To find the sum of all multiples of 9 that are less than 100, we first need to identify the last multiple of 9 that is less than 100. Since 99 is the largest multiple of 9 less than 100, we will use that number.\n","\n","The formula to find the sum of an arithmetic series is:\n","\n","Sum = n/2 * (first term + last term)\n","\n","Where n is the number of terms in the series.\n","\n","The first term is the first multiple of 9, which is 9, and the last term is 99. To find the number of terms (n), we can use the formula:\n","\n","n = (last term - first term) / common difference + 1\n","\n","In this case, the common difference is 9, since we are adding 9 to get from one multiple to the next.\n","\n","So, let's calculate:\n","\n","n = (99 - 9) / 9 + 1\n","n = 90 / 9 + 1\n","n = 10 + 1\n","n = 11\n","\n","Now we can find the sum:\n","\n","Sum = 11/2 * (9 + 99)\n","Sum = 11/2 * 108\n","Sum = 5.5 * 108\n","Sum = 594\n","\n","Therefore, the sum of all multiples of 9 that are less than 100 is 594.\n","assistant\n","The sum of all multiples of 9 that are less than \n"]}],"source":["messages = [{\"role\": \"user\", \"content\": \"Find the sum of all multiples of 9 that are less than 100.\"}]\n","\n","prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)\n","pipe = pipeline(\n"," \"text-generation\",\n"," model=model,\n"," tokenizer=tokenizer,\n"," torch_dtype=torch.float16,\n"," device_map=\"auto\",\n",")\n","\n","outputs = pipe(prompt, max_new_tokens=300, do_sample=True, temperature=0.7, top_k=50, top_p=0.95)\n","print(outputs[0][\"generated_text\"])"]},{"cell_type":"code","execution_count":8,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:11:53.899166Z","iopub.status.busy":"2024-10-21T05:11:53.898412Z","iopub.status.idle":"2024-10-21T05:12:51.165328Z","shell.execute_reply":"2024-10-21T05:12:51.164303Z","shell.execute_reply.started":"2024-10-21T05:11:53.899120Z"},"trusted":true},"outputs":[{"data":{"text/plain":["('llama-3.1-8b-chat-math-teacher/tokenizer_config.json',\n"," 'llama-3.1-8b-chat-math-teacher/special_tokens_map.json',\n"," 'llama-3.1-8b-chat-math-teacher/tokenizer.json')"]},"execution_count":8,"metadata":{},"output_type":"execute_result"}],"source":["model.save_pretrained(\"llama-3.1-8b-chat-math-teacher\")\n","tokenizer.save_pretrained(\"llama-3.1-8b-chat-math-teacher\")"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T05:13:06.910077Z","iopub.status.busy":"2024-10-21T05:13:06.909659Z","iopub.status.idle":"2024-10-21T05:17:56.332173Z","shell.execute_reply":"2024-10-21T05:17:56.331177Z","shell.execute_reply.started":"2024-10-21T05:13:06.910038Z"},"trusted":true},"outputs":[],"source":["model.push_to_hub(\"llama-3.1-8b-chat-math-teacher\", use_temp_dir=False)\n","tokenizer.push_to_hub(\"llama-3.1-8b-chat-math-teacher\", use_temp_dir=False)"]}],"metadata":{"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":202208119,"sourceType":"kernelVersion"},{"isSourceIdPinned":true,"modelId":91102,"modelInstanceId":68809,"sourceId":104449,"sourceType":"modelInstanceVersion"}],"dockerImageVersionId":30787,"isGpuEnabled":true,"isInternetEnabled":true,"language":"python","sourceType":"notebook"},"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"}},"nbformat":4,"nbformat_minor":4}
|
notebooks/llama-3-fine-tune-quantization.ipynb
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"cells":[{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T19:51:11.362685Z","iopub.status.busy":"2024-10-21T19:51:11.362279Z","iopub.status.idle":"2024-10-21T20:01:23.251497Z","shell.execute_reply":"2024-10-21T20:01:23.250324Z","shell.execute_reply.started":"2024-10-21T19:51:11.362647Z"},"trusted":true},"outputs":[],"source":["%cd /kaggle/working\n","!git clone --depth=1 https://github.com/ggerganov/llama.cpp.git\n","%cd /kaggle/working/llama.cpp\n","!sed -i 's|MK_LDFLAGS += -lcuda|MK_LDFLAGS += -L/usr/local/nvidia/lib64 -lcuda|' Makefile\n","!LLAMA_CUDA=1 conda run -n base make -j > /dev/null"]},{"cell_type":"code","execution_count":4,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T15:49:55.214707Z","iopub.status.busy":"2024-10-21T15:49:55.214216Z","iopub.status.idle":"2024-10-21T15:57:54.086080Z","shell.execute_reply":"2024-10-21T15:57:54.084916Z","shell.execute_reply.started":"2024-10-21T15:49:55.214666Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["/kaggle/working\n","main: build = 1 (f594bc8)\n","main: built with cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 for x86_64-linux-gnu\n","main: quantizing '/kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf' to 'llama-3.1-8b-chat-math-teacher-Q4_K_M.gguf' as Q4_K_M\n","llama_model_loader: loaded meta data with 29 key-value pairs and 292 tensors from /kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf (version GGUF V3 (latest))\n","llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n","llama_model_loader: - kv 0: general.architecture str = llama\n","llama_model_loader: - kv 1: general.type str = model\n","llama_model_loader: - kv 2: general.name str = Llama 3.1 8b Chat Math Teacher\n","llama_model_loader: - kv 3: general.finetune str = chat-math-teacher\n","llama_model_loader: - kv 4: general.basename str = llama-3.1\n","llama_model_loader: - kv 5: general.size_label str = 8B\n","llama_model_loader: - kv 6: llama.block_count u32 = 32\n","llama_model_loader: - kv 7: llama.context_length u32 = 131072\n","llama_model_loader: - kv 8: llama.embedding_length u32 = 4096\n","llama_model_loader: - kv 9: llama.feed_forward_length u32 = 14336\n","llama_model_loader: - kv 10: llama.attention.head_count u32 = 32\n","llama_model_loader: - kv 11: llama.attention.head_count_kv u32 = 8\n","llama_model_loader: - kv 12: llama.rope.freq_base f32 = 500000.000000\n","llama_model_loader: - kv 13: llama.attention.layer_norm_rms_epsilon f32 = 0.000010\n","llama_model_loader: - kv 14: llama.attention.key_length u32 = 128\n","llama_model_loader: - kv 15: llama.attention.value_length u32 = 128\n","llama_model_loader: - kv 16: general.file_type u32 = 1\n","llama_model_loader: - kv 17: llama.vocab_size u32 = 128258\n","llama_model_loader: - kv 18: llama.rope.dimension_count u32 = 128\n","llama_model_loader: - kv 19: tokenizer.ggml.model str = gpt2\n","llama_model_loader: - kv 20: tokenizer.ggml.pre str = llama-bpe\n","llama_model_loader: - kv 21: tokenizer.ggml.tokens arr[str,128258] = [\"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\", ...\n","llama_model_loader: - kv 22: tokenizer.ggml.token_type arr[i32,128258] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...\n","llama_model_loader: - kv 23: tokenizer.ggml.merges arr[str,280147] = [\"Ġ Ġ\", \"Ġ ĠĠĠ\", \"ĠĠ ĠĠ\", \"...\n","llama_model_loader: - kv 24: tokenizer.ggml.bos_token_id u32 = 128256\n","llama_model_loader: - kv 25: tokenizer.ggml.eos_token_id u32 = 128257\n","llama_model_loader: - kv 26: tokenizer.ggml.padding_token_id u32 = 128257\n","llama_model_loader: - kv 27: tokenizer.chat_template str = {% for message in messages %}{{'<|im_...\n","llama_model_loader: - kv 28: general.quantization_version u32 = 2\n","llama_model_loader: - type f32: 66 tensors\n","llama_model_loader: - type f16: 226 tensors\n","[ 1/ 292] rope_freqs.weight - [ 64, 1, 1, 1], type = f32, size = 0.000 MB\n","[ 2/ 292] token_embd.weight - [ 4096, 128258, 1, 1], type = f16, converting to q4_K .. size = 1002.02 MiB -> 281.82 MiB\n","[ 3/ 292] blk.0.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 4/ 292] blk.0.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 5/ 292] blk.0.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 6/ 292] blk.0.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 7/ 292] blk.0.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 8/ 292] blk.0.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 9/ 292] blk.0.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 10/ 292] blk.0.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 11/ 292] blk.0.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 12/ 292] blk.1.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 13/ 292] blk.1.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 14/ 292] blk.1.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 15/ 292] blk.1.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 16/ 292] blk.1.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 17/ 292] blk.1.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 18/ 292] blk.1.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 19/ 292] blk.1.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 20/ 292] blk.1.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 21/ 292] blk.2.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 22/ 292] blk.2.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 23/ 292] blk.2.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 24/ 292] blk.2.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 25/ 292] blk.2.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 26/ 292] blk.2.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 27/ 292] blk.2.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 28/ 292] blk.2.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 29/ 292] blk.2.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 30/ 292] blk.3.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 31/ 292] blk.3.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 32/ 292] blk.3.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 33/ 292] blk.3.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 34/ 292] blk.3.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 35/ 292] blk.3.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 36/ 292] blk.3.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 37/ 292] blk.3.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 38/ 292] blk.3.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 39/ 292] blk.4.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 40/ 292] blk.4.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 41/ 292] blk.4.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 42/ 292] blk.4.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 43/ 292] blk.4.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 44/ 292] blk.4.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 45/ 292] blk.4.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 46/ 292] blk.4.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 47/ 292] blk.4.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 48/ 292] blk.5.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 49/ 292] blk.5.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 50/ 292] blk.5.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 51/ 292] blk.5.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 52/ 292] blk.5.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 53/ 292] blk.5.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 54/ 292] blk.5.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 55/ 292] blk.5.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 56/ 292] blk.5.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 57/ 292] blk.6.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 58/ 292] blk.6.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 59/ 292] blk.6.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 60/ 292] blk.6.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 61/ 292] blk.6.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 62/ 292] blk.6.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 63/ 292] blk.6.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 64/ 292] blk.6.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 65/ 292] blk.6.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 66/ 292] blk.7.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 67/ 292] blk.7.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 68/ 292] blk.7.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 69/ 292] blk.7.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 70/ 292] blk.7.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 71/ 292] blk.7.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 72/ 292] blk.7.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 73/ 292] blk.7.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 74/ 292] blk.7.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 75/ 292] blk.8.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 76/ 292] blk.8.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 77/ 292] blk.8.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 78/ 292] blk.8.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 79/ 292] blk.8.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 80/ 292] blk.8.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 81/ 292] blk.8.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 82/ 292] blk.8.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 83/ 292] blk.8.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 84/ 292] blk.10.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 85/ 292] blk.10.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 86/ 292] blk.10.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 87/ 292] blk.10.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 88/ 292] blk.10.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 89/ 292] blk.10.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 90/ 292] blk.10.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 91/ 292] blk.10.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 92/ 292] blk.10.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 93/ 292] blk.11.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 94/ 292] blk.11.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 95/ 292] blk.11.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 96/ 292] blk.11.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 97/ 292] blk.11.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 98/ 292] blk.11.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 99/ 292] blk.11.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 100/ 292] blk.11.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 101/ 292] blk.11.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 102/ 292] blk.12.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 103/ 292] blk.12.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 104/ 292] blk.12.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 105/ 292] blk.12.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 106/ 292] blk.12.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 107/ 292] blk.12.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 108/ 292] blk.12.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 109/ 292] blk.12.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 110/ 292] blk.12.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 111/ 292] blk.13.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 112/ 292] blk.13.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 113/ 292] blk.13.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 114/ 292] blk.13.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 115/ 292] blk.13.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 116/ 292] blk.13.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 117/ 292] blk.13.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 118/ 292] blk.13.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 119/ 292] blk.13.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 120/ 292] blk.14.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 121/ 292] blk.14.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 122/ 292] blk.14.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 123/ 292] blk.14.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 124/ 292] blk.14.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 125/ 292] blk.14.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 126/ 292] blk.14.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 127/ 292] blk.14.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 128/ 292] blk.14.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 129/ 292] blk.15.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 130/ 292] blk.15.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 131/ 292] blk.15.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 132/ 292] blk.15.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 133/ 292] blk.15.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 134/ 292] blk.15.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 135/ 292] blk.15.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 136/ 292] blk.15.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 137/ 292] blk.15.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 138/ 292] blk.16.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 139/ 292] blk.16.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 140/ 292] blk.16.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 141/ 292] blk.16.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 142/ 292] blk.16.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 143/ 292] blk.16.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 144/ 292] blk.16.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 145/ 292] blk.16.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 146/ 292] blk.16.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 147/ 292] blk.17.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 148/ 292] blk.17.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 149/ 292] blk.17.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 150/ 292] blk.17.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 151/ 292] blk.17.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 152/ 292] blk.17.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 153/ 292] blk.17.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 154/ 292] blk.17.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 155/ 292] blk.17.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 156/ 292] blk.18.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 157/ 292] blk.18.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 158/ 292] blk.18.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 159/ 292] blk.18.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 160/ 292] blk.18.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 161/ 292] blk.18.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 162/ 292] blk.18.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 163/ 292] blk.18.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 164/ 292] blk.18.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 165/ 292] blk.19.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 166/ 292] blk.19.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 167/ 292] blk.19.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 168/ 292] blk.19.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 169/ 292] blk.19.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 170/ 292] blk.19.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 171/ 292] blk.19.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 172/ 292] blk.19.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 173/ 292] blk.19.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 174/ 292] blk.20.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 175/ 292] blk.20.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 176/ 292] blk.20.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 177/ 292] blk.20.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 178/ 292] blk.20.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 179/ 292] blk.9.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 180/ 292] blk.9.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 181/ 292] blk.9.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 182/ 292] blk.9.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 183/ 292] blk.9.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 184/ 292] blk.9.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 185/ 292] blk.9.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 186/ 292] blk.9.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 187/ 292] blk.9.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 188/ 292] blk.20.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 189/ 292] blk.20.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 190/ 292] blk.20.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 191/ 292] blk.20.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 192/ 292] blk.21.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 193/ 292] blk.21.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 194/ 292] blk.21.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 195/ 292] blk.21.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 196/ 292] blk.21.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 197/ 292] blk.21.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 198/ 292] blk.21.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 199/ 292] blk.21.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 200/ 292] blk.21.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 201/ 292] blk.22.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 202/ 292] blk.22.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 203/ 292] blk.22.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 204/ 292] blk.22.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 205/ 292] blk.22.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 206/ 292] blk.22.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 207/ 292] blk.22.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 208/ 292] blk.22.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 209/ 292] blk.22.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 210/ 292] blk.23.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 211/ 292] blk.23.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 212/ 292] blk.23.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 213/ 292] blk.23.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 214/ 292] blk.23.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 215/ 292] blk.23.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 216/ 292] blk.23.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 217/ 292] blk.23.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 218/ 292] blk.23.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 219/ 292] blk.24.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 220/ 292] blk.24.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 221/ 292] blk.24.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 222/ 292] blk.24.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 223/ 292] blk.24.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 224/ 292] blk.24.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 225/ 292] blk.24.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 226/ 292] blk.24.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 227/ 292] blk.24.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 228/ 292] blk.25.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 229/ 292] blk.25.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 230/ 292] blk.25.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 231/ 292] blk.25.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 232/ 292] blk.25.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 233/ 292] blk.25.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 234/ 292] blk.25.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 235/ 292] blk.25.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 236/ 292] blk.25.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 237/ 292] blk.26.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 238/ 292] blk.26.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 239/ 292] blk.26.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 240/ 292] blk.26.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 241/ 292] blk.26.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 242/ 292] blk.26.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 243/ 292] blk.26.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 244/ 292] blk.26.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 245/ 292] blk.26.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 246/ 292] blk.27.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 247/ 292] blk.27.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 248/ 292] blk.27.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 249/ 292] blk.27.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 250/ 292] blk.27.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 251/ 292] blk.27.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 252/ 292] blk.27.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 253/ 292] blk.27.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 254/ 292] blk.27.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 255/ 292] blk.28.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 256/ 292] blk.28.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 257/ 292] blk.28.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 258/ 292] blk.28.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 259/ 292] blk.28.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 260/ 292] blk.28.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 261/ 292] blk.28.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 262/ 292] blk.28.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 263/ 292] blk.28.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 264/ 292] blk.29.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 265/ 292] blk.29.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 266/ 292] blk.29.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 267/ 292] blk.29.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 268/ 292] blk.29.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 269/ 292] blk.29.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 270/ 292] blk.29.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 271/ 292] blk.29.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 272/ 292] blk.29.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 273/ 292] blk.30.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 274/ 292] blk.30.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 275/ 292] blk.30.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 276/ 292] blk.30.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 277/ 292] blk.30.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 278/ 292] blk.30.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 279/ 292] blk.30.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 280/ 292] blk.30.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 281/ 292] blk.30.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 282/ 292] blk.31.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 283/ 292] blk.31.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q4_K .. size = 112.00 MiB -> 31.50 MiB\n","[ 284/ 292] blk.31.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q4_K .. size = 8.00 MiB -> 2.25 MiB\n","[ 285/ 292] blk.31.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 286/ 292] blk.31.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q4_K .. size = 32.00 MiB -> 9.00 MiB\n","[ 287/ 292] blk.31.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 288/ 292] output.weight - [ 4096, 128258, 1, 1], type = f16, converting to q6_K .. size = 1002.02 MiB -> 410.98 MiB\n","[ 289/ 292] blk.31.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 290/ 292] blk.31.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 291/ 292] blk.31.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 292/ 292] output_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","llama_model_quantize_internal: model size = 15317.05 MB\n","llama_model_quantize_internal: quant size = 4685.32 MB\n","\n","main: quantize time = 477445.76 ms\n","main: total time = 477445.76 ms\n"]}],"source":["%cd /kaggle/working/\n","\n","!./llama.cpp/llama-quantize /kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf llama-3.1-8b-chat-math-teacher-Q4_K_M.gguf Q4_K_M"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T16:00:12.636327Z","iopub.status.busy":"2024-10-21T16:00:12.635944Z","iopub.status.idle":"2024-10-21T16:00:26.605944Z","shell.execute_reply":"2024-10-21T16:00:26.605019Z","shell.execute_reply.started":"2024-10-21T16:00:12.636283Z"},"trusted":true},"outputs":[],"source":["from huggingface_hub import login\n","from kaggle_secrets import UserSecretsClient\n","from huggingface_hub import HfApi\n","user_secrets = UserSecretsClient()\n","hf_token = user_secrets.get_secret(\"HF_TOKEN\")\n","login(token = hf_token)\n","\n","api = HfApi()\n","api.upload_file(\n"," path_or_fileobj=\"/kaggle/working/llama-3.1-8b-chat-math-teacher-Q4_K_M.gguf\",\n"," path_in_repo=\"llama-3.1-8b-chat-math-teacher-Q4_K_M.gguf\",\n"," repo_id=\"ccapo/llama-3.1-8b-chat-math-teacher-GGUF\",\n"," repo_type=\"model\",\n",")"]},{"cell_type":"code","execution_count":3,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T20:01:23.254013Z","iopub.status.busy":"2024-10-21T20:01:23.253672Z","iopub.status.idle":"2024-10-21T20:08:36.313423Z","shell.execute_reply":"2024-10-21T20:08:36.312210Z","shell.execute_reply.started":"2024-10-21T20:01:23.253978Z"},"trusted":true},"outputs":[{"name":"stdout","output_type":"stream","text":["/kaggle/working\n","main: build = 1 (994cfb1)\n","main: built with cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 for x86_64-linux-gnu\n","main: quantizing '/kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf' to 'llama-3.1-8b-chat-math-teacher-Q5_K_M.gguf' as Q5_K_M\n","llama_model_loader: loaded meta data with 29 key-value pairs and 292 tensors from /kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf (version GGUF V3 (latest))\n","llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.\n","llama_model_loader: - kv 0: general.architecture str = llama\n","llama_model_loader: - kv 1: general.type str = model\n","llama_model_loader: - kv 2: general.name str = Llama 3.1 8b Chat Math Teacher\n","llama_model_loader: - kv 3: general.finetune str = chat-math-teacher\n","llama_model_loader: - kv 4: general.basename str = llama-3.1\n","llama_model_loader: - kv 5: general.size_label str = 8B\n","llama_model_loader: - kv 6: llama.block_count u32 = 32\n","llama_model_loader: - kv 7: llama.context_length u32 = 131072\n","llama_model_loader: - kv 8: llama.embedding_length u32 = 4096\n","llama_model_loader: - kv 9: llama.feed_forward_length u32 = 14336\n","llama_model_loader: - kv 10: llama.attention.head_count u32 = 32\n","llama_model_loader: - kv 11: llama.attention.head_count_kv u32 = 8\n","llama_model_loader: - kv 12: llama.rope.freq_base f32 = 500000.000000\n","llama_model_loader: - kv 13: llama.attention.layer_norm_rms_epsilon f32 = 0.000010\n","llama_model_loader: - kv 14: llama.attention.key_length u32 = 128\n","llama_model_loader: - kv 15: llama.attention.value_length u32 = 128\n","llama_model_loader: - kv 16: general.file_type u32 = 1\n","llama_model_loader: - kv 17: llama.vocab_size u32 = 128258\n","llama_model_loader: - kv 18: llama.rope.dimension_count u32 = 128\n","llama_model_loader: - kv 19: tokenizer.ggml.model str = gpt2\n","llama_model_loader: - kv 20: tokenizer.ggml.pre str = llama-bpe\n","llama_model_loader: - kv 21: tokenizer.ggml.tokens arr[str,128258] = [\"!\", \"\\\"\", \"#\", \"$\", \"%\", \"&\", \"'\", ...\n","llama_model_loader: - kv 22: tokenizer.ggml.token_type arr[i32,128258] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ...\n","llama_model_loader: - kv 23: tokenizer.ggml.merges arr[str,280147] = [\"Ġ Ġ\", \"Ġ ĠĠĠ\", \"ĠĠ ĠĠ\", \"...\n","llama_model_loader: - kv 24: tokenizer.ggml.bos_token_id u32 = 128256\n","llama_model_loader: - kv 25: tokenizer.ggml.eos_token_id u32 = 128257\n","llama_model_loader: - kv 26: tokenizer.ggml.padding_token_id u32 = 128257\n","llama_model_loader: - kv 27: tokenizer.chat_template str = {% for message in messages %}{{'<|im_...\n","llama_model_loader: - kv 28: general.quantization_version u32 = 2\n","llama_model_loader: - type f32: 66 tensors\n","llama_model_loader: - type f16: 226 tensors\n","[ 1/ 292] rope_freqs.weight - [ 64, 1, 1, 1], type = f32, size = 0.000 MB\n","[ 2/ 292] token_embd.weight - [ 4096, 128258, 1, 1], type = f16, converting to q5_K .. size = 1002.02 MiB -> 344.44 MiB\n","[ 3/ 292] blk.0.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 4/ 292] blk.0.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 5/ 292] blk.0.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 6/ 292] blk.0.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 7/ 292] blk.0.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 8/ 292] blk.0.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 9/ 292] blk.0.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 10/ 292] blk.0.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 11/ 292] blk.0.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 12/ 292] blk.1.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 13/ 292] blk.1.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 14/ 292] blk.1.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 15/ 292] blk.1.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 16/ 292] blk.1.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 17/ 292] blk.1.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 18/ 292] blk.1.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 19/ 292] blk.1.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 20/ 292] blk.1.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 21/ 292] blk.2.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 22/ 292] blk.2.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 23/ 292] blk.2.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 24/ 292] blk.2.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 25/ 292] blk.2.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 26/ 292] blk.2.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 27/ 292] blk.2.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 28/ 292] blk.2.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 29/ 292] blk.2.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 30/ 292] blk.3.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 31/ 292] blk.3.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 32/ 292] blk.3.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 33/ 292] blk.3.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 34/ 292] blk.3.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 35/ 292] blk.3.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 36/ 292] blk.3.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 37/ 292] blk.3.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 38/ 292] blk.3.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 39/ 292] blk.4.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 40/ 292] blk.4.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 41/ 292] blk.4.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 42/ 292] blk.4.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 43/ 292] blk.4.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 44/ 292] blk.4.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 45/ 292] blk.4.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 46/ 292] blk.4.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 47/ 292] blk.4.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 48/ 292] blk.5.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 49/ 292] blk.5.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 50/ 292] blk.5.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 51/ 292] blk.5.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 52/ 292] blk.5.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 53/ 292] blk.5.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 54/ 292] blk.5.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 55/ 292] blk.5.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 56/ 292] blk.5.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 57/ 292] blk.6.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 58/ 292] blk.6.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 59/ 292] blk.6.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 60/ 292] blk.6.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 61/ 292] blk.6.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 62/ 292] blk.6.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 63/ 292] blk.6.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 64/ 292] blk.6.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 65/ 292] blk.6.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 66/ 292] blk.7.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 67/ 292] blk.7.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 68/ 292] blk.7.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 69/ 292] blk.7.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 70/ 292] blk.7.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 71/ 292] blk.7.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 72/ 292] blk.7.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 73/ 292] blk.7.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 74/ 292] blk.7.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 75/ 292] blk.8.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 76/ 292] blk.8.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 77/ 292] blk.8.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 78/ 292] blk.8.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 79/ 292] blk.8.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 80/ 292] blk.8.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 81/ 292] blk.8.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 82/ 292] blk.8.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 83/ 292] blk.8.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 84/ 292] blk.10.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 85/ 292] blk.10.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 86/ 292] blk.10.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 87/ 292] blk.10.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 88/ 292] blk.10.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 89/ 292] blk.10.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 90/ 292] blk.10.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 91/ 292] blk.10.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 92/ 292] blk.10.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 93/ 292] blk.11.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 94/ 292] blk.11.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 95/ 292] blk.11.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 96/ 292] blk.11.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 97/ 292] blk.11.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 98/ 292] blk.11.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 99/ 292] blk.11.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 100/ 292] blk.11.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 101/ 292] blk.11.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 102/ 292] blk.12.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 103/ 292] blk.12.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 104/ 292] blk.12.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 105/ 292] blk.12.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 106/ 292] blk.12.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 107/ 292] blk.12.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 108/ 292] blk.12.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 109/ 292] blk.12.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 110/ 292] blk.12.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 111/ 292] blk.13.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 112/ 292] blk.13.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 113/ 292] blk.13.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 114/ 292] blk.13.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 115/ 292] blk.13.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 116/ 292] blk.13.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 117/ 292] blk.13.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 118/ 292] blk.13.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 119/ 292] blk.13.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 120/ 292] blk.14.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 121/ 292] blk.14.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 122/ 292] blk.14.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 123/ 292] blk.14.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 124/ 292] blk.14.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 125/ 292] blk.14.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 126/ 292] blk.14.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 127/ 292] blk.14.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 128/ 292] blk.14.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 129/ 292] blk.15.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 130/ 292] blk.15.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 131/ 292] blk.15.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 132/ 292] blk.15.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 133/ 292] blk.15.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 134/ 292] blk.15.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 135/ 292] blk.15.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 136/ 292] blk.15.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 137/ 292] blk.15.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 138/ 292] blk.16.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 139/ 292] blk.16.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 140/ 292] blk.16.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 141/ 292] blk.16.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 142/ 292] blk.16.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 143/ 292] blk.16.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 144/ 292] blk.16.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 145/ 292] blk.16.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 146/ 292] blk.16.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 147/ 292] blk.17.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 148/ 292] blk.17.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 149/ 292] blk.17.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 150/ 292] blk.17.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 151/ 292] blk.17.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 152/ 292] blk.17.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 153/ 292] blk.17.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 154/ 292] blk.17.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 155/ 292] blk.17.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 156/ 292] blk.18.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 157/ 292] blk.18.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 158/ 292] blk.18.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 159/ 292] blk.18.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 160/ 292] blk.18.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 161/ 292] blk.18.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 162/ 292] blk.18.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 163/ 292] blk.18.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 164/ 292] blk.18.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 165/ 292] blk.19.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 166/ 292] blk.19.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 167/ 292] blk.19.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 168/ 292] blk.19.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 169/ 292] blk.19.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 170/ 292] blk.19.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 171/ 292] blk.19.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 172/ 292] blk.19.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 173/ 292] blk.19.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 174/ 292] blk.20.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 175/ 292] blk.20.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 176/ 292] blk.20.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 177/ 292] blk.20.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 178/ 292] blk.20.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 179/ 292] blk.9.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 180/ 292] blk.9.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 181/ 292] blk.9.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 182/ 292] blk.9.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 183/ 292] blk.9.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 184/ 292] blk.9.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 185/ 292] blk.9.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 186/ 292] blk.9.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 187/ 292] blk.9.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 188/ 292] blk.20.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 189/ 292] blk.20.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 190/ 292] blk.20.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 191/ 292] blk.20.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 192/ 292] blk.21.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 193/ 292] blk.21.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 194/ 292] blk.21.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 195/ 292] blk.21.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 196/ 292] blk.21.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 197/ 292] blk.21.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 198/ 292] blk.21.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 199/ 292] blk.21.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 200/ 292] blk.21.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 201/ 292] blk.22.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 202/ 292] blk.22.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 203/ 292] blk.22.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 204/ 292] blk.22.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 205/ 292] blk.22.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 206/ 292] blk.22.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 207/ 292] blk.22.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 208/ 292] blk.22.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 209/ 292] blk.22.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 210/ 292] blk.23.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 211/ 292] blk.23.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 212/ 292] blk.23.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 213/ 292] blk.23.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 214/ 292] blk.23.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 215/ 292] blk.23.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 216/ 292] blk.23.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 217/ 292] blk.23.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 218/ 292] blk.23.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 219/ 292] blk.24.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 220/ 292] blk.24.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 221/ 292] blk.24.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 222/ 292] blk.24.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 223/ 292] blk.24.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 224/ 292] blk.24.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 225/ 292] blk.24.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 226/ 292] blk.24.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 227/ 292] blk.24.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 228/ 292] blk.25.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 229/ 292] blk.25.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 230/ 292] blk.25.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 231/ 292] blk.25.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 232/ 292] blk.25.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 233/ 292] blk.25.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 234/ 292] blk.25.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 235/ 292] blk.25.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 236/ 292] blk.25.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 237/ 292] blk.26.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 238/ 292] blk.26.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 239/ 292] blk.26.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 240/ 292] blk.26.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 241/ 292] blk.26.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 242/ 292] blk.26.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 243/ 292] blk.26.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 244/ 292] blk.26.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 245/ 292] blk.26.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 246/ 292] blk.27.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 247/ 292] blk.27.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 248/ 292] blk.27.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 249/ 292] blk.27.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 250/ 292] blk.27.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 251/ 292] blk.27.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 252/ 292] blk.27.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 253/ 292] blk.27.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 254/ 292] blk.27.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 255/ 292] blk.28.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 256/ 292] blk.28.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 257/ 292] blk.28.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 258/ 292] blk.28.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 259/ 292] blk.28.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 260/ 292] blk.28.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 261/ 292] blk.28.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 262/ 292] blk.28.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 263/ 292] blk.28.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 264/ 292] blk.29.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 265/ 292] blk.29.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 266/ 292] blk.29.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 267/ 292] blk.29.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 268/ 292] blk.29.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 269/ 292] blk.29.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 270/ 292] blk.29.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 271/ 292] blk.29.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 272/ 292] blk.29.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 273/ 292] blk.30.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 274/ 292] blk.30.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 275/ 292] blk.30.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 276/ 292] blk.30.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 277/ 292] blk.30.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 278/ 292] blk.30.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 279/ 292] blk.30.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 280/ 292] blk.30.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 281/ 292] blk.30.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 282/ 292] blk.31.ffn_gate.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 283/ 292] blk.31.ffn_up.weight - [ 4096, 14336, 1, 1], type = f16, converting to q5_K .. size = 112.00 MiB -> 38.50 MiB\n","[ 284/ 292] blk.31.attn_k.weight - [ 4096, 1024, 1, 1], type = f16, converting to q5_K .. size = 8.00 MiB -> 2.75 MiB\n","[ 285/ 292] blk.31.attn_output.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 286/ 292] blk.31.attn_q.weight - [ 4096, 4096, 1, 1], type = f16, converting to q5_K .. size = 32.00 MiB -> 11.00 MiB\n","[ 287/ 292] blk.31.attn_v.weight - [ 4096, 1024, 1, 1], type = f16, converting to q6_K .. size = 8.00 MiB -> 3.28 MiB\n","[ 288/ 292] output.weight - [ 4096, 128258, 1, 1], type = f16, converting to q6_K .. size = 1002.02 MiB -> 410.98 MiB\n","[ 289/ 292] blk.31.attn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 290/ 292] blk.31.ffn_down.weight - [14336, 4096, 1, 1], type = f16, converting to q6_K .. size = 112.00 MiB -> 45.94 MiB\n","[ 291/ 292] blk.31.ffn_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","[ 292/ 292] output_norm.weight - [ 4096, 1, 1, 1], type = f32, size = 0.016 MB\n","llama_model_quantize_internal: model size = 15317.05 MB\n","llama_model_quantize_internal: quant size = 5459.94 MB\n","\n","main: quantize time = 431584.61 ms\n","main: total time = 431584.61 ms\n"]}],"source":["%cd /kaggle/working/\n","\n","!./llama.cpp/llama-quantize /kaggle/input/llama-3-llm-to-gguf/llama-3.1-8b-chat-math-teacher.gguf llama-3.1-8b-chat-math-teacher-Q5_K_M.gguf Q5_K_M"]},{"cell_type":"code","execution_count":null,"metadata":{"execution":{"iopub.execute_input":"2024-10-21T20:08:36.315241Z","iopub.status.busy":"2024-10-21T20:08:36.314900Z","iopub.status.idle":"2024-10-21T20:11:08.853556Z","shell.execute_reply":"2024-10-21T20:11:08.852606Z","shell.execute_reply.started":"2024-10-21T20:08:36.315205Z"},"trusted":true},"outputs":[],"source":["from huggingface_hub import login\n","from kaggle_secrets import UserSecretsClient\n","from huggingface_hub import HfApi\n","user_secrets = UserSecretsClient()\n","hf_token = user_secrets.get_secret(\"HF_TOKEN\")\n","login(token = hf_token)\n","\n","api = HfApi()\n","api.upload_file(\n"," path_or_fileobj=\"/kaggle/working/llama-3.1-8b-chat-math-teacher-Q5_K_M.gguf\",\n"," path_in_repo=\"llama-3.1-8b-chat-math-teacher-Q5_K_M.gguf\",\n"," repo_id=\"ccapo/llama-3.1-8b-chat-math-teacher-GGUF\",\n"," repo_type=\"model\",\n",")"]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.10.14"}},"nbformat":4,"nbformat_minor":4}
|
notebooks/movie_recommendation.ipynb
ADDED
@@ -0,0 +1,1229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {},
|
6 |
+
"source": [
|
7 |
+
"# Movie Recommendation Project\n",
|
8 |
+
"In this machine learning project, we build a recommendation system from the ground up to suggest movies to the user based on his/her preferences.\n",
|
9 |
+
"\n",
|
10 |
+
"## Dataset\n",
|
11 |
+
"We are using the TMDB dataset available from Kaggle\n",
|
12 |
+
"\n",
|
13 |
+
"## What is a Recommendation System?\n",
|
14 |
+
"Recommendation systems suggest recommendations to users depending on a variety of criteria.\n",
|
15 |
+
"\n",
|
16 |
+
"There are 3 types of recommendation systems.\n",
|
17 |
+
"\n",
|
18 |
+
"1. Demographic Filtering: The recommendations are the same for every user. They are generalized, not personalized. These types of systems are behind sections like “Top Trending”.\n",
|
19 |
+
"2. Content-based Filtering: These suggest recommendations based on the item metadata (movie, product, song, etc). Here, the main idea is if a user likes an item, then the user will also like items similar to it.\n",
|
20 |
+
"3. Collaboration-based Filtering: These systems make recommendations by grouping the users with similar interests. For this system, metadata of the item is not required.\n",
|
21 |
+
"\n",
|
22 |
+
"In this project, we are building a **Content-based** recommendation engine for movies."
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"cell_type": "code",
|
27 |
+
"execution_count": 4,
|
28 |
+
"metadata": {},
|
29 |
+
"outputs": [],
|
30 |
+
"source": [
|
31 |
+
"import pandas as pd\n",
|
32 |
+
"import numpy as np\n",
|
33 |
+
"from ast import literal_eval\n",
|
34 |
+
"from sklearn.feature_extraction.text import CountVectorizer\n",
|
35 |
+
"from sklearn.metrics.pairwise import cosine_similarity\n",
|
36 |
+
"import pickle"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": 5,
|
42 |
+
"metadata": {},
|
43 |
+
"outputs": [],
|
44 |
+
"source": [
|
45 |
+
"credits_df = pd.read_csv(\"./data/tmdb_5000_credits.csv\")\n",
|
46 |
+
"movies_df = pd.read_csv(\"./data/tmdb_5000_movies.csv\")"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
{
|
50 |
+
"cell_type": "code",
|
51 |
+
"execution_count": 6,
|
52 |
+
"metadata": {},
|
53 |
+
"outputs": [
|
54 |
+
{
|
55 |
+
"data": {
|
56 |
+
"text/html": [
|
57 |
+
"<div>\n",
|
58 |
+
"<style scoped>\n",
|
59 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
60 |
+
" vertical-align: middle;\n",
|
61 |
+
" }\n",
|
62 |
+
"\n",
|
63 |
+
" .dataframe tbody tr th {\n",
|
64 |
+
" vertical-align: top;\n",
|
65 |
+
" }\n",
|
66 |
+
"\n",
|
67 |
+
" .dataframe thead th {\n",
|
68 |
+
" text-align: right;\n",
|
69 |
+
" }\n",
|
70 |
+
"</style>\n",
|
71 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
72 |
+
" <thead>\n",
|
73 |
+
" <tr style=\"text-align: right;\">\n",
|
74 |
+
" <th></th>\n",
|
75 |
+
" <th>budget</th>\n",
|
76 |
+
" <th>genres</th>\n",
|
77 |
+
" <th>homepage</th>\n",
|
78 |
+
" <th>id</th>\n",
|
79 |
+
" <th>keywords</th>\n",
|
80 |
+
" <th>original_language</th>\n",
|
81 |
+
" <th>original_title</th>\n",
|
82 |
+
" <th>overview</th>\n",
|
83 |
+
" <th>popularity</th>\n",
|
84 |
+
" <th>production_companies</th>\n",
|
85 |
+
" <th>production_countries</th>\n",
|
86 |
+
" <th>release_date</th>\n",
|
87 |
+
" <th>revenue</th>\n",
|
88 |
+
" <th>runtime</th>\n",
|
89 |
+
" <th>spoken_languages</th>\n",
|
90 |
+
" <th>status</th>\n",
|
91 |
+
" <th>tagline</th>\n",
|
92 |
+
" <th>title</th>\n",
|
93 |
+
" <th>vote_average</th>\n",
|
94 |
+
" <th>vote_count</th>\n",
|
95 |
+
" </tr>\n",
|
96 |
+
" </thead>\n",
|
97 |
+
" <tbody>\n",
|
98 |
+
" <tr>\n",
|
99 |
+
" <th>0</th>\n",
|
100 |
+
" <td>237000000</td>\n",
|
101 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
102 |
+
" <td>http://www.avatarmovie.com/</td>\n",
|
103 |
+
" <td>19995</td>\n",
|
104 |
+
" <td>[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":...</td>\n",
|
105 |
+
" <td>en</td>\n",
|
106 |
+
" <td>Avatar</td>\n",
|
107 |
+
" <td>In the 22nd century, a paraplegic Marine is di...</td>\n",
|
108 |
+
" <td>150.437577</td>\n",
|
109 |
+
" <td>[{\"name\": \"Ingenious Film Partners\", \"id\": 289...</td>\n",
|
110 |
+
" <td>[{\"iso_3166_1\": \"US\", \"name\": \"United States o...</td>\n",
|
111 |
+
" <td>2009-12-10</td>\n",
|
112 |
+
" <td>2787965087</td>\n",
|
113 |
+
" <td>162.0</td>\n",
|
114 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso...</td>\n",
|
115 |
+
" <td>Released</td>\n",
|
116 |
+
" <td>Enter the World of Pandora.</td>\n",
|
117 |
+
" <td>Avatar</td>\n",
|
118 |
+
" <td>7.2</td>\n",
|
119 |
+
" <td>11800</td>\n",
|
120 |
+
" </tr>\n",
|
121 |
+
" <tr>\n",
|
122 |
+
" <th>1</th>\n",
|
123 |
+
" <td>300000000</td>\n",
|
124 |
+
" <td>[{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"...</td>\n",
|
125 |
+
" <td>http://disney.go.com/disneypictures/pirates/</td>\n",
|
126 |
+
" <td>285</td>\n",
|
127 |
+
" <td>[{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na...</td>\n",
|
128 |
+
" <td>en</td>\n",
|
129 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
130 |
+
" <td>Captain Barbossa, long believed to be dead, ha...</td>\n",
|
131 |
+
" <td>139.082615</td>\n",
|
132 |
+
" <td>[{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"...</td>\n",
|
133 |
+
" <td>[{\"iso_3166_1\": \"US\", \"name\": \"United States o...</td>\n",
|
134 |
+
" <td>2007-05-19</td>\n",
|
135 |
+
" <td>961000000</td>\n",
|
136 |
+
" <td>169.0</td>\n",
|
137 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
138 |
+
" <td>Released</td>\n",
|
139 |
+
" <td>At the end of the world, the adventure begins.</td>\n",
|
140 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
141 |
+
" <td>6.9</td>\n",
|
142 |
+
" <td>4500</td>\n",
|
143 |
+
" </tr>\n",
|
144 |
+
" <tr>\n",
|
145 |
+
" <th>2</th>\n",
|
146 |
+
" <td>245000000</td>\n",
|
147 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
148 |
+
" <td>http://www.sonypictures.com/movies/spectre/</td>\n",
|
149 |
+
" <td>206647</td>\n",
|
150 |
+
" <td>[{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name...</td>\n",
|
151 |
+
" <td>en</td>\n",
|
152 |
+
" <td>Spectre</td>\n",
|
153 |
+
" <td>A cryptic message from Bond’s past sends him o...</td>\n",
|
154 |
+
" <td>107.376788</td>\n",
|
155 |
+
" <td>[{\"name\": \"Columbia Pictures\", \"id\": 5}, {\"nam...</td>\n",
|
156 |
+
" <td>[{\"iso_3166_1\": \"GB\", \"name\": \"United Kingdom\"...</td>\n",
|
157 |
+
" <td>2015-10-26</td>\n",
|
158 |
+
" <td>880674609</td>\n",
|
159 |
+
" <td>148.0</td>\n",
|
160 |
+
" <td>[{\"iso_639_1\": \"fr\", \"name\": \"Fran\\u00e7ais\"},...</td>\n",
|
161 |
+
" <td>Released</td>\n",
|
162 |
+
" <td>A Plan No One Escapes</td>\n",
|
163 |
+
" <td>Spectre</td>\n",
|
164 |
+
" <td>6.3</td>\n",
|
165 |
+
" <td>4466</td>\n",
|
166 |
+
" </tr>\n",
|
167 |
+
" <tr>\n",
|
168 |
+
" <th>3</th>\n",
|
169 |
+
" <td>250000000</td>\n",
|
170 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam...</td>\n",
|
171 |
+
" <td>http://www.thedarkknightrises.com/</td>\n",
|
172 |
+
" <td>49026</td>\n",
|
173 |
+
" <td>[{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,...</td>\n",
|
174 |
+
" <td>en</td>\n",
|
175 |
+
" <td>The Dark Knight Rises</td>\n",
|
176 |
+
" <td>Following the death of District Attorney Harve...</td>\n",
|
177 |
+
" <td>112.312950</td>\n",
|
178 |
+
" <td>[{\"name\": \"Legendary Pictures\", \"id\": 923}, {\"...</td>\n",
|
179 |
+
" <td>[{\"iso_3166_1\": \"US\", \"name\": \"United States o...</td>\n",
|
180 |
+
" <td>2012-07-16</td>\n",
|
181 |
+
" <td>1084939099</td>\n",
|
182 |
+
" <td>165.0</td>\n",
|
183 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
184 |
+
" <td>Released</td>\n",
|
185 |
+
" <td>The Legend Ends</td>\n",
|
186 |
+
" <td>The Dark Knight Rises</td>\n",
|
187 |
+
" <td>7.6</td>\n",
|
188 |
+
" <td>9106</td>\n",
|
189 |
+
" </tr>\n",
|
190 |
+
" <tr>\n",
|
191 |
+
" <th>4</th>\n",
|
192 |
+
" <td>260000000</td>\n",
|
193 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
194 |
+
" <td>http://movies.disney.com/john-carter</td>\n",
|
195 |
+
" <td>49529</td>\n",
|
196 |
+
" <td>[{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":...</td>\n",
|
197 |
+
" <td>en</td>\n",
|
198 |
+
" <td>John Carter</td>\n",
|
199 |
+
" <td>John Carter is a war-weary, former military ca...</td>\n",
|
200 |
+
" <td>43.926995</td>\n",
|
201 |
+
" <td>[{\"name\": \"Walt Disney Pictures\", \"id\": 2}]</td>\n",
|
202 |
+
" <td>[{\"iso_3166_1\": \"US\", \"name\": \"United States o...</td>\n",
|
203 |
+
" <td>2012-03-07</td>\n",
|
204 |
+
" <td>284139100</td>\n",
|
205 |
+
" <td>132.0</td>\n",
|
206 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
207 |
+
" <td>Released</td>\n",
|
208 |
+
" <td>Lost in our world, found in another.</td>\n",
|
209 |
+
" <td>John Carter</td>\n",
|
210 |
+
" <td>6.1</td>\n",
|
211 |
+
" <td>2124</td>\n",
|
212 |
+
" </tr>\n",
|
213 |
+
" </tbody>\n",
|
214 |
+
"</table>\n",
|
215 |
+
"</div>"
|
216 |
+
],
|
217 |
+
"text/plain": [
|
218 |
+
" budget genres \\\n",
|
219 |
+
"0 237000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
220 |
+
"1 300000000 [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... \n",
|
221 |
+
"2 245000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
222 |
+
"3 250000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... \n",
|
223 |
+
"4 260000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
224 |
+
"\n",
|
225 |
+
" homepage id \\\n",
|
226 |
+
"0 http://www.avatarmovie.com/ 19995 \n",
|
227 |
+
"1 http://disney.go.com/disneypictures/pirates/ 285 \n",
|
228 |
+
"2 http://www.sonypictures.com/movies/spectre/ 206647 \n",
|
229 |
+
"3 http://www.thedarkknightrises.com/ 49026 \n",
|
230 |
+
"4 http://movies.disney.com/john-carter 49529 \n",
|
231 |
+
"\n",
|
232 |
+
" keywords original_language \\\n",
|
233 |
+
"0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... en \n",
|
234 |
+
"1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... en \n",
|
235 |
+
"2 [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... en \n",
|
236 |
+
"3 [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... en \n",
|
237 |
+
"4 [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... en \n",
|
238 |
+
"\n",
|
239 |
+
" original_title \\\n",
|
240 |
+
"0 Avatar \n",
|
241 |
+
"1 Pirates of the Caribbean: At World's End \n",
|
242 |
+
"2 Spectre \n",
|
243 |
+
"3 The Dark Knight Rises \n",
|
244 |
+
"4 John Carter \n",
|
245 |
+
"\n",
|
246 |
+
" overview popularity \\\n",
|
247 |
+
"0 In the 22nd century, a paraplegic Marine is di... 150.437577 \n",
|
248 |
+
"1 Captain Barbossa, long believed to be dead, ha... 139.082615 \n",
|
249 |
+
"2 A cryptic message from Bond’s past sends him o... 107.376788 \n",
|
250 |
+
"3 Following the death of District Attorney Harve... 112.312950 \n",
|
251 |
+
"4 John Carter is a war-weary, former military ca... 43.926995 \n",
|
252 |
+
"\n",
|
253 |
+
" production_companies \\\n",
|
254 |
+
"0 [{\"name\": \"Ingenious Film Partners\", \"id\": 289... \n",
|
255 |
+
"1 [{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"... \n",
|
256 |
+
"2 [{\"name\": \"Columbia Pictures\", \"id\": 5}, {\"nam... \n",
|
257 |
+
"3 [{\"name\": \"Legendary Pictures\", \"id\": 923}, {\"... \n",
|
258 |
+
"4 [{\"name\": \"Walt Disney Pictures\", \"id\": 2}] \n",
|
259 |
+
"\n",
|
260 |
+
" production_countries release_date revenue \\\n",
|
261 |
+
"0 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2009-12-10 2787965087 \n",
|
262 |
+
"1 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2007-05-19 961000000 \n",
|
263 |
+
"2 [{\"iso_3166_1\": \"GB\", \"name\": \"United Kingdom\"... 2015-10-26 880674609 \n",
|
264 |
+
"3 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2012-07-16 1084939099 \n",
|
265 |
+
"4 [{\"iso_3166_1\": \"US\", \"name\": \"United States o... 2012-03-07 284139100 \n",
|
266 |
+
"\n",
|
267 |
+
" runtime spoken_languages status \\\n",
|
268 |
+
"0 162.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... Released \n",
|
269 |
+
"1 169.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
270 |
+
"2 148.0 [{\"iso_639_1\": \"fr\", \"name\": \"Fran\\u00e7ais\"},... Released \n",
|
271 |
+
"3 165.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
272 |
+
"4 132.0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
273 |
+
"\n",
|
274 |
+
" tagline \\\n",
|
275 |
+
"0 Enter the World of Pandora. \n",
|
276 |
+
"1 At the end of the world, the adventure begins. \n",
|
277 |
+
"2 A Plan No One Escapes \n",
|
278 |
+
"3 The Legend Ends \n",
|
279 |
+
"4 Lost in our world, found in another. \n",
|
280 |
+
"\n",
|
281 |
+
" title vote_average vote_count \n",
|
282 |
+
"0 Avatar 7.2 11800 \n",
|
283 |
+
"1 Pirates of the Caribbean: At World's End 6.9 4500 \n",
|
284 |
+
"2 Spectre 6.3 4466 \n",
|
285 |
+
"3 The Dark Knight Rises 7.6 9106 \n",
|
286 |
+
"4 John Carter 6.1 2124 "
|
287 |
+
]
|
288 |
+
},
|
289 |
+
"execution_count": 6,
|
290 |
+
"metadata": {},
|
291 |
+
"output_type": "execute_result"
|
292 |
+
}
|
293 |
+
],
|
294 |
+
"source": [
|
295 |
+
"movies_df.head()"
|
296 |
+
]
|
297 |
+
},
|
298 |
+
{
|
299 |
+
"cell_type": "code",
|
300 |
+
"execution_count": 7,
|
301 |
+
"metadata": {},
|
302 |
+
"outputs": [
|
303 |
+
{
|
304 |
+
"data": {
|
305 |
+
"text/html": [
|
306 |
+
"<div>\n",
|
307 |
+
"<style scoped>\n",
|
308 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
309 |
+
" vertical-align: middle;\n",
|
310 |
+
" }\n",
|
311 |
+
"\n",
|
312 |
+
" .dataframe tbody tr th {\n",
|
313 |
+
" vertical-align: top;\n",
|
314 |
+
" }\n",
|
315 |
+
"\n",
|
316 |
+
" .dataframe thead th {\n",
|
317 |
+
" text-align: right;\n",
|
318 |
+
" }\n",
|
319 |
+
"</style>\n",
|
320 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
321 |
+
" <thead>\n",
|
322 |
+
" <tr style=\"text-align: right;\">\n",
|
323 |
+
" <th></th>\n",
|
324 |
+
" <th>movie_id</th>\n",
|
325 |
+
" <th>title</th>\n",
|
326 |
+
" <th>cast</th>\n",
|
327 |
+
" <th>crew</th>\n",
|
328 |
+
" </tr>\n",
|
329 |
+
" </thead>\n",
|
330 |
+
" <tbody>\n",
|
331 |
+
" <tr>\n",
|
332 |
+
" <th>0</th>\n",
|
333 |
+
" <td>19995</td>\n",
|
334 |
+
" <td>Avatar</td>\n",
|
335 |
+
" <td>[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...</td>\n",
|
336 |
+
" <td>[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...</td>\n",
|
337 |
+
" </tr>\n",
|
338 |
+
" <tr>\n",
|
339 |
+
" <th>1</th>\n",
|
340 |
+
" <td>285</td>\n",
|
341 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
342 |
+
" <td>[{\"cast_id\": 4, \"character\": \"Captain Jack Spa...</td>\n",
|
343 |
+
" <td>[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de...</td>\n",
|
344 |
+
" </tr>\n",
|
345 |
+
" <tr>\n",
|
346 |
+
" <th>2</th>\n",
|
347 |
+
" <td>206647</td>\n",
|
348 |
+
" <td>Spectre</td>\n",
|
349 |
+
" <td>[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr...</td>\n",
|
350 |
+
" <td>[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de...</td>\n",
|
351 |
+
" </tr>\n",
|
352 |
+
" <tr>\n",
|
353 |
+
" <th>3</th>\n",
|
354 |
+
" <td>49026</td>\n",
|
355 |
+
" <td>The Dark Knight Rises</td>\n",
|
356 |
+
" <td>[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba...</td>\n",
|
357 |
+
" <td>[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de...</td>\n",
|
358 |
+
" </tr>\n",
|
359 |
+
" <tr>\n",
|
360 |
+
" <th>4</th>\n",
|
361 |
+
" <td>49529</td>\n",
|
362 |
+
" <td>John Carter</td>\n",
|
363 |
+
" <td>[{\"cast_id\": 5, \"character\": \"John Carter\", \"c...</td>\n",
|
364 |
+
" <td>[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de...</td>\n",
|
365 |
+
" </tr>\n",
|
366 |
+
" </tbody>\n",
|
367 |
+
"</table>\n",
|
368 |
+
"</div>"
|
369 |
+
],
|
370 |
+
"text/plain": [
|
371 |
+
" movie_id title \\\n",
|
372 |
+
"0 19995 Avatar \n",
|
373 |
+
"1 285 Pirates of the Caribbean: At World's End \n",
|
374 |
+
"2 206647 Spectre \n",
|
375 |
+
"3 49026 The Dark Knight Rises \n",
|
376 |
+
"4 49529 John Carter \n",
|
377 |
+
"\n",
|
378 |
+
" cast \\\n",
|
379 |
+
"0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n",
|
380 |
+
"1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n",
|
381 |
+
"2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n",
|
382 |
+
"3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n",
|
383 |
+
"4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n",
|
384 |
+
"\n",
|
385 |
+
" crew \n",
|
386 |
+
"0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n",
|
387 |
+
"1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n",
|
388 |
+
"2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n",
|
389 |
+
"3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n",
|
390 |
+
"4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... "
|
391 |
+
]
|
392 |
+
},
|
393 |
+
"execution_count": 7,
|
394 |
+
"metadata": {},
|
395 |
+
"output_type": "execute_result"
|
396 |
+
}
|
397 |
+
],
|
398 |
+
"source": [
|
399 |
+
"credits_df.head()"
|
400 |
+
]
|
401 |
+
},
|
402 |
+
{
|
403 |
+
"cell_type": "code",
|
404 |
+
"execution_count": 8,
|
405 |
+
"metadata": {},
|
406 |
+
"outputs": [
|
407 |
+
{
|
408 |
+
"data": {
|
409 |
+
"text/html": [
|
410 |
+
"<div>\n",
|
411 |
+
"<style scoped>\n",
|
412 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
413 |
+
" vertical-align: middle;\n",
|
414 |
+
" }\n",
|
415 |
+
"\n",
|
416 |
+
" .dataframe tbody tr th {\n",
|
417 |
+
" vertical-align: top;\n",
|
418 |
+
" }\n",
|
419 |
+
"\n",
|
420 |
+
" .dataframe thead th {\n",
|
421 |
+
" text-align: right;\n",
|
422 |
+
" }\n",
|
423 |
+
"</style>\n",
|
424 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
425 |
+
" <thead>\n",
|
426 |
+
" <tr style=\"text-align: right;\">\n",
|
427 |
+
" <th></th>\n",
|
428 |
+
" <th>budget</th>\n",
|
429 |
+
" <th>genres</th>\n",
|
430 |
+
" <th>homepage</th>\n",
|
431 |
+
" <th>id</th>\n",
|
432 |
+
" <th>keywords</th>\n",
|
433 |
+
" <th>original_language</th>\n",
|
434 |
+
" <th>original_title</th>\n",
|
435 |
+
" <th>overview</th>\n",
|
436 |
+
" <th>popularity</th>\n",
|
437 |
+
" <th>production_companies</th>\n",
|
438 |
+
" <th>...</th>\n",
|
439 |
+
" <th>revenue</th>\n",
|
440 |
+
" <th>runtime</th>\n",
|
441 |
+
" <th>spoken_languages</th>\n",
|
442 |
+
" <th>status</th>\n",
|
443 |
+
" <th>tagline</th>\n",
|
444 |
+
" <th>title</th>\n",
|
445 |
+
" <th>vote_average</th>\n",
|
446 |
+
" <th>vote_count</th>\n",
|
447 |
+
" <th>cast</th>\n",
|
448 |
+
" <th>crew</th>\n",
|
449 |
+
" </tr>\n",
|
450 |
+
" </thead>\n",
|
451 |
+
" <tbody>\n",
|
452 |
+
" <tr>\n",
|
453 |
+
" <th>0</th>\n",
|
454 |
+
" <td>237000000</td>\n",
|
455 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
456 |
+
" <td>http://www.avatarmovie.com/</td>\n",
|
457 |
+
" <td>19995</td>\n",
|
458 |
+
" <td>[{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":...</td>\n",
|
459 |
+
" <td>en</td>\n",
|
460 |
+
" <td>Avatar</td>\n",
|
461 |
+
" <td>In the 22nd century, a paraplegic Marine is di...</td>\n",
|
462 |
+
" <td>150.437577</td>\n",
|
463 |
+
" <td>[{\"name\": \"Ingenious Film Partners\", \"id\": 289...</td>\n",
|
464 |
+
" <td>...</td>\n",
|
465 |
+
" <td>2787965087</td>\n",
|
466 |
+
" <td>162.0</td>\n",
|
467 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso...</td>\n",
|
468 |
+
" <td>Released</td>\n",
|
469 |
+
" <td>Enter the World of Pandora.</td>\n",
|
470 |
+
" <td>Avatar</td>\n",
|
471 |
+
" <td>7.2</td>\n",
|
472 |
+
" <td>11800</td>\n",
|
473 |
+
" <td>[{\"cast_id\": 242, \"character\": \"Jake Sully\", \"...</td>\n",
|
474 |
+
" <td>[{\"credit_id\": \"52fe48009251416c750aca23\", \"de...</td>\n",
|
475 |
+
" </tr>\n",
|
476 |
+
" <tr>\n",
|
477 |
+
" <th>1</th>\n",
|
478 |
+
" <td>300000000</td>\n",
|
479 |
+
" <td>[{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"...</td>\n",
|
480 |
+
" <td>http://disney.go.com/disneypictures/pirates/</td>\n",
|
481 |
+
" <td>285</td>\n",
|
482 |
+
" <td>[{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na...</td>\n",
|
483 |
+
" <td>en</td>\n",
|
484 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
485 |
+
" <td>Captain Barbossa, long believed to be dead, ha...</td>\n",
|
486 |
+
" <td>139.082615</td>\n",
|
487 |
+
" <td>[{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"...</td>\n",
|
488 |
+
" <td>...</td>\n",
|
489 |
+
" <td>961000000</td>\n",
|
490 |
+
" <td>169.0</td>\n",
|
491 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
492 |
+
" <td>Released</td>\n",
|
493 |
+
" <td>At the end of the world, the adventure begins.</td>\n",
|
494 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
495 |
+
" <td>6.9</td>\n",
|
496 |
+
" <td>4500</td>\n",
|
497 |
+
" <td>[{\"cast_id\": 4, \"character\": \"Captain Jack Spa...</td>\n",
|
498 |
+
" <td>[{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de...</td>\n",
|
499 |
+
" </tr>\n",
|
500 |
+
" <tr>\n",
|
501 |
+
" <th>2</th>\n",
|
502 |
+
" <td>245000000</td>\n",
|
503 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
504 |
+
" <td>http://www.sonypictures.com/movies/spectre/</td>\n",
|
505 |
+
" <td>206647</td>\n",
|
506 |
+
" <td>[{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name...</td>\n",
|
507 |
+
" <td>en</td>\n",
|
508 |
+
" <td>Spectre</td>\n",
|
509 |
+
" <td>A cryptic message from Bond’s past sends him o...</td>\n",
|
510 |
+
" <td>107.376788</td>\n",
|
511 |
+
" <td>[{\"name\": \"Columbia Pictures\", \"id\": 5}, {\"nam...</td>\n",
|
512 |
+
" <td>...</td>\n",
|
513 |
+
" <td>880674609</td>\n",
|
514 |
+
" <td>148.0</td>\n",
|
515 |
+
" <td>[{\"iso_639_1\": \"fr\", \"name\": \"Fran\\u00e7ais\"},...</td>\n",
|
516 |
+
" <td>Released</td>\n",
|
517 |
+
" <td>A Plan No One Escapes</td>\n",
|
518 |
+
" <td>Spectre</td>\n",
|
519 |
+
" <td>6.3</td>\n",
|
520 |
+
" <td>4466</td>\n",
|
521 |
+
" <td>[{\"cast_id\": 1, \"character\": \"James Bond\", \"cr...</td>\n",
|
522 |
+
" <td>[{\"credit_id\": \"54805967c3a36829b5002c41\", \"de...</td>\n",
|
523 |
+
" </tr>\n",
|
524 |
+
" <tr>\n",
|
525 |
+
" <th>3</th>\n",
|
526 |
+
" <td>250000000</td>\n",
|
527 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam...</td>\n",
|
528 |
+
" <td>http://www.thedarkknightrises.com/</td>\n",
|
529 |
+
" <td>49026</td>\n",
|
530 |
+
" <td>[{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,...</td>\n",
|
531 |
+
" <td>en</td>\n",
|
532 |
+
" <td>The Dark Knight Rises</td>\n",
|
533 |
+
" <td>Following the death of District Attorney Harve...</td>\n",
|
534 |
+
" <td>112.312950</td>\n",
|
535 |
+
" <td>[{\"name\": \"Legendary Pictures\", \"id\": 923}, {\"...</td>\n",
|
536 |
+
" <td>...</td>\n",
|
537 |
+
" <td>1084939099</td>\n",
|
538 |
+
" <td>165.0</td>\n",
|
539 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
540 |
+
" <td>Released</td>\n",
|
541 |
+
" <td>The Legend Ends</td>\n",
|
542 |
+
" <td>The Dark Knight Rises</td>\n",
|
543 |
+
" <td>7.6</td>\n",
|
544 |
+
" <td>9106</td>\n",
|
545 |
+
" <td>[{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba...</td>\n",
|
546 |
+
" <td>[{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de...</td>\n",
|
547 |
+
" </tr>\n",
|
548 |
+
" <tr>\n",
|
549 |
+
" <th>4</th>\n",
|
550 |
+
" <td>260000000</td>\n",
|
551 |
+
" <td>[{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam...</td>\n",
|
552 |
+
" <td>http://movies.disney.com/john-carter</td>\n",
|
553 |
+
" <td>49529</td>\n",
|
554 |
+
" <td>[{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":...</td>\n",
|
555 |
+
" <td>en</td>\n",
|
556 |
+
" <td>John Carter</td>\n",
|
557 |
+
" <td>John Carter is a war-weary, former military ca...</td>\n",
|
558 |
+
" <td>43.926995</td>\n",
|
559 |
+
" <td>[{\"name\": \"Walt Disney Pictures\", \"id\": 2}]</td>\n",
|
560 |
+
" <td>...</td>\n",
|
561 |
+
" <td>284139100</td>\n",
|
562 |
+
" <td>132.0</td>\n",
|
563 |
+
" <td>[{\"iso_639_1\": \"en\", \"name\": \"English\"}]</td>\n",
|
564 |
+
" <td>Released</td>\n",
|
565 |
+
" <td>Lost in our world, found in another.</td>\n",
|
566 |
+
" <td>John Carter</td>\n",
|
567 |
+
" <td>6.1</td>\n",
|
568 |
+
" <td>2124</td>\n",
|
569 |
+
" <td>[{\"cast_id\": 5, \"character\": \"John Carter\", \"c...</td>\n",
|
570 |
+
" <td>[{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de...</td>\n",
|
571 |
+
" </tr>\n",
|
572 |
+
" </tbody>\n",
|
573 |
+
"</table>\n",
|
574 |
+
"<p>5 rows × 22 columns</p>\n",
|
575 |
+
"</div>"
|
576 |
+
],
|
577 |
+
"text/plain": [
|
578 |
+
" budget genres \\\n",
|
579 |
+
"0 237000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
580 |
+
"1 300000000 [{\"id\": 12, \"name\": \"Adventure\"}, {\"id\": 14, \"... \n",
|
581 |
+
"2 245000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
582 |
+
"3 250000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 80, \"nam... \n",
|
583 |
+
"4 260000000 [{\"id\": 28, \"name\": \"Action\"}, {\"id\": 12, \"nam... \n",
|
584 |
+
"\n",
|
585 |
+
" homepage id \\\n",
|
586 |
+
"0 http://www.avatarmovie.com/ 19995 \n",
|
587 |
+
"1 http://disney.go.com/disneypictures/pirates/ 285 \n",
|
588 |
+
"2 http://www.sonypictures.com/movies/spectre/ 206647 \n",
|
589 |
+
"3 http://www.thedarkknightrises.com/ 49026 \n",
|
590 |
+
"4 http://movies.disney.com/john-carter 49529 \n",
|
591 |
+
"\n",
|
592 |
+
" keywords original_language \\\n",
|
593 |
+
"0 [{\"id\": 1463, \"name\": \"culture clash\"}, {\"id\":... en \n",
|
594 |
+
"1 [{\"id\": 270, \"name\": \"ocean\"}, {\"id\": 726, \"na... en \n",
|
595 |
+
"2 [{\"id\": 470, \"name\": \"spy\"}, {\"id\": 818, \"name... en \n",
|
596 |
+
"3 [{\"id\": 849, \"name\": \"dc comics\"}, {\"id\": 853,... en \n",
|
597 |
+
"4 [{\"id\": 818, \"name\": \"based on novel\"}, {\"id\":... en \n",
|
598 |
+
"\n",
|
599 |
+
" original_title \\\n",
|
600 |
+
"0 Avatar \n",
|
601 |
+
"1 Pirates of the Caribbean: At World's End \n",
|
602 |
+
"2 Spectre \n",
|
603 |
+
"3 The Dark Knight Rises \n",
|
604 |
+
"4 John Carter \n",
|
605 |
+
"\n",
|
606 |
+
" overview popularity \\\n",
|
607 |
+
"0 In the 22nd century, a paraplegic Marine is di... 150.437577 \n",
|
608 |
+
"1 Captain Barbossa, long believed to be dead, ha... 139.082615 \n",
|
609 |
+
"2 A cryptic message from Bond’s past sends him o... 107.376788 \n",
|
610 |
+
"3 Following the death of District Attorney Harve... 112.312950 \n",
|
611 |
+
"4 John Carter is a war-weary, former military ca... 43.926995 \n",
|
612 |
+
"\n",
|
613 |
+
" production_companies ... revenue runtime \\\n",
|
614 |
+
"0 [{\"name\": \"Ingenious Film Partners\", \"id\": 289... ... 2787965087 162.0 \n",
|
615 |
+
"1 [{\"name\": \"Walt Disney Pictures\", \"id\": 2}, {\"... ... 961000000 169.0 \n",
|
616 |
+
"2 [{\"name\": \"Columbia Pictures\", \"id\": 5}, {\"nam... ... 880674609 148.0 \n",
|
617 |
+
"3 [{\"name\": \"Legendary Pictures\", \"id\": 923}, {\"... ... 1084939099 165.0 \n",
|
618 |
+
"4 [{\"name\": \"Walt Disney Pictures\", \"id\": 2}] ... 284139100 132.0 \n",
|
619 |
+
"\n",
|
620 |
+
" spoken_languages status \\\n",
|
621 |
+
"0 [{\"iso_639_1\": \"en\", \"name\": \"English\"}, {\"iso... Released \n",
|
622 |
+
"1 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
623 |
+
"2 [{\"iso_639_1\": \"fr\", \"name\": \"Fran\\u00e7ais\"},... Released \n",
|
624 |
+
"3 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
625 |
+
"4 [{\"iso_639_1\": \"en\", \"name\": \"English\"}] Released \n",
|
626 |
+
"\n",
|
627 |
+
" tagline \\\n",
|
628 |
+
"0 Enter the World of Pandora. \n",
|
629 |
+
"1 At the end of the world, the adventure begins. \n",
|
630 |
+
"2 A Plan No One Escapes \n",
|
631 |
+
"3 The Legend Ends \n",
|
632 |
+
"4 Lost in our world, found in another. \n",
|
633 |
+
"\n",
|
634 |
+
" title vote_average vote_count \\\n",
|
635 |
+
"0 Avatar 7.2 11800 \n",
|
636 |
+
"1 Pirates of the Caribbean: At World's End 6.9 4500 \n",
|
637 |
+
"2 Spectre 6.3 4466 \n",
|
638 |
+
"3 The Dark Knight Rises 7.6 9106 \n",
|
639 |
+
"4 John Carter 6.1 2124 \n",
|
640 |
+
"\n",
|
641 |
+
" cast \\\n",
|
642 |
+
"0 [{\"cast_id\": 242, \"character\": \"Jake Sully\", \"... \n",
|
643 |
+
"1 [{\"cast_id\": 4, \"character\": \"Captain Jack Spa... \n",
|
644 |
+
"2 [{\"cast_id\": 1, \"character\": \"James Bond\", \"cr... \n",
|
645 |
+
"3 [{\"cast_id\": 2, \"character\": \"Bruce Wayne / Ba... \n",
|
646 |
+
"4 [{\"cast_id\": 5, \"character\": \"John Carter\", \"c... \n",
|
647 |
+
"\n",
|
648 |
+
" crew \n",
|
649 |
+
"0 [{\"credit_id\": \"52fe48009251416c750aca23\", \"de... \n",
|
650 |
+
"1 [{\"credit_id\": \"52fe4232c3a36847f800b579\", \"de... \n",
|
651 |
+
"2 [{\"credit_id\": \"54805967c3a36829b5002c41\", \"de... \n",
|
652 |
+
"3 [{\"credit_id\": \"52fe4781c3a36847f81398c3\", \"de... \n",
|
653 |
+
"4 [{\"credit_id\": \"52fe479ac3a36847f813eaa3\", \"de... \n",
|
654 |
+
"\n",
|
655 |
+
"[5 rows x 22 columns]"
|
656 |
+
]
|
657 |
+
},
|
658 |
+
"execution_count": 8,
|
659 |
+
"metadata": {},
|
660 |
+
"output_type": "execute_result"
|
661 |
+
}
|
662 |
+
],
|
663 |
+
"source": [
|
664 |
+
"credits_df.columns = ['id', 'title', 'cast', 'crew']\n",
|
665 |
+
"movies_df = movies_df.merge(credits_df, on = \"id\")\n",
|
666 |
+
"movies_df.drop('title_y', axis = 1, inplace = True)\n",
|
667 |
+
"movies_df.rename(columns={'title_x':'title'}, inplace = True)\n",
|
668 |
+
"movies_df.head()"
|
669 |
+
]
|
670 |
+
},
|
671 |
+
{
|
672 |
+
"cell_type": "code",
|
673 |
+
"execution_count": 9,
|
674 |
+
"metadata": {},
|
675 |
+
"outputs": [
|
676 |
+
{
|
677 |
+
"data": {
|
678 |
+
"text/html": [
|
679 |
+
"<div>\n",
|
680 |
+
"<style scoped>\n",
|
681 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
682 |
+
" vertical-align: middle;\n",
|
683 |
+
" }\n",
|
684 |
+
"\n",
|
685 |
+
" .dataframe tbody tr th {\n",
|
686 |
+
" vertical-align: top;\n",
|
687 |
+
" }\n",
|
688 |
+
"\n",
|
689 |
+
" .dataframe thead th {\n",
|
690 |
+
" text-align: right;\n",
|
691 |
+
" }\n",
|
692 |
+
"</style>\n",
|
693 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
694 |
+
" <thead>\n",
|
695 |
+
" <tr style=\"text-align: right;\">\n",
|
696 |
+
" <th></th>\n",
|
697 |
+
" <th>cast</th>\n",
|
698 |
+
" <th>crew</th>\n",
|
699 |
+
" <th>keywords</th>\n",
|
700 |
+
" <th>genres</th>\n",
|
701 |
+
" </tr>\n",
|
702 |
+
" </thead>\n",
|
703 |
+
" <tbody>\n",
|
704 |
+
" <tr>\n",
|
705 |
+
" <th>0</th>\n",
|
706 |
+
" <td>[{'cast_id': 242, 'character': 'Jake Sully', '...</td>\n",
|
707 |
+
" <td>[{'credit_id': '52fe48009251416c750aca23', 'de...</td>\n",
|
708 |
+
" <td>[{'id': 1463, 'name': 'culture clash'}, {'id':...</td>\n",
|
709 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...</td>\n",
|
710 |
+
" </tr>\n",
|
711 |
+
" <tr>\n",
|
712 |
+
" <th>1</th>\n",
|
713 |
+
" <td>[{'cast_id': 4, 'character': 'Captain Jack Spa...</td>\n",
|
714 |
+
" <td>[{'credit_id': '52fe4232c3a36847f800b579', 'de...</td>\n",
|
715 |
+
" <td>[{'id': 270, 'name': 'ocean'}, {'id': 726, 'na...</td>\n",
|
716 |
+
" <td>[{'id': 12, 'name': 'Adventure'}, {'id': 14, '...</td>\n",
|
717 |
+
" </tr>\n",
|
718 |
+
" <tr>\n",
|
719 |
+
" <th>2</th>\n",
|
720 |
+
" <td>[{'cast_id': 1, 'character': 'James Bond', 'cr...</td>\n",
|
721 |
+
" <td>[{'credit_id': '54805967c3a36829b5002c41', 'de...</td>\n",
|
722 |
+
" <td>[{'id': 470, 'name': 'spy'}, {'id': 818, 'name...</td>\n",
|
723 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...</td>\n",
|
724 |
+
" </tr>\n",
|
725 |
+
" <tr>\n",
|
726 |
+
" <th>3</th>\n",
|
727 |
+
" <td>[{'cast_id': 2, 'character': 'Bruce Wayne / Ba...</td>\n",
|
728 |
+
" <td>[{'credit_id': '52fe4781c3a36847f81398c3', 'de...</td>\n",
|
729 |
+
" <td>[{'id': 849, 'name': 'dc comics'}, {'id': 853,...</td>\n",
|
730 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 80, 'nam...</td>\n",
|
731 |
+
" </tr>\n",
|
732 |
+
" <tr>\n",
|
733 |
+
" <th>4</th>\n",
|
734 |
+
" <td>[{'cast_id': 5, 'character': 'John Carter', 'c...</td>\n",
|
735 |
+
" <td>[{'credit_id': '52fe479ac3a36847f813eaa3', 'de...</td>\n",
|
736 |
+
" <td>[{'id': 818, 'name': 'based on novel'}, {'id':...</td>\n",
|
737 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...</td>\n",
|
738 |
+
" </tr>\n",
|
739 |
+
" <tr>\n",
|
740 |
+
" <th>5</th>\n",
|
741 |
+
" <td>[{'cast_id': 30, 'character': 'Peter Parker / ...</td>\n",
|
742 |
+
" <td>[{'credit_id': '52fe4252c3a36847f80151a5', 'de...</td>\n",
|
743 |
+
" <td>[{'id': 851, 'name': 'dual identity'}, {'id': ...</td>\n",
|
744 |
+
" <td>[{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'na...</td>\n",
|
745 |
+
" </tr>\n",
|
746 |
+
" <tr>\n",
|
747 |
+
" <th>6</th>\n",
|
748 |
+
" <td>[{'cast_id': 34, 'character': 'Flynn Rider (vo...</td>\n",
|
749 |
+
" <td>[{'credit_id': '52fe46db9251416c91062101', 'de...</td>\n",
|
750 |
+
" <td>[{'id': 1562, 'name': 'hostage'}, {'id': 2343,...</td>\n",
|
751 |
+
" <td>[{'id': 16, 'name': 'Animation'}, {'id': 10751...</td>\n",
|
752 |
+
" </tr>\n",
|
753 |
+
" <tr>\n",
|
754 |
+
" <th>7</th>\n",
|
755 |
+
" <td>[{'cast_id': 76, 'character': 'Tony Stark / Ir...</td>\n",
|
756 |
+
" <td>[{'credit_id': '55d5f7d4c3a3683e7e0016eb', 'de...</td>\n",
|
757 |
+
" <td>[{'id': 8828, 'name': 'marvel comic'}, {'id': ...</td>\n",
|
758 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...</td>\n",
|
759 |
+
" </tr>\n",
|
760 |
+
" <tr>\n",
|
761 |
+
" <th>8</th>\n",
|
762 |
+
" <td>[{'cast_id': 3, 'character': 'Harry Potter', '...</td>\n",
|
763 |
+
" <td>[{'credit_id': '52fe4273c3a36847f801fab1', 'de...</td>\n",
|
764 |
+
" <td>[{'id': 616, 'name': 'witch'}, {'id': 2343, 'n...</td>\n",
|
765 |
+
" <td>[{'id': 12, 'name': 'Adventure'}, {'id': 14, '...</td>\n",
|
766 |
+
" </tr>\n",
|
767 |
+
" <tr>\n",
|
768 |
+
" <th>9</th>\n",
|
769 |
+
" <td>[{'cast_id': 18, 'character': 'Bruce Wayne / B...</td>\n",
|
770 |
+
" <td>[{'credit_id': '553bf23692514135c8002886', 'de...</td>\n",
|
771 |
+
" <td>[{'id': 849, 'name': 'dc comics'}, {'id': 7002...</td>\n",
|
772 |
+
" <td>[{'id': 28, 'name': 'Action'}, {'id': 12, 'nam...</td>\n",
|
773 |
+
" </tr>\n",
|
774 |
+
" </tbody>\n",
|
775 |
+
"</table>\n",
|
776 |
+
"</div>"
|
777 |
+
],
|
778 |
+
"text/plain": [
|
779 |
+
" cast \\\n",
|
780 |
+
"0 [{'cast_id': 242, 'character': 'Jake Sully', '... \n",
|
781 |
+
"1 [{'cast_id': 4, 'character': 'Captain Jack Spa... \n",
|
782 |
+
"2 [{'cast_id': 1, 'character': 'James Bond', 'cr... \n",
|
783 |
+
"3 [{'cast_id': 2, 'character': 'Bruce Wayne / Ba... \n",
|
784 |
+
"4 [{'cast_id': 5, 'character': 'John Carter', 'c... \n",
|
785 |
+
"5 [{'cast_id': 30, 'character': 'Peter Parker / ... \n",
|
786 |
+
"6 [{'cast_id': 34, 'character': 'Flynn Rider (vo... \n",
|
787 |
+
"7 [{'cast_id': 76, 'character': 'Tony Stark / Ir... \n",
|
788 |
+
"8 [{'cast_id': 3, 'character': 'Harry Potter', '... \n",
|
789 |
+
"9 [{'cast_id': 18, 'character': 'Bruce Wayne / B... \n",
|
790 |
+
"\n",
|
791 |
+
" crew \\\n",
|
792 |
+
"0 [{'credit_id': '52fe48009251416c750aca23', 'de... \n",
|
793 |
+
"1 [{'credit_id': '52fe4232c3a36847f800b579', 'de... \n",
|
794 |
+
"2 [{'credit_id': '54805967c3a36829b5002c41', 'de... \n",
|
795 |
+
"3 [{'credit_id': '52fe4781c3a36847f81398c3', 'de... \n",
|
796 |
+
"4 [{'credit_id': '52fe479ac3a36847f813eaa3', 'de... \n",
|
797 |
+
"5 [{'credit_id': '52fe4252c3a36847f80151a5', 'de... \n",
|
798 |
+
"6 [{'credit_id': '52fe46db9251416c91062101', 'de... \n",
|
799 |
+
"7 [{'credit_id': '55d5f7d4c3a3683e7e0016eb', 'de... \n",
|
800 |
+
"8 [{'credit_id': '52fe4273c3a36847f801fab1', 'de... \n",
|
801 |
+
"9 [{'credit_id': '553bf23692514135c8002886', 'de... \n",
|
802 |
+
"\n",
|
803 |
+
" keywords \\\n",
|
804 |
+
"0 [{'id': 1463, 'name': 'culture clash'}, {'id':... \n",
|
805 |
+
"1 [{'id': 270, 'name': 'ocean'}, {'id': 726, 'na... \n",
|
806 |
+
"2 [{'id': 470, 'name': 'spy'}, {'id': 818, 'name... \n",
|
807 |
+
"3 [{'id': 849, 'name': 'dc comics'}, {'id': 853,... \n",
|
808 |
+
"4 [{'id': 818, 'name': 'based on novel'}, {'id':... \n",
|
809 |
+
"5 [{'id': 851, 'name': 'dual identity'}, {'id': ... \n",
|
810 |
+
"6 [{'id': 1562, 'name': 'hostage'}, {'id': 2343,... \n",
|
811 |
+
"7 [{'id': 8828, 'name': 'marvel comic'}, {'id': ... \n",
|
812 |
+
"8 [{'id': 616, 'name': 'witch'}, {'id': 2343, 'n... \n",
|
813 |
+
"9 [{'id': 849, 'name': 'dc comics'}, {'id': 7002... \n",
|
814 |
+
"\n",
|
815 |
+
" genres \n",
|
816 |
+
"0 [{'id': 28, 'name': 'Action'}, {'id': 12, 'nam... \n",
|
817 |
+
"1 [{'id': 12, 'name': 'Adventure'}, {'id': 14, '... \n",
|
818 |
+
"2 [{'id': 28, 'name': 'Action'}, {'id': 12, 'nam... \n",
|
819 |
+
"3 [{'id': 28, 'name': 'Action'}, {'id': 80, 'nam... \n",
|
820 |
+
"4 [{'id': 28, 'name': 'Action'}, {'id': 12, 'nam... \n",
|
821 |
+
"5 [{'id': 14, 'name': 'Fantasy'}, {'id': 28, 'na... \n",
|
822 |
+
"6 [{'id': 16, 'name': 'Animation'}, {'id': 10751... \n",
|
823 |
+
"7 [{'id': 28, 'name': 'Action'}, {'id': 12, 'nam... \n",
|
824 |
+
"8 [{'id': 12, 'name': 'Adventure'}, {'id': 14, '... \n",
|
825 |
+
"9 [{'id': 28, 'name': 'Action'}, {'id': 12, 'nam... "
|
826 |
+
]
|
827 |
+
},
|
828 |
+
"execution_count": 9,
|
829 |
+
"metadata": {},
|
830 |
+
"output_type": "execute_result"
|
831 |
+
}
|
832 |
+
],
|
833 |
+
"source": [
|
834 |
+
"features = [\"cast\", \"crew\", \"keywords\", \"genres\"]\n",
|
835 |
+
"for feature in features:\n",
|
836 |
+
" movies_df[feature] = movies_df[feature].apply(literal_eval)\n",
|
837 |
+
"movies_df[features].head(10)"
|
838 |
+
]
|
839 |
+
},
|
840 |
+
{
|
841 |
+
"cell_type": "code",
|
842 |
+
"execution_count": 10,
|
843 |
+
"metadata": {},
|
844 |
+
"outputs": [],
|
845 |
+
"source": [
|
846 |
+
"def get_director(input):\n",
|
847 |
+
" for i in input:\n",
|
848 |
+
" if i[\"job\"] == \"Director\":\n",
|
849 |
+
" return i[\"name\"]\n",
|
850 |
+
" return np.nan\n",
|
851 |
+
"\n",
|
852 |
+
"def get_list(x):\n",
|
853 |
+
" if isinstance(x, list):\n",
|
854 |
+
" names = [i[\"name\"] for i in x]\n",
|
855 |
+
" if len(names) > 3:\n",
|
856 |
+
" names = names[:3]\n",
|
857 |
+
" return names\n",
|
858 |
+
" return []"
|
859 |
+
]
|
860 |
+
},
|
861 |
+
{
|
862 |
+
"cell_type": "code",
|
863 |
+
"execution_count": 11,
|
864 |
+
"metadata": {},
|
865 |
+
"outputs": [
|
866 |
+
{
|
867 |
+
"data": {
|
868 |
+
"text/html": [
|
869 |
+
"<div>\n",
|
870 |
+
"<style scoped>\n",
|
871 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
872 |
+
" vertical-align: middle;\n",
|
873 |
+
" }\n",
|
874 |
+
"\n",
|
875 |
+
" .dataframe tbody tr th {\n",
|
876 |
+
" vertical-align: top;\n",
|
877 |
+
" }\n",
|
878 |
+
"\n",
|
879 |
+
" .dataframe thead th {\n",
|
880 |
+
" text-align: right;\n",
|
881 |
+
" }\n",
|
882 |
+
"</style>\n",
|
883 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
884 |
+
" <thead>\n",
|
885 |
+
" <tr style=\"text-align: right;\">\n",
|
886 |
+
" <th></th>\n",
|
887 |
+
" <th>title</th>\n",
|
888 |
+
" <th>cast</th>\n",
|
889 |
+
" <th>director</th>\n",
|
890 |
+
" <th>keywords</th>\n",
|
891 |
+
" <th>genres</th>\n",
|
892 |
+
" </tr>\n",
|
893 |
+
" </thead>\n",
|
894 |
+
" <tbody>\n",
|
895 |
+
" <tr>\n",
|
896 |
+
" <th>0</th>\n",
|
897 |
+
" <td>Avatar</td>\n",
|
898 |
+
" <td>[Sam Worthington, Zoe Saldana, Sigourney Weaver]</td>\n",
|
899 |
+
" <td>James Cameron</td>\n",
|
900 |
+
" <td>[culture clash, future, space war]</td>\n",
|
901 |
+
" <td>[Action, Adventure, Fantasy]</td>\n",
|
902 |
+
" </tr>\n",
|
903 |
+
" <tr>\n",
|
904 |
+
" <th>1</th>\n",
|
905 |
+
" <td>Pirates of the Caribbean: At World's End</td>\n",
|
906 |
+
" <td>[Johnny Depp, Orlando Bloom, Keira Knightley]</td>\n",
|
907 |
+
" <td>Gore Verbinski</td>\n",
|
908 |
+
" <td>[ocean, drug abuse, exotic island]</td>\n",
|
909 |
+
" <td>[Adventure, Fantasy, Action]</td>\n",
|
910 |
+
" </tr>\n",
|
911 |
+
" <tr>\n",
|
912 |
+
" <th>2</th>\n",
|
913 |
+
" <td>Spectre</td>\n",
|
914 |
+
" <td>[Daniel Craig, Christoph Waltz, Léa Seydoux]</td>\n",
|
915 |
+
" <td>Sam Mendes</td>\n",
|
916 |
+
" <td>[spy, based on novel, secret agent]</td>\n",
|
917 |
+
" <td>[Action, Adventure, Crime]</td>\n",
|
918 |
+
" </tr>\n",
|
919 |
+
" <tr>\n",
|
920 |
+
" <th>3</th>\n",
|
921 |
+
" <td>The Dark Knight Rises</td>\n",
|
922 |
+
" <td>[Christian Bale, Michael Caine, Gary Oldman]</td>\n",
|
923 |
+
" <td>Christopher Nolan</td>\n",
|
924 |
+
" <td>[dc comics, crime fighter, terrorist]</td>\n",
|
925 |
+
" <td>[Action, Crime, Drama]</td>\n",
|
926 |
+
" </tr>\n",
|
927 |
+
" <tr>\n",
|
928 |
+
" <th>4</th>\n",
|
929 |
+
" <td>John Carter</td>\n",
|
930 |
+
" <td>[Taylor Kitsch, Lynn Collins, Samantha Morton]</td>\n",
|
931 |
+
" <td>Andrew Stanton</td>\n",
|
932 |
+
" <td>[based on novel, mars, medallion]</td>\n",
|
933 |
+
" <td>[Action, Adventure, Science Fiction]</td>\n",
|
934 |
+
" </tr>\n",
|
935 |
+
" </tbody>\n",
|
936 |
+
"</table>\n",
|
937 |
+
"</div>"
|
938 |
+
],
|
939 |
+
"text/plain": [
|
940 |
+
" title \\\n",
|
941 |
+
"0 Avatar \n",
|
942 |
+
"1 Pirates of the Caribbean: At World's End \n",
|
943 |
+
"2 Spectre \n",
|
944 |
+
"3 The Dark Knight Rises \n",
|
945 |
+
"4 John Carter \n",
|
946 |
+
"\n",
|
947 |
+
" cast director \\\n",
|
948 |
+
"0 [Sam Worthington, Zoe Saldana, Sigourney Weaver] James Cameron \n",
|
949 |
+
"1 [Johnny Depp, Orlando Bloom, Keira Knightley] Gore Verbinski \n",
|
950 |
+
"2 [Daniel Craig, Christoph Waltz, Léa Seydoux] Sam Mendes \n",
|
951 |
+
"3 [Christian Bale, Michael Caine, Gary Oldman] Christopher Nolan \n",
|
952 |
+
"4 [Taylor Kitsch, Lynn Collins, Samantha Morton] Andrew Stanton \n",
|
953 |
+
"\n",
|
954 |
+
" keywords genres \n",
|
955 |
+
"0 [culture clash, future, space war] [Action, Adventure, Fantasy] \n",
|
956 |
+
"1 [ocean, drug abuse, exotic island] [Adventure, Fantasy, Action] \n",
|
957 |
+
"2 [spy, based on novel, secret agent] [Action, Adventure, Crime] \n",
|
958 |
+
"3 [dc comics, crime fighter, terrorist] [Action, Crime, Drama] \n",
|
959 |
+
"4 [based on novel, mars, medallion] [Action, Adventure, Science Fiction] "
|
960 |
+
]
|
961 |
+
},
|
962 |
+
"execution_count": 11,
|
963 |
+
"metadata": {},
|
964 |
+
"output_type": "execute_result"
|
965 |
+
}
|
966 |
+
],
|
967 |
+
"source": [
|
968 |
+
"movies_df[\"director\"] = movies_df[\"crew\"].apply(get_director)\n",
|
969 |
+
"features = [\"cast\", \"keywords\", \"genres\"]\n",
|
970 |
+
"for feature in features:\n",
|
971 |
+
" movies_df[feature] = movies_df[feature].apply(get_list)\n",
|
972 |
+
"movies_df[['title', 'cast', 'director', 'keywords', 'genres']].head()"
|
973 |
+
]
|
974 |
+
},
|
975 |
+
{
|
976 |
+
"cell_type": "code",
|
977 |
+
"execution_count": 12,
|
978 |
+
"metadata": {},
|
979 |
+
"outputs": [],
|
980 |
+
"source": [
|
981 |
+
"def clean_data(row):\n",
|
982 |
+
" if isinstance(row, list):\n",
|
983 |
+
" return [str.lower(i.replace(\" \", \"\")) for i in row]\n",
|
984 |
+
" else:\n",
|
985 |
+
" if isinstance(row, str):\n",
|
986 |
+
" return str.lower(row.replace(\" \", \"\"))\n",
|
987 |
+
" else:\n",
|
988 |
+
" return \"\"\n",
|
989 |
+
"\n",
|
990 |
+
"def create_soup(features):\n",
|
991 |
+
" soup = ' '.join(features['keywords'])\n",
|
992 |
+
" soup += ' ' + ' '.join(features['cast'])\n",
|
993 |
+
" soup += ' ' + features['director']\n",
|
994 |
+
" soup += ' ' + ' '.join(features['genres'])\n",
|
995 |
+
" return soup"
|
996 |
+
]
|
997 |
+
},
|
998 |
+
{
|
999 |
+
"cell_type": "code",
|
1000 |
+
"execution_count": 13,
|
1001 |
+
"metadata": {},
|
1002 |
+
"outputs": [
|
1003 |
+
{
|
1004 |
+
"data": {
|
1005 |
+
"text/plain": [
|
1006 |
+
"0 cultureclash future spacewar samworthington zo...\n",
|
1007 |
+
"1 ocean drugabuse exoticisland johnnydepp orland...\n",
|
1008 |
+
"2 spy basedonnovel secretagent danielcraig chris...\n",
|
1009 |
+
"3 dccomics crimefighter terrorist christianbale ...\n",
|
1010 |
+
"4 basedonnovel mars medallion taylorkitsch lynnc...\n",
|
1011 |
+
"Name: soup, dtype: object"
|
1012 |
+
]
|
1013 |
+
},
|
1014 |
+
"execution_count": 13,
|
1015 |
+
"metadata": {},
|
1016 |
+
"output_type": "execute_result"
|
1017 |
+
}
|
1018 |
+
],
|
1019 |
+
"source": [
|
1020 |
+
"features = ['cast', 'keywords', 'director', 'genres']\n",
|
1021 |
+
"for feature in features:\n",
|
1022 |
+
" movies_df[feature] = movies_df[feature].apply(clean_data)\n",
|
1023 |
+
"\n",
|
1024 |
+
"movies_df[\"soup\"] = movies_df.apply(create_soup, axis=1)\n",
|
1025 |
+
"movies_df[\"soup\"].head()"
|
1026 |
+
]
|
1027 |
+
},
|
1028 |
+
{
|
1029 |
+
"cell_type": "code",
|
1030 |
+
"execution_count": 14,
|
1031 |
+
"metadata": {},
|
1032 |
+
"outputs": [
|
1033 |
+
{
|
1034 |
+
"name": "stdout",
|
1035 |
+
"output_type": "stream",
|
1036 |
+
"text": [
|
1037 |
+
"(4803, 11520)\n",
|
1038 |
+
"(4803, 4803)\n"
|
1039 |
+
]
|
1040 |
+
}
|
1041 |
+
],
|
1042 |
+
"source": [
|
1043 |
+
"count_vectorizer = CountVectorizer(stop_words = \"english\")\n",
|
1044 |
+
"count_matrix = count_vectorizer.fit_transform(movies_df[\"soup\"])\n",
|
1045 |
+
"print(count_matrix.shape)\n",
|
1046 |
+
"\n",
|
1047 |
+
"cosine_sim = cosine_similarity(count_matrix, count_matrix) \n",
|
1048 |
+
"print(cosine_sim.shape)\n",
|
1049 |
+
"\n",
|
1050 |
+
"movies_df = movies_df.reset_index()\n",
|
1051 |
+
"indices = pd.Series(movies_df.index, index = movies_df['title'])"
|
1052 |
+
]
|
1053 |
+
},
|
1054 |
+
{
|
1055 |
+
"cell_type": "code",
|
1056 |
+
"execution_count": 15,
|
1057 |
+
"metadata": {},
|
1058 |
+
"outputs": [
|
1059 |
+
{
|
1060 |
+
"data": {
|
1061 |
+
"text/plain": [
|
1062 |
+
"title\n",
|
1063 |
+
"Avatar 0\n",
|
1064 |
+
"Pirates of the Caribbean: At World's End 1\n",
|
1065 |
+
"Spectre 2\n",
|
1066 |
+
"The Dark Knight Rises 3\n",
|
1067 |
+
"John Carter 4\n",
|
1068 |
+
"dtype: int64"
|
1069 |
+
]
|
1070 |
+
},
|
1071 |
+
"execution_count": 15,
|
1072 |
+
"metadata": {},
|
1073 |
+
"output_type": "execute_result"
|
1074 |
+
}
|
1075 |
+
],
|
1076 |
+
"source": [
|
1077 |
+
"indices = pd.Series(movies_df.index, index = movies_df[\"title\"]).drop_duplicates()\n",
|
1078 |
+
"indices.head()"
|
1079 |
+
]
|
1080 |
+
},
|
1081 |
+
{
|
1082 |
+
"cell_type": "code",
|
1083 |
+
"execution_count": 16,
|
1084 |
+
"metadata": {},
|
1085 |
+
"outputs": [],
|
1086 |
+
"source": [
|
1087 |
+
"# Save model to file\n",
|
1088 |
+
"model_file = open('movie_recommendation_model.pkl', 'wb')\n",
|
1089 |
+
"pickle.dump(movies_df, model_file)\n",
|
1090 |
+
"pickle.dump(cosine_sim, model_file)\n",
|
1091 |
+
"pickle.dump(indices, model_file)\n",
|
1092 |
+
"model_file.close()"
|
1093 |
+
]
|
1094 |
+
},
|
1095 |
+
{
|
1096 |
+
"cell_type": "markdown",
|
1097 |
+
"metadata": {},
|
1098 |
+
"source": [
|
1099 |
+
"The get_recommendations() function takes the title of the movie and the similarity function as input. It follows the below steps to make recommendations.\n",
|
1100 |
+
"\n",
|
1101 |
+
"- Get the index of the movie using the title.\n",
|
1102 |
+
"- Get the list of similarity scores of the movies concerning all the movies.\n",
|
1103 |
+
"- Enumerate them (create tuples) with the first element being the index and the second element is the cosine similarity score.\n",
|
1104 |
+
"- Sort the list of tuples in descending order based on the similarity score.\n",
|
1105 |
+
"- Get the list of the indices of the top 10 movies from the above sorted list. Exclude the first element because it is the title itself.\n",
|
1106 |
+
"- Map those indices to their respective titles and return the movies list."
|
1107 |
+
]
|
1108 |
+
},
|
1109 |
+
{
|
1110 |
+
"cell_type": "code",
|
1111 |
+
"execution_count": 17,
|
1112 |
+
"metadata": {},
|
1113 |
+
"outputs": [],
|
1114 |
+
"source": [
|
1115 |
+
"def get_recommendations(title, cosine_sim = cosine_sim):\n",
|
1116 |
+
" idx = indices[title]\n",
|
1117 |
+
" similarity_scores = list(enumerate(cosine_sim[idx]))\n",
|
1118 |
+
" similarity_scores = sorted(similarity_scores, key = lambda x: x[1], reverse = True)\n",
|
1119 |
+
" similarity_scores = similarity_scores[1:11]\n",
|
1120 |
+
" # (a, b) where a is id of movie, b is similarity_scores\n",
|
1121 |
+
" movies_indices = [ind[0] for ind in similarity_scores]\n",
|
1122 |
+
" movies = movies_df[\"title\"].iloc[movies_indices]\n",
|
1123 |
+
" return movies"
|
1124 |
+
]
|
1125 |
+
},
|
1126 |
+
{
|
1127 |
+
"cell_type": "code",
|
1128 |
+
"execution_count": 18,
|
1129 |
+
"metadata": {},
|
1130 |
+
"outputs": [
|
1131 |
+
{
|
1132 |
+
"name": "stdout",
|
1133 |
+
"output_type": "stream",
|
1134 |
+
"text": [
|
1135 |
+
"65 The Dark Knight\n",
|
1136 |
+
"119 Batman Begins\n",
|
1137 |
+
"4638 Amidst the Devil's Wings\n",
|
1138 |
+
"1196 The Prestige\n",
|
1139 |
+
"3073 Romeo Is Bleeding\n",
|
1140 |
+
"3326 Black November\n",
|
1141 |
+
"1503 Takers\n",
|
1142 |
+
"1986 Faster\n",
|
1143 |
+
"303 Catwoman\n",
|
1144 |
+
"747 Gangster Squad\n",
|
1145 |
+
"Name: title, dtype: object\n"
|
1146 |
+
]
|
1147 |
+
}
|
1148 |
+
],
|
1149 |
+
"source": [
|
1150 |
+
"print(get_recommendations(\"The Dark Knight Rises\"))"
|
1151 |
+
]
|
1152 |
+
},
|
1153 |
+
{
|
1154 |
+
"cell_type": "code",
|
1155 |
+
"execution_count": 19,
|
1156 |
+
"metadata": {},
|
1157 |
+
"outputs": [
|
1158 |
+
{
|
1159 |
+
"name": "stdout",
|
1160 |
+
"output_type": "stream",
|
1161 |
+
"text": [
|
1162 |
+
"7 Avengers: Age of Ultron\n",
|
1163 |
+
"26 Captain America: Civil War\n",
|
1164 |
+
"79 Iron Man 2\n",
|
1165 |
+
"169 Captain America: The First Avenger\n",
|
1166 |
+
"174 The Incredible Hulk\n",
|
1167 |
+
"85 Captain America: The Winter Soldier\n",
|
1168 |
+
"31 Iron Man 3\n",
|
1169 |
+
"33 X-Men: The Last Stand\n",
|
1170 |
+
"68 Iron Man\n",
|
1171 |
+
"94 Guardians of the Galaxy\n",
|
1172 |
+
"Name: title, dtype: object\n"
|
1173 |
+
]
|
1174 |
+
}
|
1175 |
+
],
|
1176 |
+
"source": [
|
1177 |
+
"print(get_recommendations(\"The Avengers\"))"
|
1178 |
+
]
|
1179 |
+
},
|
1180 |
+
{
|
1181 |
+
"cell_type": "code",
|
1182 |
+
"execution_count": 20,
|
1183 |
+
"metadata": {},
|
1184 |
+
"outputs": [
|
1185 |
+
{
|
1186 |
+
"name": "stdout",
|
1187 |
+
"output_type": "stream",
|
1188 |
+
"text": [
|
1189 |
+
"2577 Tuck Everlasting\n",
|
1190 |
+
"3072 Atlas Shrugged Part II\n",
|
1191 |
+
"4691 Yesterday Was a Lie\n",
|
1192 |
+
"266 I, Robot\n",
|
1193 |
+
"3155 Melancholia\n",
|
1194 |
+
"3642 Atlas Shrugged Part III: Who is John Galt?\n",
|
1195 |
+
"163 Watchmen\n",
|
1196 |
+
"220 Prometheus\n",
|
1197 |
+
"365 Contact\n",
|
1198 |
+
"461 Lost in Space\n",
|
1199 |
+
"Name: title, dtype: object\n"
|
1200 |
+
]
|
1201 |
+
}
|
1202 |
+
],
|
1203 |
+
"source": [
|
1204 |
+
"print(get_recommendations(\"Dark City\"))"
|
1205 |
+
]
|
1206 |
+
}
|
1207 |
+
],
|
1208 |
+
"metadata": {
|
1209 |
+
"kernelspec": {
|
1210 |
+
"display_name": ".ptvenv",
|
1211 |
+
"language": "python",
|
1212 |
+
"name": "python3"
|
1213 |
+
},
|
1214 |
+
"language_info": {
|
1215 |
+
"codemirror_mode": {
|
1216 |
+
"name": "ipython",
|
1217 |
+
"version": 3
|
1218 |
+
},
|
1219 |
+
"file_extension": ".py",
|
1220 |
+
"mimetype": "text/x-python",
|
1221 |
+
"name": "python",
|
1222 |
+
"nbconvert_exporter": "python",
|
1223 |
+
"pygments_lexer": "ipython3",
|
1224 |
+
"version": "3.12.3"
|
1225 |
+
}
|
1226 |
+
},
|
1227 |
+
"nbformat": 4,
|
1228 |
+
"nbformat_minor": 2
|
1229 |
+
}
|
notebooks/music_model.ipynb
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": null,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pickle, glob\n",
|
10 |
+
"import numpy as np\n",
|
11 |
+
"import keras.utils as keras_utils\n",
|
12 |
+
"from keras.models import Sequential\n",
|
13 |
+
"from keras.layers import Dense\n",
|
14 |
+
"from keras.layers import Dropout\n",
|
15 |
+
"from keras.layers import LSTM\n",
|
16 |
+
"from keras.layers import BatchNormalization as BatchNorm\n",
|
17 |
+
"from keras.layers import Activation\n",
|
18 |
+
"from keras.callbacks import ModelCheckpoint, EarlyStopping\n",
|
19 |
+
"from music21 import converter, instrument, note, chord"
|
20 |
+
]
|
21 |
+
},
|
22 |
+
{
|
23 |
+
"cell_type": "code",
|
24 |
+
"execution_count": 2,
|
25 |
+
"metadata": {},
|
26 |
+
"outputs": [],
|
27 |
+
"source": [
|
28 |
+
"# To generate a new list of notes to train against\n",
|
29 |
+
"# notes = []\n",
|
30 |
+
"# for file in glob.glob(\"./midi_songs/*.mid\"):\n",
|
31 |
+
"# midi = converter.parse(file)\n",
|
32 |
+
"# notes_to_parse = None\n",
|
33 |
+
"# parts = instrument.partitionByInstrument(midi)\n",
|
34 |
+
"# if parts: # file has instrument parts\n",
|
35 |
+
"# notes_to_parse = parts.parts[0].recurse()\n",
|
36 |
+
"# else: # file has notes in a flat structure\n",
|
37 |
+
"# notes_to_parse = midi.flat.notes\n",
|
38 |
+
"# for element in notes_to_parse:\n",
|
39 |
+
"# if isinstance(element, note.Note):\n",
|
40 |
+
"# notes.append(str(element.pitch))\n",
|
41 |
+
"# elif isinstance(element, chord.Chord):\n",
|
42 |
+
"# notes.append('.'.join(str(n) for n in element.normalOrder))\n",
|
43 |
+
"\n",
|
44 |
+
"# with open('data/music_notes.pkl', 'wb') as filepath:\n",
|
45 |
+
"# pickle.dump(notes, filepath)\n",
|
46 |
+
"# pickle.dump(pitchnames, filepath)\n",
|
47 |
+
"# pickle.dump(n_vocab, filepath)"
|
48 |
+
]
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"cell_type": "code",
|
52 |
+
"execution_count": null,
|
53 |
+
"metadata": {},
|
54 |
+
"outputs": [],
|
55 |
+
"source": [
|
56 |
+
"with open('data/music_notes.pkl', 'rb') as filepath:\n",
|
57 |
+
" notes = pickle.load(filepath)\n",
|
58 |
+
" pitchnames = pickle.load(filepath)\n",
|
59 |
+
" n_vocab = pickle.load(filepath)"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "code",
|
64 |
+
"execution_count": 4,
|
65 |
+
"metadata": {},
|
66 |
+
"outputs": [],
|
67 |
+
"source": [
|
68 |
+
"sequence_length = 100\n",
|
69 |
+
"# get all pitch names\n",
|
70 |
+
"pitchnames = sorted(set(item for item in notes))\n",
|
71 |
+
"# create a dictionary to map pitches to integers\n",
|
72 |
+
"note_to_int = dict((note, number) for number, note in enumerate(pitchnames))\n",
|
73 |
+
"network_input = []\n",
|
74 |
+
"network_output = []\n",
|
75 |
+
"# create input sequences and the corresponding outputs\n",
|
76 |
+
"for i in range(0, len(notes) - sequence_length, 1):\n",
|
77 |
+
" sequence_in = notes[i:i + sequence_length]\n",
|
78 |
+
" sequence_out = notes[i + sequence_length]\n",
|
79 |
+
" network_input.append([note_to_int[char] for char in sequence_in])\n",
|
80 |
+
" network_output.append(note_to_int[sequence_out])\n",
|
81 |
+
"n_patterns = len(network_input)\n",
|
82 |
+
"# reshape the input into a format compatible with LSTM layers\n",
|
83 |
+
"network_input = np.reshape(network_input, (n_patterns, sequence_length, 1))\n",
|
84 |
+
"# normalize input\n",
|
85 |
+
"network_input = network_input / float(n_vocab)\n",
|
86 |
+
"network_output = keras_utils.to_categorical(network_output)"
|
87 |
+
]
|
88 |
+
},
|
89 |
+
{
|
90 |
+
"cell_type": "code",
|
91 |
+
"execution_count": null,
|
92 |
+
"metadata": {},
|
93 |
+
"outputs": [],
|
94 |
+
"source": [
|
95 |
+
"model = Sequential()\n",
|
96 |
+
"model.add(LSTM(\n",
|
97 |
+
" 512,\n",
|
98 |
+
" input_shape=(network_input.shape[1], network_input.shape[2]),\n",
|
99 |
+
" recurrent_dropout=0.3,\n",
|
100 |
+
" return_sequences=True\n",
|
101 |
+
"))\n",
|
102 |
+
"model.add(LSTM(512, return_sequences=True, recurrent_dropout=0.3,))\n",
|
103 |
+
"model.add(LSTM(512))\n",
|
104 |
+
"model.add(BatchNorm())\n",
|
105 |
+
"model.add(Dropout(0.3))\n",
|
106 |
+
"model.add(Dense(256))\n",
|
107 |
+
"model.add(Activation('relu'))\n",
|
108 |
+
"model.add(BatchNorm())\n",
|
109 |
+
"model.add(Dropout(0.3))\n",
|
110 |
+
"model.add(Dense(n_vocab))\n",
|
111 |
+
"model.add(Activation('softmax'))\n",
|
112 |
+
"model.compile(loss='categorical_crossentropy', optimizer='rmsprop')"
|
113 |
+
]
|
114 |
+
},
|
115 |
+
{
|
116 |
+
"cell_type": "code",
|
117 |
+
"execution_count": null,
|
118 |
+
"metadata": {},
|
119 |
+
"outputs": [],
|
120 |
+
"source": [
|
121 |
+
"checkpoint_filepath = \"./models/model.keras\" \n",
|
122 |
+
"checkpoint = ModelCheckpoint(\n",
|
123 |
+
" filepath=checkpoint_filepath,\n",
|
124 |
+
" monitor='loss',\n",
|
125 |
+
" mode='min',\n",
|
126 |
+
" save_best_only=True,\n",
|
127 |
+
" verbose=0\n",
|
128 |
+
")\n",
|
129 |
+
"early_stopping = EarlyStopping(\n",
|
130 |
+
" monitor=\"loss\",\n",
|
131 |
+
" patience=10,\n",
|
132 |
+
" min_delta=0.001,\n",
|
133 |
+
" restore_best_weights=True,\n",
|
134 |
+
")\n",
|
135 |
+
"callbacks_list = [early_stopping, checkpoint] \n",
|
136 |
+
"model.fit(network_input, network_output, epochs=1000, batch_size=64, callbacks=callbacks_list)"
|
137 |
+
]
|
138 |
+
}
|
139 |
+
],
|
140 |
+
"metadata": {
|
141 |
+
"kernelspec": {
|
142 |
+
"display_name": ".venv",
|
143 |
+
"language": "python",
|
144 |
+
"name": "python3"
|
145 |
+
},
|
146 |
+
"language_info": {
|
147 |
+
"codemirror_mode": {
|
148 |
+
"name": "ipython",
|
149 |
+
"version": 3
|
150 |
+
},
|
151 |
+
"file_extension": ".py",
|
152 |
+
"mimetype": "text/x-python",
|
153 |
+
"name": "python",
|
154 |
+
"nbconvert_exporter": "python",
|
155 |
+
"pygments_lexer": "ipython3",
|
156 |
+
"version": "3.12.3"
|
157 |
+
}
|
158 |
+
},
|
159 |
+
"nbformat": 4,
|
160 |
+
"nbformat_minor": 2
|
161 |
+
}
|
notebooks/stock_market_analysis.ipynb
ADDED
@@ -0,0 +1,1083 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"metadata": {
|
6 |
+
"id": "7SZxKPcyDbw_"
|
7 |
+
},
|
8 |
+
"source": [
|
9 |
+
"# Stock Market Analysis And Forecasting\n",
|
10 |
+
"A stock market, equity market, or share market is the aggregation of buyers and sellers of stocks (also called shares), which represent ownership claims on businesses; these may include securities listed on a public stock exchange, as well as stock that is only traded privately, such as shares of private companies which are sold to investors through equity crowdfunding platforms. Investment in the stock market is most often done via stockbrokerages and electronic trading platforms. Investment is usually made with an investment strategy in mind.\n",
|
11 |
+
"\n",
|
12 |
+
"The task of stock prediction has always been a challenging problem for statistics experts and finance. The main reason behind this prediction is buying stocks that are likely to increase in price and then selling stocks that are probably to fall. Generally, there are two ways for stock market prediction.\n",
|
13 |
+
"\n",
|
14 |
+
"Fundamental analysis is one of them and relies on a company's technique and fundamental information like market position, expenses and annual growth rates. The second one is the technical analysis method, which concentrates on previous stock prices and values.\n",
|
15 |
+
"\n",
|
16 |
+
"In the first part of our project, we will try to analyze the data. and in the second part, we will forecast the stock market.\n",
|
17 |
+
"\n",
|
18 |
+
"## Dataset\n",
|
19 |
+
"We will be using stock data from 2006-2018 for the following publicly traded companies:\n",
|
20 |
+
" 1. Google\n",
|
21 |
+
" 2. Microsoft\n",
|
22 |
+
" 3. IBM\n",
|
23 |
+
" 4. Amazon\n",
|
24 |
+
"\n",
|
25 |
+
"## Analysis\n",
|
26 |
+
"We will find the distribution of close and open. Then we will find the correlation between close and open. After that, we will visualize the attributes [Open, High, Low, Close, volume] of our datasets. Then we compare the \"High\" and \"Close\" of each datasets. At last, we will find the trend and seasonality in the dataset."
|
27 |
+
]
|
28 |
+
},
|
29 |
+
{
|
30 |
+
"cell_type": "code",
|
31 |
+
"execution_count": 1,
|
32 |
+
"metadata": {
|
33 |
+
"id": "aiCB-iASNjYf"
|
34 |
+
},
|
35 |
+
"outputs": [],
|
36 |
+
"source": [
|
37 |
+
"import numpy as np \n",
|
38 |
+
"import pandas as pd\n",
|
39 |
+
"import matplotlib.pyplot as plt\n",
|
40 |
+
"import seaborn as sns\n",
|
41 |
+
"import plotly.express as px\n",
|
42 |
+
"import pickle"
|
43 |
+
]
|
44 |
+
},
|
45 |
+
{
|
46 |
+
"cell_type": "code",
|
47 |
+
"execution_count": null,
|
48 |
+
"metadata": {
|
49 |
+
"colab": {
|
50 |
+
"base_uri": "https://localhost:8080/",
|
51 |
+
"height": 235
|
52 |
+
},
|
53 |
+
"id": "Cf8CvSh6OGay",
|
54 |
+
"outputId": "7ce041bf-0827-415c-8af8-a5f97b028c22"
|
55 |
+
},
|
56 |
+
"outputs": [],
|
57 |
+
"source": [
|
58 |
+
"google = pd.read_csv('./data/GOOGL_2006-01-01_to_2018-01-01.csv', index_col='Date', parse_dates=['Date'])\n",
|
59 |
+
"google.head()"
|
60 |
+
]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"cell_type": "code",
|
64 |
+
"execution_count": null,
|
65 |
+
"metadata": {
|
66 |
+
"colab": {
|
67 |
+
"base_uri": "https://localhost:8080/",
|
68 |
+
"height": 235
|
69 |
+
},
|
70 |
+
"id": "gYLCppXiTrK0",
|
71 |
+
"outputId": "5be584f8-e797-402c-89b3-2c6505a44c02"
|
72 |
+
},
|
73 |
+
"outputs": [],
|
74 |
+
"source": [
|
75 |
+
"microsoft = pd.read_csv('./data/MSFT_2006-01-01_to_2018-01-01.csv', index_col='Date', parse_dates=['Date'])\n",
|
76 |
+
"microsoft.head()"
|
77 |
+
]
|
78 |
+
},
|
79 |
+
{
|
80 |
+
"cell_type": "code",
|
81 |
+
"execution_count": null,
|
82 |
+
"metadata": {
|
83 |
+
"colab": {
|
84 |
+
"base_uri": "https://localhost:8080/",
|
85 |
+
"height": 235
|
86 |
+
},
|
87 |
+
"id": "iPKqlK-ZOOIx",
|
88 |
+
"outputId": "96f140cd-ace1-4dd7-948c-c53dbffd8394"
|
89 |
+
},
|
90 |
+
"outputs": [],
|
91 |
+
"source": [
|
92 |
+
"amazon = pd.read_csv('./data/AMZN_2006-01-01_to_2018-01-01.csv', index_col='Date', parse_dates=['Date'])\n",
|
93 |
+
"amazon.head()"
|
94 |
+
]
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"execution_count": null,
|
99 |
+
"metadata": {
|
100 |
+
"colab": {
|
101 |
+
"base_uri": "https://localhost:8080/",
|
102 |
+
"height": 235
|
103 |
+
},
|
104 |
+
"id": "7D6zjAx2OZRp",
|
105 |
+
"outputId": "594067ed-8438-4def-9f23-a19f2edc23d6"
|
106 |
+
},
|
107 |
+
"outputs": [],
|
108 |
+
"source": [
|
109 |
+
"ibm = pd.read_csv('./data/IBM_2006-01-01_to_2018-01-01.csv', index_col='Date', parse_dates=['Date'])\n",
|
110 |
+
"ibm.head()"
|
111 |
+
]
|
112 |
+
},
|
113 |
+
{
|
114 |
+
"cell_type": "code",
|
115 |
+
"execution_count": null,
|
116 |
+
"metadata": {
|
117 |
+
"colab": {
|
118 |
+
"base_uri": "https://localhost:8080/",
|
119 |
+
"height": 297
|
120 |
+
},
|
121 |
+
"id": "_DsuOfcPOfDZ",
|
122 |
+
"outputId": "e2856039-3928-4ba8-8990-7206eac91a64"
|
123 |
+
},
|
124 |
+
"outputs": [],
|
125 |
+
"source": [
|
126 |
+
"google.describe()"
|
127 |
+
]
|
128 |
+
},
|
129 |
+
{
|
130 |
+
"cell_type": "markdown",
|
131 |
+
"metadata": {
|
132 |
+
"id": "VOn--fTaHv9u"
|
133 |
+
},
|
134 |
+
"source": [
|
135 |
+
"After describing the google dataset, there is a high difference between the minimum and maximum values. And 75% of the value is close to the mean."
|
136 |
+
]
|
137 |
+
},
|
138 |
+
{
|
139 |
+
"cell_type": "code",
|
140 |
+
"execution_count": null,
|
141 |
+
"metadata": {
|
142 |
+
"colab": {
|
143 |
+
"base_uri": "https://localhost:8080/"
|
144 |
+
},
|
145 |
+
"id": "NlCJYoSlOkTC",
|
146 |
+
"outputId": "1e6c5e8e-c477-44e8-c8e1-0d04d0cae615"
|
147 |
+
},
|
148 |
+
"outputs": [],
|
149 |
+
"source": [
|
150 |
+
"google.columns"
|
151 |
+
]
|
152 |
+
},
|
153 |
+
{
|
154 |
+
"cell_type": "code",
|
155 |
+
"execution_count": null,
|
156 |
+
"metadata": {
|
157 |
+
"colab": {
|
158 |
+
"base_uri": "https://localhost:8080/"
|
159 |
+
},
|
160 |
+
"id": "afaJu5juPvVM",
|
161 |
+
"outputId": "d02c39e2-6673-4045-d73b-3492354eddb2"
|
162 |
+
},
|
163 |
+
"outputs": [],
|
164 |
+
"source": [
|
165 |
+
"google.info()"
|
166 |
+
]
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"cell_type": "code",
|
170 |
+
"execution_count": null,
|
171 |
+
"metadata": {
|
172 |
+
"colab": {
|
173 |
+
"base_uri": "https://localhost:8080/"
|
174 |
+
},
|
175 |
+
"id": "YJO2obUyQJ-D",
|
176 |
+
"outputId": "ebe42795-4831-4a6c-c7d0-509bf538878c"
|
177 |
+
},
|
178 |
+
"outputs": [],
|
179 |
+
"source": [
|
180 |
+
"google.isna().sum()"
|
181 |
+
]
|
182 |
+
},
|
183 |
+
{
|
184 |
+
"cell_type": "code",
|
185 |
+
"execution_count": null,
|
186 |
+
"metadata": {
|
187 |
+
"colab": {
|
188 |
+
"base_uri": "https://localhost:8080/",
|
189 |
+
"height": 297
|
190 |
+
},
|
191 |
+
"id": "u9e-C3xCUFoG",
|
192 |
+
"outputId": "d0f68684-bc60-41d5-8248-69714753da9e"
|
193 |
+
},
|
194 |
+
"outputs": [],
|
195 |
+
"source": [
|
196 |
+
"microsoft.describe()"
|
197 |
+
]
|
198 |
+
},
|
199 |
+
{
|
200 |
+
"cell_type": "markdown",
|
201 |
+
"metadata": {
|
202 |
+
"id": "AiEKBLpTIhDN"
|
203 |
+
},
|
204 |
+
"source": [
|
205 |
+
"Also same for the Microsoft dataset, there is a high difference between the minimum and maximum values. And 75% of the value is close to the mean."
|
206 |
+
]
|
207 |
+
},
|
208 |
+
{
|
209 |
+
"cell_type": "code",
|
210 |
+
"execution_count": null,
|
211 |
+
"metadata": {
|
212 |
+
"colab": {
|
213 |
+
"base_uri": "https://localhost:8080/"
|
214 |
+
},
|
215 |
+
"id": "B1XbVBsaUFqs",
|
216 |
+
"outputId": "f3c2d8fd-5e19-4903-e9b1-77f39eeb2a4b"
|
217 |
+
},
|
218 |
+
"outputs": [],
|
219 |
+
"source": [
|
220 |
+
"microsoft.info()"
|
221 |
+
]
|
222 |
+
},
|
223 |
+
{
|
224 |
+
"cell_type": "code",
|
225 |
+
"execution_count": null,
|
226 |
+
"metadata": {
|
227 |
+
"colab": {
|
228 |
+
"base_uri": "https://localhost:8080/"
|
229 |
+
},
|
230 |
+
"id": "ZGeHejlzUFtb",
|
231 |
+
"outputId": "46ad34ee-9e98-4f77-c604-7c3b02fffa1a"
|
232 |
+
},
|
233 |
+
"outputs": [],
|
234 |
+
"source": [
|
235 |
+
"microsoft.isna().sum()"
|
236 |
+
]
|
237 |
+
},
|
238 |
+
{
|
239 |
+
"cell_type": "code",
|
240 |
+
"execution_count": null,
|
241 |
+
"metadata": {
|
242 |
+
"colab": {
|
243 |
+
"base_uri": "https://localhost:8080/"
|
244 |
+
},
|
245 |
+
"id": "_lAPBgC3QTP0",
|
246 |
+
"outputId": "8b1cb52c-45c2-4f77-e9f1-9eafed9fdcf6"
|
247 |
+
},
|
248 |
+
"outputs": [],
|
249 |
+
"source": [
|
250 |
+
"amazon.info()"
|
251 |
+
]
|
252 |
+
},
|
253 |
+
{
|
254 |
+
"cell_type": "code",
|
255 |
+
"execution_count": null,
|
256 |
+
"metadata": {
|
257 |
+
"colab": {
|
258 |
+
"base_uri": "https://localhost:8080/",
|
259 |
+
"height": 297
|
260 |
+
},
|
261 |
+
"id": "e7ReAgz7QXC6",
|
262 |
+
"outputId": "a083e744-86b4-42b4-d57f-a5b092e5f052"
|
263 |
+
},
|
264 |
+
"outputs": [],
|
265 |
+
"source": [
|
266 |
+
"amazon.describe()"
|
267 |
+
]
|
268 |
+
},
|
269 |
+
{
|
270 |
+
"cell_type": "markdown",
|
271 |
+
"metadata": {
|
272 |
+
"id": "nphzU3gkI09M"
|
273 |
+
},
|
274 |
+
"source": [
|
275 |
+
"Also same for the Amazon dataset, there is a high difference between the minimum and maximum values. And 75% of the value is close to the mean."
|
276 |
+
]
|
277 |
+
},
|
278 |
+
{
|
279 |
+
"cell_type": "code",
|
280 |
+
"execution_count": null,
|
281 |
+
"metadata": {
|
282 |
+
"colab": {
|
283 |
+
"base_uri": "https://localhost:8080/"
|
284 |
+
},
|
285 |
+
"id": "kmBZCcnvQeOT",
|
286 |
+
"outputId": "58b0405f-4dfe-4ff2-a7f3-9138a85da3a4"
|
287 |
+
},
|
288 |
+
"outputs": [],
|
289 |
+
"source": [
|
290 |
+
"amazon.columns"
|
291 |
+
]
|
292 |
+
},
|
293 |
+
{
|
294 |
+
"cell_type": "code",
|
295 |
+
"execution_count": null,
|
296 |
+
"metadata": {
|
297 |
+
"colab": {
|
298 |
+
"base_uri": "https://localhost:8080/"
|
299 |
+
},
|
300 |
+
"id": "oxbvY--YQjbz",
|
301 |
+
"outputId": "084b0ef8-806c-4fd5-d3ec-fb27e4a7e008"
|
302 |
+
},
|
303 |
+
"outputs": [],
|
304 |
+
"source": [
|
305 |
+
"amazon.isna().sum()"
|
306 |
+
]
|
307 |
+
},
|
308 |
+
{
|
309 |
+
"cell_type": "code",
|
310 |
+
"execution_count": null,
|
311 |
+
"metadata": {
|
312 |
+
"colab": {
|
313 |
+
"base_uri": "https://localhost:8080/",
|
314 |
+
"height": 297
|
315 |
+
},
|
316 |
+
"id": "ubBizjDgQ9vT",
|
317 |
+
"outputId": "ec4b39cf-b198-47be-884a-e5a93c823c16"
|
318 |
+
},
|
319 |
+
"outputs": [],
|
320 |
+
"source": [
|
321 |
+
"ibm.describe()"
|
322 |
+
]
|
323 |
+
},
|
324 |
+
{
|
325 |
+
"cell_type": "markdown",
|
326 |
+
"metadata": {
|
327 |
+
"id": "idAqf3mEJHnN"
|
328 |
+
},
|
329 |
+
"source": [
|
330 |
+
"But for the IBM dataset, we can see all the value is nearly close to the mean."
|
331 |
+
]
|
332 |
+
},
|
333 |
+
{
|
334 |
+
"cell_type": "code",
|
335 |
+
"execution_count": null,
|
336 |
+
"metadata": {
|
337 |
+
"colab": {
|
338 |
+
"base_uri": "https://localhost:8080/"
|
339 |
+
},
|
340 |
+
"id": "JX0WUfEERBFr",
|
341 |
+
"outputId": "c989995c-3523-4276-d21e-342f129af016"
|
342 |
+
},
|
343 |
+
"outputs": [],
|
344 |
+
"source": [
|
345 |
+
"ibm.columns"
|
346 |
+
]
|
347 |
+
},
|
348 |
+
{
|
349 |
+
"cell_type": "code",
|
350 |
+
"execution_count": null,
|
351 |
+
"metadata": {
|
352 |
+
"colab": {
|
353 |
+
"base_uri": "https://localhost:8080/"
|
354 |
+
},
|
355 |
+
"id": "gF2Vp6xpRGgL",
|
356 |
+
"outputId": "2c184665-5108-465c-ed7e-f08e24e72a14"
|
357 |
+
},
|
358 |
+
"outputs": [],
|
359 |
+
"source": [
|
360 |
+
"ibm.isna().sum()"
|
361 |
+
]
|
362 |
+
},
|
363 |
+
{
|
364 |
+
"cell_type": "code",
|
365 |
+
"execution_count": 20,
|
366 |
+
"metadata": {
|
367 |
+
"id": "wcMiz2pDRUJT"
|
368 |
+
},
|
369 |
+
"outputs": [],
|
370 |
+
"source": [
|
371 |
+
"ibm.dropna(inplace=True)\n"
|
372 |
+
]
|
373 |
+
},
|
374 |
+
{
|
375 |
+
"cell_type": "code",
|
376 |
+
"execution_count": null,
|
377 |
+
"metadata": {
|
378 |
+
"colab": {
|
379 |
+
"base_uri": "https://localhost:8080/"
|
380 |
+
},
|
381 |
+
"id": "bJDp1qMTSMGU",
|
382 |
+
"outputId": "444b03d8-27cf-4989-f13d-6bd36d8659f2"
|
383 |
+
},
|
384 |
+
"outputs": [],
|
385 |
+
"source": [
|
386 |
+
"ibm.isna().sum()"
|
387 |
+
]
|
388 |
+
},
|
389 |
+
{
|
390 |
+
"cell_type": "code",
|
391 |
+
"execution_count": null,
|
392 |
+
"metadata": {
|
393 |
+
"colab": {
|
394 |
+
"base_uri": "https://localhost:8080/",
|
395 |
+
"height": 542
|
396 |
+
},
|
397 |
+
"id": "vdy-INO5tRTM",
|
398 |
+
"outputId": "aeb6a77f-9074-4828-ccdc-0d84c10b5a8f"
|
399 |
+
},
|
400 |
+
"outputs": [],
|
401 |
+
"source": [
|
402 |
+
"fig = px.histogram(google, \n",
|
403 |
+
" x='Close', \n",
|
404 |
+
" marginal='box', \n",
|
405 |
+
" nbins=47, \n",
|
406 |
+
" title='Distribution of Close')\n",
|
407 |
+
"fig.update_layout(bargap=0.1)\n",
|
408 |
+
"fig.show()"
|
409 |
+
]
|
410 |
+
},
|
411 |
+
{
|
412 |
+
"cell_type": "code",
|
413 |
+
"execution_count": null,
|
414 |
+
"metadata": {
|
415 |
+
"colab": {
|
416 |
+
"base_uri": "https://localhost:8080/",
|
417 |
+
"height": 542
|
418 |
+
},
|
419 |
+
"id": "5UVmGagftpjt",
|
420 |
+
"outputId": "fb0cf4cb-9260-4219-b74c-f3c33caf827d"
|
421 |
+
},
|
422 |
+
"outputs": [],
|
423 |
+
"source": [
|
424 |
+
"fig = px.histogram(google, \n",
|
425 |
+
" x='Open', \n",
|
426 |
+
" marginal='box', \n",
|
427 |
+
" color_discrete_sequence=['red'], \n",
|
428 |
+
" title='Distribution of open')\n",
|
429 |
+
"fig.update_layout(bargap=0.1)\n",
|
430 |
+
"fig.show()"
|
431 |
+
]
|
432 |
+
},
|
433 |
+
{
|
434 |
+
"cell_type": "code",
|
435 |
+
"execution_count": null,
|
436 |
+
"metadata": {
|
437 |
+
"colab": {
|
438 |
+
"base_uri": "https://localhost:8080/",
|
439 |
+
"height": 542
|
440 |
+
},
|
441 |
+
"id": "YysvtUmIuAqi",
|
442 |
+
"outputId": "7ef51f06-fde5-45bb-ee5c-c782fbae23b1"
|
443 |
+
},
|
444 |
+
"outputs": [],
|
445 |
+
"source": [
|
446 |
+
"fig = px.scatter(google, \n",
|
447 |
+
" x='Open', \n",
|
448 |
+
" y='Close', \n",
|
449 |
+
" opacity=0.8,\n",
|
450 |
+
" title='Open vs. Close')\n",
|
451 |
+
"fig.update_traces(marker_size=5)\n",
|
452 |
+
"fig.show()"
|
453 |
+
]
|
454 |
+
},
|
455 |
+
{
|
456 |
+
"cell_type": "markdown",
|
457 |
+
"metadata": {
|
458 |
+
"id": "kNq5XracJazF"
|
459 |
+
},
|
460 |
+
"source": [
|
461 |
+
"There is a very high correlation between \"Open\" and \"Close\". As we can see from the scatter plot."
|
462 |
+
]
|
463 |
+
},
|
464 |
+
{
|
465 |
+
"cell_type": "code",
|
466 |
+
"execution_count": null,
|
467 |
+
"metadata": {
|
468 |
+
"colab": {
|
469 |
+
"base_uri": "https://localhost:8080/",
|
470 |
+
"height": 204
|
471 |
+
},
|
472 |
+
"id": "pM8o7QEdulPc",
|
473 |
+
"outputId": "235f2ad4-7493-4bbc-b97b-534eb238165b"
|
474 |
+
},
|
475 |
+
"outputs": [],
|
476 |
+
"source": [
|
477 |
+
"google.corr(numeric_only=True)"
|
478 |
+
]
|
479 |
+
},
|
480 |
+
{
|
481 |
+
"cell_type": "code",
|
482 |
+
"execution_count": null,
|
483 |
+
"metadata": {
|
484 |
+
"colab": {
|
485 |
+
"base_uri": "https://localhost:8080/",
|
486 |
+
"height": 661
|
487 |
+
},
|
488 |
+
"id": "AiT3r-2kSRGj",
|
489 |
+
"outputId": "cca7e3cd-6baf-4031-8fed-137248ec8909"
|
490 |
+
},
|
491 |
+
"outputs": [],
|
492 |
+
"source": [
|
493 |
+
"google['2008':'2018'].plot(subplots=True, figsize=(10,12))\n",
|
494 |
+
"plt.title('Google stock attributes from 2008 to 2018')\n",
|
495 |
+
"plt.show()"
|
496 |
+
]
|
497 |
+
},
|
498 |
+
{
|
499 |
+
"cell_type": "code",
|
500 |
+
"execution_count": null,
|
501 |
+
"metadata": {
|
502 |
+
"colab": {
|
503 |
+
"base_uri": "https://localhost:8080/",
|
504 |
+
"height": 661
|
505 |
+
},
|
506 |
+
"id": "-8QaSCwIUaCd",
|
507 |
+
"outputId": "0dbeb672-dbff-40ea-f0fd-49dfd90b17ef"
|
508 |
+
},
|
509 |
+
"outputs": [],
|
510 |
+
"source": [
|
511 |
+
"microsoft['2008':'2018'].plot(subplots=True, figsize=(10,12))\n",
|
512 |
+
"plt.title('Microsoft stock attributes from 2008 to 2018')\n",
|
513 |
+
"plt.show()"
|
514 |
+
]
|
515 |
+
},
|
516 |
+
{
|
517 |
+
"cell_type": "code",
|
518 |
+
"execution_count": null,
|
519 |
+
"metadata": {
|
520 |
+
"colab": {
|
521 |
+
"base_uri": "https://localhost:8080/",
|
522 |
+
"height": 661
|
523 |
+
},
|
524 |
+
"id": "caMqi4-hSw-0",
|
525 |
+
"outputId": "3de05802-e399-4148-b254-fe230ed98e7a"
|
526 |
+
},
|
527 |
+
"outputs": [],
|
528 |
+
"source": [
|
529 |
+
"amazon['2008':'2018'].plot(subplots=True, figsize=(10,12))\n",
|
530 |
+
"plt.title('Amazon stock attributes from 2008 to 2018')\n",
|
531 |
+
"plt.show()"
|
532 |
+
]
|
533 |
+
},
|
534 |
+
{
|
535 |
+
"cell_type": "code",
|
536 |
+
"execution_count": null,
|
537 |
+
"metadata": {
|
538 |
+
"colab": {
|
539 |
+
"base_uri": "https://localhost:8080/",
|
540 |
+
"height": 661
|
541 |
+
},
|
542 |
+
"id": "jc-ay-okS5Ek",
|
543 |
+
"outputId": "aa61d916-3d67-4e56-a324-7f99bb23042d"
|
544 |
+
},
|
545 |
+
"outputs": [],
|
546 |
+
"source": [
|
547 |
+
"ibm['2008':'2018'].plot(subplots=True, figsize=(10,12))\n",
|
548 |
+
"plt.title('IBM stock attributes from 2008 to 2018')\n",
|
549 |
+
"plt.show()"
|
550 |
+
]
|
551 |
+
},
|
552 |
+
{
|
553 |
+
"cell_type": "markdown",
|
554 |
+
"metadata": {
|
555 |
+
"id": "oEyemEBUJ7Hd"
|
556 |
+
},
|
557 |
+
"source": [
|
558 |
+
"### High plot"
|
559 |
+
]
|
560 |
+
},
|
561 |
+
{
|
562 |
+
"cell_type": "code",
|
563 |
+
"execution_count": null,
|
564 |
+
"metadata": {
|
565 |
+
"colab": {
|
566 |
+
"base_uri": "https://localhost:8080/",
|
567 |
+
"height": 514
|
568 |
+
},
|
569 |
+
"id": "n91_-c-vTGYr",
|
570 |
+
"outputId": "89755429-2cfa-4548-8199-509c800faa7d"
|
571 |
+
},
|
572 |
+
"outputs": [],
|
573 |
+
"source": [
|
574 |
+
"# Plotting before normalization\n",
|
575 |
+
"google.High.plot()\n",
|
576 |
+
"microsoft.High.plot()\n",
|
577 |
+
"amazon.High.plot()\n",
|
578 |
+
"ibm.High.plot()\n",
|
579 |
+
"plt.legend(['Google','Microsoft','Amazon','IBM'])\n",
|
580 |
+
"plt.show()"
|
581 |
+
]
|
582 |
+
},
|
583 |
+
{
|
584 |
+
"cell_type": "markdown",
|
585 |
+
"metadata": {
|
586 |
+
"id": "uNEvX-eNKG_u"
|
587 |
+
},
|
588 |
+
"source": [
|
589 |
+
"As we can see here Microsoft's \"High\" value is very slowly increasing straight line. IBM's \"High\" value and Amazon's \"High\" value started from the approx same stage, even Amazon's \"High\" value was a bit lower but after 2012 Amazon's \"High\" value started to exponentially increase and slight drop for IBM's \"High\" value. Since 2016 there is a high fight going between Google's \"High\" value and Amazon's \"High\" value at 2018 Amazon's \"High\" value also beat Google's \"High\" value."
|
590 |
+
]
|
591 |
+
},
|
592 |
+
{
|
593 |
+
"cell_type": "code",
|
594 |
+
"execution_count": 31,
|
595 |
+
"metadata": {
|
596 |
+
"colab": {
|
597 |
+
"base_uri": "https://localhost:8080/",
|
598 |
+
"height": 69
|
599 |
+
},
|
600 |
+
"id": "At_n7sgAVHOQ",
|
601 |
+
"outputId": "8df3470a-c038-4cfe-ba37-d9a1043d2a30"
|
602 |
+
},
|
603 |
+
"outputs": [],
|
604 |
+
"source": [
|
605 |
+
"# Normalizing and comparison\n",
|
606 |
+
"# Both stocks start from 100\n",
|
607 |
+
"# normalized_google = google.High.div(google.High.iloc[0]).mul(100)\n",
|
608 |
+
"# normalized_microsoft = microsoft.High.div(microsoft.High.iloc[0]).mul(100)\n",
|
609 |
+
"# normalized_amazon = amazon.High.div(google.High.iloc[0]).mul(100)\n",
|
610 |
+
"# normalized_ibm = ibm.High.div(microsoft.High.iloc[0]).mul(100)\n",
|
611 |
+
"# normalized_google.plot()\n",
|
612 |
+
"# normalized_microsoft.plot()\n",
|
613 |
+
"# normalized_amazon.plot()\n",
|
614 |
+
"# normalized_ibm.plot()\n",
|
615 |
+
"# plt.legend(['Google','Microsoft','Amazon','IBM'])\n",
|
616 |
+
"# plt.show()"
|
617 |
+
]
|
618 |
+
},
|
619 |
+
{
|
620 |
+
"cell_type": "code",
|
621 |
+
"execution_count": null,
|
622 |
+
"metadata": {
|
623 |
+
"colab": {
|
624 |
+
"base_uri": "https://localhost:8080/",
|
625 |
+
"height": 530
|
626 |
+
},
|
627 |
+
"id": "p5Mb1sq8WU84",
|
628 |
+
"outputId": "b16ec5b1-e160-45cf-e541-d279f62c347b"
|
629 |
+
},
|
630 |
+
"outputs": [],
|
631 |
+
"source": [
|
632 |
+
"# Expanding window functions\n",
|
633 |
+
"microsoft_mean = microsoft.High.expanding().mean()\n",
|
634 |
+
"microsoft_std = microsoft.High.expanding().std()\n",
|
635 |
+
"microsoft.High.plot()\n",
|
636 |
+
"microsoft_mean.plot()\n",
|
637 |
+
"microsoft_std.plot()\n",
|
638 |
+
"plt.legend(['High','Expanding Mean','Expanding Standard Deviation'])\n",
|
639 |
+
"plt.title('Microsoft')\n",
|
640 |
+
"plt.show()"
|
641 |
+
]
|
642 |
+
},
|
643 |
+
{
|
644 |
+
"cell_type": "markdown",
|
645 |
+
"metadata": {
|
646 |
+
"id": "F_uazrtGMsMQ"
|
647 |
+
},
|
648 |
+
"source": [
|
649 |
+
"In Microsoft data, we can see in 2009 \"High\" value was under mean for a long time, so we can say there was some loss."
|
650 |
+
]
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"cell_type": "code",
|
654 |
+
"execution_count": null,
|
655 |
+
"metadata": {
|
656 |
+
"colab": {
|
657 |
+
"base_uri": "https://localhost:8080/",
|
658 |
+
"height": 530
|
659 |
+
},
|
660 |
+
"id": "HYJVphVxWYeV",
|
661 |
+
"outputId": "3584d0c6-b486-4f75-b9fa-3c9372f6813b"
|
662 |
+
},
|
663 |
+
"outputs": [],
|
664 |
+
"source": [
|
665 |
+
"# Expanding window functions\n",
|
666 |
+
"google_mean = google.High.expanding().mean()\n",
|
667 |
+
"google_std = google.High.expanding().std()\n",
|
668 |
+
"google.High.plot()\n",
|
669 |
+
"google_mean.plot()\n",
|
670 |
+
"google_std.plot()\n",
|
671 |
+
"plt.legend(['High','Expanding Mean','Expanding Standard Deviation'])\n",
|
672 |
+
"plt.title('Google')\n",
|
673 |
+
"plt.show()"
|
674 |
+
]
|
675 |
+
},
|
676 |
+
{
|
677 |
+
"cell_type": "markdown",
|
678 |
+
"metadata": {
|
679 |
+
"id": "XqflMuOONQbe"
|
680 |
+
},
|
681 |
+
"source": [
|
682 |
+
"Same for Google data, we can see in 2009 \"High\" value was under mean for a long time, so we can say there was some loss. But it was not an as huge loss as Amazon."
|
683 |
+
]
|
684 |
+
},
|
685 |
+
{
|
686 |
+
"cell_type": "code",
|
687 |
+
"execution_count": null,
|
688 |
+
"metadata": {
|
689 |
+
"colab": {
|
690 |
+
"base_uri": "https://localhost:8080/",
|
691 |
+
"height": 530
|
692 |
+
},
|
693 |
+
"id": "hdwNPs0qW9nn",
|
694 |
+
"outputId": "8e9d23af-827f-4513-95b5-c186b44a0221"
|
695 |
+
},
|
696 |
+
"outputs": [],
|
697 |
+
"source": [
|
698 |
+
"# Expanding window functions\n",
|
699 |
+
"ibm_mean = ibm.High.expanding().mean()\n",
|
700 |
+
"ibm_std = ibm.High.expanding().std()\n",
|
701 |
+
"ibm.High.plot()\n",
|
702 |
+
"ibm_mean.plot()\n",
|
703 |
+
"ibm_std.plot()\n",
|
704 |
+
"plt.legend(['High','Expanding Mean','Expanding Standard Deviation'])\n",
|
705 |
+
"plt.title('IBM')\n",
|
706 |
+
"plt.show()"
|
707 |
+
]
|
708 |
+
},
|
709 |
+
{
|
710 |
+
"cell_type": "markdown",
|
711 |
+
"metadata": {
|
712 |
+
"id": "wxBYR8shNm3n"
|
713 |
+
},
|
714 |
+
"source": [
|
715 |
+
"Same for IBM data, we can see in 2009 \"High\" value was under mean for a long time, so we can say there was some loss. And after 2013 again a drop then in 2016 there was a huge loss but after that, they were doing well. After just some profit again in between 2017, there was another drop."
|
716 |
+
]
|
717 |
+
},
|
718 |
+
{
|
719 |
+
"cell_type": "code",
|
720 |
+
"execution_count": null,
|
721 |
+
"metadata": {
|
722 |
+
"colab": {
|
723 |
+
"base_uri": "https://localhost:8080/",
|
724 |
+
"height": 530
|
725 |
+
},
|
726 |
+
"id": "1N2XLLVfXaN4",
|
727 |
+
"outputId": "08fef5e2-78fb-44bf-c301-f3e17f7dce97"
|
728 |
+
},
|
729 |
+
"outputs": [],
|
730 |
+
"source": [
|
731 |
+
"# Expanding window functions\n",
|
732 |
+
"amazon_mean = amazon.High.expanding().mean()\n",
|
733 |
+
"amazon_std = amazon.High.expanding().std()\n",
|
734 |
+
"amazon.High.plot()\n",
|
735 |
+
"amazon_mean.plot()\n",
|
736 |
+
"amazon_std.plot()\n",
|
737 |
+
"plt.legend(['High','Expanding Mean','Expanding Standard Deviation'])\n",
|
738 |
+
"plt.title('Amazon')\n",
|
739 |
+
"plt.show()"
|
740 |
+
]
|
741 |
+
},
|
742 |
+
{
|
743 |
+
"cell_type": "markdown",
|
744 |
+
"metadata": {
|
745 |
+
"id": "BKFOLIFQNku_"
|
746 |
+
},
|
747 |
+
"source": [
|
748 |
+
"For Amazon's \"High\" value the case is different they also face loss in 2009 but for a very little margin. And after that their growth is in exponential order."
|
749 |
+
]
|
750 |
+
},
|
751 |
+
{
|
752 |
+
"cell_type": "markdown",
|
753 |
+
"metadata": {
|
754 |
+
"id": "6-_5BaUEPN7u"
|
755 |
+
},
|
756 |
+
"source": [
|
757 |
+
"## Here we can see every company faced a loss in 2009, maybe that's because of the economic slowdown."
|
758 |
+
]
|
759 |
+
},
|
760 |
+
{
|
761 |
+
"cell_type": "markdown",
|
762 |
+
"metadata": {
|
763 |
+
"id": "kF6fwLdhPE3-"
|
764 |
+
},
|
765 |
+
"source": [
|
766 |
+
"### Close"
|
767 |
+
]
|
768 |
+
},
|
769 |
+
{
|
770 |
+
"cell_type": "code",
|
771 |
+
"execution_count": null,
|
772 |
+
"metadata": {
|
773 |
+
"colab": {
|
774 |
+
"base_uri": "https://localhost:8080/",
|
775 |
+
"height": 530
|
776 |
+
},
|
777 |
+
"id": "EUTiQTKXXtPH",
|
778 |
+
"outputId": "faa3a26a-0c01-4f83-9c89-77bbeb7b3b77"
|
779 |
+
},
|
780 |
+
"outputs": [],
|
781 |
+
"source": [
|
782 |
+
"# Expanding window functions\n",
|
783 |
+
"google_mean = google.Close.expanding().mean()\n",
|
784 |
+
"google_std = google.Close.expanding().std()\n",
|
785 |
+
"google.High.plot()\n",
|
786 |
+
"google_mean.plot()\n",
|
787 |
+
"google_std.plot()\n",
|
788 |
+
"plt.legend(['Close','Expanding Mean','Expanding Standard Deviation'])\n",
|
789 |
+
"plt.title('Google')\n",
|
790 |
+
"plt.show()"
|
791 |
+
]
|
792 |
+
},
|
793 |
+
{
|
794 |
+
"cell_type": "code",
|
795 |
+
"execution_count": 37,
|
796 |
+
"metadata": {
|
797 |
+
"id": "iyr745YnYdOG"
|
798 |
+
},
|
799 |
+
"outputs": [],
|
800 |
+
"source": [
|
801 |
+
"from pylab import rcParams\n",
|
802 |
+
"import statsmodels.api as sm"
|
803 |
+
]
|
804 |
+
},
|
805 |
+
{
|
806 |
+
"cell_type": "markdown",
|
807 |
+
"metadata": {
|
808 |
+
"id": "NStUk9DAPuCO"
|
809 |
+
},
|
810 |
+
"source": [
|
811 |
+
"## Trend and Seasonality"
|
812 |
+
]
|
813 |
+
},
|
814 |
+
{
|
815 |
+
"cell_type": "markdown",
|
816 |
+
"metadata": {
|
817 |
+
"id": "xyc1m22DP9vf"
|
818 |
+
},
|
819 |
+
"source": [
|
820 |
+
"Google data"
|
821 |
+
]
|
822 |
+
},
|
823 |
+
{
|
824 |
+
"cell_type": "code",
|
825 |
+
"execution_count": null,
|
826 |
+
"metadata": {
|
827 |
+
"colab": {
|
828 |
+
"base_uri": "https://localhost:8080/",
|
829 |
+
"height": 657
|
830 |
+
},
|
831 |
+
"id": "nCEPW4zHYMVO",
|
832 |
+
"outputId": "9d1e681b-f6af-46ae-d2c4-8440e1eec48f"
|
833 |
+
},
|
834 |
+
"outputs": [],
|
835 |
+
"source": [
|
836 |
+
"# Now, for decomposition...\n",
|
837 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
838 |
+
"decomposed_google_volume = sm.tsa.seasonal_decompose(google[\"High\"],period=360) # The frequncy is annual\n",
|
839 |
+
"figure = decomposed_google_volume.plot()\n",
|
840 |
+
"plt.show()"
|
841 |
+
]
|
842 |
+
},
|
843 |
+
{
|
844 |
+
"cell_type": "markdown",
|
845 |
+
"metadata": {
|
846 |
+
"id": "-BKKfxqAQBu3"
|
847 |
+
},
|
848 |
+
"source": [
|
849 |
+
"There is a very slow increasing trend until 2012, but after 2012 there was an exponential high trend. And very high seasonality."
|
850 |
+
]
|
851 |
+
},
|
852 |
+
{
|
853 |
+
"cell_type": "markdown",
|
854 |
+
"metadata": {
|
855 |
+
"id": "bb1MA8O7QmFs"
|
856 |
+
},
|
857 |
+
"source": [
|
858 |
+
"Microsoft data"
|
859 |
+
]
|
860 |
+
},
|
861 |
+
{
|
862 |
+
"cell_type": "code",
|
863 |
+
"execution_count": null,
|
864 |
+
"metadata": {
|
865 |
+
"colab": {
|
866 |
+
"base_uri": "https://localhost:8080/",
|
867 |
+
"height": 657
|
868 |
+
},
|
869 |
+
"id": "JZR6or5ZYi8m",
|
870 |
+
"outputId": "271ee237-4836-43a2-a94c-b11f6f0ed652"
|
871 |
+
},
|
872 |
+
"outputs": [],
|
873 |
+
"source": [
|
874 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
875 |
+
"decomposed_microsoft_volume = sm.tsa.seasonal_decompose(microsoft[\"High\"],period=360) # The frequncy is annual\n",
|
876 |
+
"figure = decomposed_microsoft_volume.plot()\n",
|
877 |
+
"plt.show()"
|
878 |
+
]
|
879 |
+
},
|
880 |
+
{
|
881 |
+
"cell_type": "markdown",
|
882 |
+
"metadata": {
|
883 |
+
"id": "C4iQFevgQ3Px"
|
884 |
+
},
|
885 |
+
"source": [
|
886 |
+
"Same for Microsoft data, there is a very slow increasing trend until 2012, but after 2012 there was an exponential high trend. And very high seasonality."
|
887 |
+
]
|
888 |
+
},
|
889 |
+
{
|
890 |
+
"cell_type": "markdown",
|
891 |
+
"metadata": {
|
892 |
+
"id": "std7HguHQ7jw"
|
893 |
+
},
|
894 |
+
"source": [
|
895 |
+
"IBM data"
|
896 |
+
]
|
897 |
+
},
|
898 |
+
{
|
899 |
+
"cell_type": "code",
|
900 |
+
"execution_count": null,
|
901 |
+
"metadata": {
|
902 |
+
"colab": {
|
903 |
+
"base_uri": "https://localhost:8080/",
|
904 |
+
"height": 657
|
905 |
+
},
|
906 |
+
"id": "jfuFqS80Yxlu",
|
907 |
+
"outputId": "ba038348-c4b5-43d1-b03f-334c0d21bb89"
|
908 |
+
},
|
909 |
+
"outputs": [],
|
910 |
+
"source": [
|
911 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
912 |
+
"decomposed_ibm_volume = sm.tsa.seasonal_decompose(ibm[\"High\"],period=360) # The frequncy is annual\n",
|
913 |
+
"figure = decomposed_ibm_volume.plot()\n",
|
914 |
+
"plt.show()"
|
915 |
+
]
|
916 |
+
},
|
917 |
+
{
|
918 |
+
"cell_type": "markdown",
|
919 |
+
"metadata": {
|
920 |
+
"id": "9ZVHA6zuRE-L"
|
921 |
+
},
|
922 |
+
"source": [
|
923 |
+
"IBM data has a very slow increasing trend until 2008, but after 2009 there was an exponential high trend until 2013, then a high drop until 2016 then a very slow increasing trend. And very high seasonality."
|
924 |
+
]
|
925 |
+
},
|
926 |
+
{
|
927 |
+
"cell_type": "markdown",
|
928 |
+
"metadata": {
|
929 |
+
"id": "95ZBbTHoRzNS"
|
930 |
+
},
|
931 |
+
"source": [
|
932 |
+
"Amazon data"
|
933 |
+
]
|
934 |
+
},
|
935 |
+
{
|
936 |
+
"cell_type": "code",
|
937 |
+
"execution_count": null,
|
938 |
+
"metadata": {
|
939 |
+
"colab": {
|
940 |
+
"base_uri": "https://localhost:8080/",
|
941 |
+
"height": 659
|
942 |
+
},
|
943 |
+
"id": "2578pdviY_Wo",
|
944 |
+
"outputId": "07ebbf3f-2944-4bc5-fac6-cbe522b25a6d"
|
945 |
+
},
|
946 |
+
"outputs": [],
|
947 |
+
"source": [
|
948 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
949 |
+
"decomposed_amazon_volume = sm.tsa.seasonal_decompose(amazon[\"High\"],period=360) # The frequncy is annual\n",
|
950 |
+
"figure = decomposed_amazon_volume.plot()\n",
|
951 |
+
"plt.show()"
|
952 |
+
]
|
953 |
+
},
|
954 |
+
{
|
955 |
+
"cell_type": "markdown",
|
956 |
+
"metadata": {
|
957 |
+
"id": "uo4KfDAkSQF3"
|
958 |
+
},
|
959 |
+
"source": [
|
960 |
+
"Amazon data is similar to Google data."
|
961 |
+
]
|
962 |
+
},
|
963 |
+
{
|
964 |
+
"cell_type": "markdown",
|
965 |
+
"metadata": {
|
966 |
+
"id": "3i01zQQHSf-x"
|
967 |
+
},
|
968 |
+
"source": [
|
969 |
+
"### Close"
|
970 |
+
]
|
971 |
+
},
|
972 |
+
{
|
973 |
+
"cell_type": "code",
|
974 |
+
"execution_count": null,
|
975 |
+
"metadata": {
|
976 |
+
"colab": {
|
977 |
+
"base_uri": "https://localhost:8080/",
|
978 |
+
"height": 657
|
979 |
+
},
|
980 |
+
"id": "Oqx57vd1ZQVW",
|
981 |
+
"outputId": "55e0bb86-f451-461b-c231-b917547cb06a"
|
982 |
+
},
|
983 |
+
"outputs": [],
|
984 |
+
"source": [
|
985 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
986 |
+
"decomposed_google_volume = sm.tsa.seasonal_decompose(google[\"Close\"],period=360) # The frequncy is annual\n",
|
987 |
+
"figure = decomposed_google_volume.plot()\n",
|
988 |
+
"plt.show()"
|
989 |
+
]
|
990 |
+
},
|
991 |
+
{
|
992 |
+
"cell_type": "code",
|
993 |
+
"execution_count": null,
|
994 |
+
"metadata": {
|
995 |
+
"colab": {
|
996 |
+
"base_uri": "https://localhost:8080/",
|
997 |
+
"height": 657
|
998 |
+
},
|
999 |
+
"id": "cMSuInsuZWRn",
|
1000 |
+
"outputId": "ac1532ea-0c48-4808-c82c-c6fa1c5ff349"
|
1001 |
+
},
|
1002 |
+
"outputs": [],
|
1003 |
+
"source": [
|
1004 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
1005 |
+
"decomposed_microsoft_volume = sm.tsa.seasonal_decompose(microsoft[\"Close\"],period=360) # The frequncy is annual\n",
|
1006 |
+
"figure = decomposed_microsoft_volume.plot()\n",
|
1007 |
+
"plt.show()"
|
1008 |
+
]
|
1009 |
+
},
|
1010 |
+
{
|
1011 |
+
"cell_type": "code",
|
1012 |
+
"execution_count": null,
|
1013 |
+
"metadata": {
|
1014 |
+
"colab": {
|
1015 |
+
"base_uri": "https://localhost:8080/",
|
1016 |
+
"height": 661
|
1017 |
+
},
|
1018 |
+
"id": "Yc19oD9ZZi-B",
|
1019 |
+
"outputId": "8aa64728-5317-475c-d56a-4224c16c0b09"
|
1020 |
+
},
|
1021 |
+
"outputs": [],
|
1022 |
+
"source": [
|
1023 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
1024 |
+
"decomposed_amazon_volume = sm.tsa.seasonal_decompose(amazon[\"Close\"],period=360) # The frequncy is annual\n",
|
1025 |
+
"figure = decomposed_amazon_volume.plot()\n",
|
1026 |
+
"plt.show()"
|
1027 |
+
]
|
1028 |
+
},
|
1029 |
+
{
|
1030 |
+
"cell_type": "code",
|
1031 |
+
"execution_count": null,
|
1032 |
+
"metadata": {
|
1033 |
+
"colab": {
|
1034 |
+
"base_uri": "https://localhost:8080/",
|
1035 |
+
"height": 657
|
1036 |
+
},
|
1037 |
+
"id": "HnfVt4A3Zvp_",
|
1038 |
+
"outputId": "8ede7386-e1a6-4740-ae69-efd6f9661890"
|
1039 |
+
},
|
1040 |
+
"outputs": [],
|
1041 |
+
"source": [
|
1042 |
+
"rcParams['figure.figsize'] = 11, 9\n",
|
1043 |
+
"decomposed_ibm_volume = sm.tsa.seasonal_decompose(ibm[\"Close\"],period=360) # The frequncy is annual\n",
|
1044 |
+
"figure = decomposed_ibm_volume.plot()\n",
|
1045 |
+
"plt.show()"
|
1046 |
+
]
|
1047 |
+
},
|
1048 |
+
{
|
1049 |
+
"cell_type": "markdown",
|
1050 |
+
"metadata": {
|
1051 |
+
"id": "HpnfOK0GSo9z"
|
1052 |
+
},
|
1053 |
+
"source": [
|
1054 |
+
"Because there have a very strong correlation between Close and High, we can see the trend and seasonality is very similar."
|
1055 |
+
]
|
1056 |
+
}
|
1057 |
+
],
|
1058 |
+
"metadata": {
|
1059 |
+
"colab": {
|
1060 |
+
"collapsed_sections": [],
|
1061 |
+
"name": "Stock_market.ipynb",
|
1062 |
+
"provenance": []
|
1063 |
+
},
|
1064 |
+
"kernelspec": {
|
1065 |
+
"display_name": "Python 3",
|
1066 |
+
"name": "python3"
|
1067 |
+
},
|
1068 |
+
"language_info": {
|
1069 |
+
"codemirror_mode": {
|
1070 |
+
"name": "ipython",
|
1071 |
+
"version": 3
|
1072 |
+
},
|
1073 |
+
"file_extension": ".py",
|
1074 |
+
"mimetype": "text/x-python",
|
1075 |
+
"name": "python",
|
1076 |
+
"nbconvert_exporter": "python",
|
1077 |
+
"pygments_lexer": "ipython3",
|
1078 |
+
"version": "3.12.3"
|
1079 |
+
}
|
1080 |
+
},
|
1081 |
+
"nbformat": 4,
|
1082 |
+
"nbformat_minor": 0
|
1083 |
+
}
|
notebooks/stock_market_prediction.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
notebooks/weather_classification.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
packages.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fluidsynth
|
requirements.txt
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
numpy
|
3 |
+
pandas
|
4 |
+
scikit-learn
|
5 |
+
keras
|
6 |
+
plotly
|
7 |
+
music21
|
8 |
+
mido
|
9 |
+
pretty-midi
|
10 |
+
pyfluidsynth
|
11 |
+
scipy
|
12 |
+
soundfile
|
13 |
+
tensorflow
|
14 |
+
# llama-cpp-python
|