diff --git a/Mideval code/kuldeep_mideval_code/mideval_ps_kuldeep (2).ipynb b/Mideval code/kuldeep_mideval_code/mideval_ps_kuldeep (2).ipynb new file mode 100644 index 0000000..06925a0 --- /dev/null +++ b/Mideval code/kuldeep_mideval_code/mideval_ps_kuldeep (2).ipynb @@ -0,0 +1,711 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 226 + }, + "id": "zeoKusfsajl-", + "outputId": "20c5383e-ac56-47ad-b6db-2a4ae096e6b7" + }, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " lookback_days high_volatility trend_continuation technical_score \\\n", + "0 48 0 1 59.99 \n", + "1 38 1 1 78.54 \n", + "2 24 1 0 56.03 \n", + "3 52 0 0 66.51 \n", + "4 17 1 1 61.21 \n", + "\n", + " edge_density slope_strength candlestick_variance pattern_symmetry \\\n", + "0 0.504 0.298 1.572 0.768 \n", + "1 0.559 0.037 0.692 0.538 \n", + "2 0.617 0.212 1.419 0.301 \n", + "3 0.360 0.347 0.699 0.498 \n", + "4 0.492 0.144 2.520 0.828 \n", + "\n", + " future_trend asset_type_equity asset_type_index market_regime_bullish \\\n", + "0 1 1 0 1 \n", + "1 1 0 1 1 \n", + "2 1 1 0 1 \n", + "3 1 1 0 1 \n", + "4 1 1 0 1 \n", + "\n", + " market_regime_sideways \n", + "0 0 \n", + "1 0 \n", + "2 0 \n", + "3 0 \n", + "4 0 " + ], + "text/html": [ + "\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
lookback_dayshigh_volatilitytrend_continuationtechnical_scoreedge_densityslope_strengthcandlestick_variancepattern_symmetryfuture_trendasset_type_equityasset_type_indexmarket_regime_bullishmarket_regime_sideways
0480159.990.5040.2981.5720.76811010
1381178.540.5590.0370.6920.53810110
2241056.030.6170.2121.4190.30111010
3520066.510.3600.3470.6990.49811010
4171161.210.4920.1442.5200.82811010
\n", + "
\n", + "
\n", + "\n", + "
\n", + " \n", + "\n", + " \n", + "\n", + " \n", + "
\n", + "\n", + "\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + " \n", + "
\n", + "\n", + "
\n", + "
\n" + ], + "application/vnd.google.colaboratory.intrinsic+json": { + "type": "dataframe", + "variable_name": "df", + "summary": "{\n \"name\": \"df\",\n \"rows\": 200,\n \"fields\": [\n {\n \"column\": \"lookback_days\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 14,\n \"min\": 10,\n \"max\": 60,\n \"num_unique_values\": 50,\n \"samples\": [\n 31,\n 15,\n 18\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"high_volatility\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 1,\n 0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"trend_continuation\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"technical_score\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 15.028468080337015,\n \"min\": 24.2,\n \"max\": 100.0,\n \"num_unique_values\": 195,\n \"samples\": [\n 71.25,\n 69.01\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"edge_density\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.11605043079384576,\n \"min\": 0.191,\n \"max\": 0.798,\n \"num_unique_values\": 159,\n \"samples\": [\n 0.384,\n 0.695\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"slope_strength\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.6199660874985351,\n \"min\": -1.217,\n \"max\": 1.833,\n \"num_unique_values\": 189,\n \"samples\": [\n -0.285,\n 0.217\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"candlestick_variance\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.5755348790123836,\n \"min\": 0.028,\n \"max\": 2.52,\n \"num_unique_values\": 195,\n \"samples\": [\n 2.085,\n 0.634\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"pattern_symmetry\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0.17357671352283097,\n \"min\": 0.21,\n \"max\": 1.0,\n \"num_unique_values\": 172,\n \"samples\": [\n 0.919,\n 0.318\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"future_trend\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"asset_type_equity\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"asset_type_index\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 1,\n 0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"market_regime_bullish\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 0,\n 1\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n },\n {\n \"column\": \"market_regime_sideways\",\n \"properties\": {\n \"dtype\": \"number\",\n \"std\": 0,\n \"min\": 0,\n \"max\": 1,\n \"num_unique_values\": 2,\n \"samples\": [\n 1,\n 0\n ],\n \"semantic_type\": \"\",\n \"description\": \"\"\n }\n }\n ]\n}" + } + }, + "metadata": {}, + "execution_count": 2 + } + ], + "source": [ + "import pandas as pd\n", + "import numpy as np\n", + "old_df = pd.read_csv('quantvision_financial_dataset_200.csv')\n", + "\n", + "df = pd.get_dummies(old_df, columns=['asset_type' , 'market_regime'] , drop_first=True )\n", + "bool_columns = df.select_dtypes(include=[bool]).columns\n", + "df[bool_columns] = df[bool_columns].astype(int)\n", + "df.head()\n" + ] + }, + { + "cell_type": "code", + "source": [ + "x = df.drop('future_trend' , axis = 1)\n", + "y = df['future_trend']\n", + "\n", + "\n", + "\n" + ], + "metadata": { + "id": "acDFzMvqavA5" + }, + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "from sklearn.model_selection import train_test_split\n", + "\n", + "x_train , x_test , y_train , y_test = train_test_split(\n", + " x , y , test_size = 0.2 , random_state = 40 , stratify = y\n", + " )\n", + "\n", + "\n", + "\n", + "from sklearn.preprocessing import StandardScaler\n", + "scaler = StandardScaler()\n", + "x_train = scaler.fit_transform(x_train)\n", + "\n", + "x_test = scaler.transform(x_test)\n", + "" + ], + "metadata": { + "id": "-xetJO5LmyuV" + }, + "execution_count": 4, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "from sklearn.linear_model import LogisticRegression\n", + "\n", + "from imblearn.over_sampling import SMOTE\n", + "smote = SMOTE(random_state=42)\n", + "x_train_smote , y_train_smote = smote.fit_resample(x_train, y_train)\n", + "\n", + "\n", + "\n", + "LR = LogisticRegression(penalty = 'l2' , C = 1.6 , solver='liblinear' , random_state= 42\n", + ")\n", + "LR.fit(x_train_smote , y_train_smote)\n", + "\n", + "y_test_pred = LR.predict(x_test)\n", + "from sklearn.metrics import accuracy_score\n", + "score = accuracy_score(y_valid , y_test_pred)\n", + "print(score)\n", + "\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "rfCb6q-Opy9Q", + "outputId": "4f4885fd-e4be-462b-e91b-97e49b801a4c" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "0.9\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "from tensorflow.keras.models import Sequential\n", + "from tensorflow.keras.layers import Dense, Dropout\n", + "from tensorflow.keras.optimizers import Adam\n", + "from sklearn.preprocessing import StandardScaler\n", + "from sklearn.metrics import classification_report, confusion_matrix\n" + ], + "metadata": { + "id": "5KX7QyExq2Bi" + }, + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "model = Sequential()\n", + "\n", + "model.add(Dense(64, activation='relu', input_shape=(x_train.shape[1],)))\n", + "model.add(Dropout(0.3))\n", + "\n", + "model.add(Dense(32, activation='relu'))\n", + "model.add(Dropout(0.2))\n", + "\n", + "model.add(Dense(1, activation='sigmoid')) # Binary output\n" + ], + "metadata": { + "id": "oaI1jdUEGjhL" + }, + "execution_count": 11, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "model.compile(\n", + " optimizer=Adam(learning_rate=0.001),\n", + " loss='binary_crossentropy',\n", + " metrics=['accuracy']\n", + ")\n" + ], + "metadata": { + "id": "0OFCG5QzHNNa" + }, + "execution_count": 12, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "history = model.fit(\n", + " x_train, y_train,\n", + " epochs=40,\n", + " batch_size=32,\n", + " validation_data=(x_test, y_test),\n", + " verbose=1\n", + ")\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "GcnOQJyvHQnS", + "outputId": "4ee51da8-cab0-40fe-aa05-1a3bcc431956" + }, + "execution_count": 16, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Epoch 1/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 28ms/step - accuracy: 0.9422 - loss: 0.1399 - val_accuracy: 0.9000 - val_loss: 0.4047\n", + "Epoch 2/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9392 - loss: 0.1207 - val_accuracy: 0.9000 - val_loss: 0.4096\n", + "Epoch 3/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9561 - loss: 0.0972 - val_accuracy: 0.9000 - val_loss: 0.4148\n", + "Epoch 4/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9434 - loss: 0.0911 - val_accuracy: 0.8500 - val_loss: 0.4188\n", + "Epoch 5/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 0.9526 - loss: 0.0867 - val_accuracy: 0.8500 - val_loss: 0.4224\n", + "Epoch 6/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 37ms/step - accuracy: 0.9690 - loss: 0.0901 - val_accuracy: 0.8500 - val_loss: 0.4267\n", + "Epoch 7/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 37ms/step - accuracy: 0.9422 - loss: 0.1073 - val_accuracy: 0.8500 - val_loss: 0.4304\n", + "Epoch 8/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9494 - loss: 0.1083 - val_accuracy: 0.8500 - val_loss: 0.4354\n", + "Epoch 9/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9681 - loss: 0.0693 - val_accuracy: 0.8500 - val_loss: 0.4407\n", + "Epoch 10/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9403 - loss: 0.1112 - val_accuracy: 0.8500 - val_loss: 0.4449\n", + "Epoch 11/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9485 - loss: 0.1111 - val_accuracy: 0.8500 - val_loss: 0.4487\n", + "Epoch 12/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9584 - loss: 0.0795 - val_accuracy: 0.8500 - val_loss: 0.4531\n", + "Epoch 13/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9386 - loss: 0.1042 - val_accuracy: 0.8500 - val_loss: 0.4585\n", + "Epoch 14/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9778 - loss: 0.0705 - val_accuracy: 0.8500 - val_loss: 0.4645\n", + "Epoch 15/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 37ms/step - accuracy: 0.9569 - loss: 0.0814 - val_accuracy: 0.8500 - val_loss: 0.4716\n", + "Epoch 16/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9412 - loss: 0.1285 - val_accuracy: 0.8500 - val_loss: 0.4768\n", + "Epoch 17/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 38ms/step - accuracy: 0.9357 - loss: 0.0985 - val_accuracy: 0.8500 - val_loss: 0.4812\n", + "Epoch 18/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9741 - loss: 0.0745 - val_accuracy: 0.8500 - val_loss: 0.4869\n", + "Epoch 19/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9672 - loss: 0.0859 - val_accuracy: 0.8500 - val_loss: 0.4903\n", + "Epoch 20/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9795 - loss: 0.0570 - val_accuracy: 0.8500 - val_loss: 0.4937\n", + "Epoch 21/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 28ms/step - accuracy: 0.9569 - loss: 0.0890 - val_accuracy: 0.8500 - val_loss: 0.4960\n", + "Epoch 22/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9714 - loss: 0.0851 - val_accuracy: 0.8500 - val_loss: 0.4990\n", + "Epoch 23/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9718 - loss: 0.0735 - val_accuracy: 0.8500 - val_loss: 0.5011\n", + "Epoch 24/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9545 - loss: 0.0896 - val_accuracy: 0.8500 - val_loss: 0.5033\n", + "Epoch 25/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 0.9698 - loss: 0.0639 - val_accuracy: 0.8500 - val_loss: 0.5060\n", + "Epoch 26/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9351 - loss: 0.1141 - val_accuracy: 0.8500 - val_loss: 0.5069\n", + "Epoch 27/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9464 - loss: 0.0903 - val_accuracy: 0.8500 - val_loss: 0.5107\n", + "Epoch 28/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9630 - loss: 0.0855 - val_accuracy: 0.8500 - val_loss: 0.5140\n", + "Epoch 29/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9843 - loss: 0.0648 - val_accuracy: 0.8500 - val_loss: 0.5192\n", + "Epoch 30/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9558 - loss: 0.0834 - val_accuracy: 0.8500 - val_loss: 0.5239\n", + "Epoch 31/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 17ms/step - accuracy: 0.9799 - loss: 0.0829 - val_accuracy: 0.8500 - val_loss: 0.5291\n", + "Epoch 32/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 17ms/step - accuracy: 0.9745 - loss: 0.0615 - val_accuracy: 0.8500 - val_loss: 0.5320\n", + "Epoch 33/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9644 - loss: 0.0746 - val_accuracy: 0.8500 - val_loss: 0.5351\n", + "Epoch 34/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9688 - loss: 0.0714 - val_accuracy: 0.8500 - val_loss: 0.5415\n", + "Epoch 35/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 20ms/step - accuracy: 0.9868 - loss: 0.0644 - val_accuracy: 0.8500 - val_loss: 0.5477\n", + "Epoch 36/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9649 - loss: 0.0718 - val_accuracy: 0.8500 - val_loss: 0.5538\n", + "Epoch 37/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 21ms/step - accuracy: 0.9727 - loss: 0.0713 - val_accuracy: 0.8500 - val_loss: 0.5594\n", + "Epoch 38/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 19ms/step - accuracy: 0.9581 - loss: 0.0787 - val_accuracy: 0.8500 - val_loss: 0.5645\n", + "Epoch 39/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9615 - loss: 0.0820 - val_accuracy: 0.8500 - val_loss: 0.5699\n", + "Epoch 40/40\n", + "\u001b[1m5/5\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 18ms/step - accuracy: 0.9742 - loss: 0.0627 - val_accuracy: 0.8500 - val_loss: 0.5744\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "test_loss, test_accuracy = model.evaluate(x_test, y_test)\n", + "print(\"Test Accuracy:\", test_accuracy)\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "N3FMlzKLHvWC", + "outputId": "31ba2f20-860a-41a2-c52a-b46e84862225" + }, + "execution_count": 19, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 47ms/step - accuracy: 0.8500 - loss: 0.5744\n", + "Test Accuracy: 0.8500000238418579\n" + ] + } + ] + }, + { + "cell_type": "code", + "source": [ + "y_test_prob = model.predict(x_test)\n", + "y_test_pred = (y_test_prob > 0.5).astype(int)\n", + "\n", + "print(confusion_matrix(y_test, y_test_pred))\n", + "print(classification_report(y_test, y_test_pred))\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "EDbvJ0JNH4pI", + "outputId": "539ef226-b047-4012-d930-42b27a184b5f" + }, + "execution_count": 21, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "\u001b[1m1/1\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 129ms/step\n", + "[[ 0 2]\n", + " [ 1 17]]\n", + " precision recall f1-score support\n", + "\n", + " 0 0.00 0.00 0.00 2\n", + " 1 0.89 0.94 0.92 18\n", + "\n", + " accuracy 0.85 20\n", + " macro avg 0.45 0.47 0.46 20\n", + "weighted avg 0.81 0.85 0.83 20\n", + "\n" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/Mideval code/kuldeep_mideval_code/readme.md b/Mideval code/kuldeep_mideval_code/readme.md new file mode 100644 index 0000000..cf29aee --- /dev/null +++ b/Mideval code/kuldeep_mideval_code/readme.md @@ -0,0 +1 @@ +kuldeep