{ "cells": [ { "cell_type": "code", "execution_count": 27, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "mJNjt9W69_bO", "outputId": "5b9d99cd-abc3-406d-e0be-62e90dd489a6" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "/content/DATA1.xlsx\n" ] } ], "source": [ "from pandas import read_excel, concat\n", "from sklearn.model_selection import cross_val_score\n", "from sklearn.model_selection import train_test_split\n", "from sklearn.preprocessing import LabelEncoder\n", "from sklearn.model_selection import StratifiedKFold\n", "from sklearn.linear_model import SGDClassifier\n", "from sklearn.preprocessing import StandardScaler\n", "from sklearn.linear_model import RidgeClassifier\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.neighbors import KNeighborsClassifier\n", "from sklearn.ensemble import StackingClassifier\n", "from sklearn.pipeline import Pipeline\n", "\n", "import tensorflow as tf\n", "import numpy\n", "\n", "datapath = input()\n", "df = read_excel(datapath, names = [\"OPEN\", \"HIGH\", \"LOW\", \"CLOSE\", \"VOLUME\", \"MACD\", \"TSV\", \"TRIX\", \"AROON\", \"McGINLEY\", \"ST_s\", \"ST_l\", \"RSI\", \"CMF\", \"WR\", \"ADX\", \"CMX\", \"ATR\", \"QQE\", \"AOSC\", \"STOCH\", \"SRSI\", \"ESMI\", \"RVI\", \"VOLOSC\", \"COSC\", \"KOSC\", \"class\"])\n", "X = df[[\"OPEN\", \"HIGH\", \"LOW\", \"CLOSE\", \"VOLUME\", \"MACD\", \"TSV\", \"TRIX\", \"AROON\", \"McGINLEY\", \"ST_s\", \"ST_l\", \"RSI\", \"CMF\", \"WR\", \"ADX\", \"CMX\", \"ATR\", \"QQE\", \"AOSC\", \"STOCH\", \"SRSI\", \"ESMI\", \"RVI\", \"VOLOSC\", \"COSC\", \"KOSC\"]]\n", "y = df[\"class\"]\n", "#X = X.transpose(28,)\n", "# split into input (X) and output (Y) variables\n", "X_train = X[0:20000]\n", "Y_train = y[0:20000]\n", "X_test = X[20000:]\n", "Y_test = y[20000:]" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "id": "UZo0CS2Y0-BB" }, "outputs": [], "source": [ "X_train = numpy.array(X_train)\n", "Y_train = numpy.array(Y_train)\n", "X_test = numpy.array(X_test)\n", "Y_test = numpy.array(Y_test)" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "id": "a2YyF0bD7UTU", "colab": { "base_uri": "https://localhost:8080/" }, "outputId": "06c52cac-4f0d-49fb-8bd7-ede827708efd" }, "outputs": [ { "output_type": "stream", "name": "stderr", "text": [ "/usr/local/lib/python3.10/dist-packages/sklearn/decomposition/_fastica.py:542: FutureWarning: Starting in v1.3, whiten='unit-variance' will be used by default.\n", " warnings.warn(\n" ] } ], "source": [ "from sklearn.decomposition import FastICA\n", "ica = FastICA(n_components=27)\n", "#ica.fit(X_train)\n", "#X_test = ica.transform(X_test)\n", "X_test = ica.fit_transform(X_test)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "id": "N96-RvoPxxTm", "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "outputId": "10385a04-bc29-48c7-9222-179f0a041d9e" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ "StackingClassifier(estimators=[('ridge', RidgeClassifier()),\n", " ('adaboost',\n", " AdaBoostClassifier(n_estimators=27)),\n", " ('bagging',\n", " BaggingClassifier(estimator=SVC(),\n", " n_estimators=27,\n", " random_state=0)),\n", " ('extratrees',\n", " ExtraTreesClassifier(n_estimators=27,\n", " random_state=0))],\n", " final_estimator=HistGradientBoostingClassifier())" ], "text/html": [ "
StackingClassifier(estimators=[('ridge', RidgeClassifier()),\n", " ('adaboost',\n", " AdaBoostClassifier(n_estimators=27)),\n", " ('bagging',\n", " BaggingClassifier(estimator=SVC(),\n", " n_estimators=27,\n", " random_state=0)),\n", " ('extratrees',\n", " ExtraTreesClassifier(n_estimators=27,\n", " random_state=0))],\n", " final_estimator=HistGradientBoostingClassifier())In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook.
StackingClassifier(estimators=[('ridge', RidgeClassifier()),\n", " ('adaboost',\n", " AdaBoostClassifier(n_estimators=27)),\n", " ('bagging',\n", " BaggingClassifier(estimator=SVC(),\n", " n_estimators=27,\n", " random_state=0)),\n", " ('extratrees',\n", " ExtraTreesClassifier(n_estimators=27,\n", " random_state=0))],\n", " final_estimator=HistGradientBoostingClassifier())
RidgeClassifier()
AdaBoostClassifier(n_estimators=27)
SVC()
SVC()
ExtraTreesClassifier(n_estimators=27, random_state=0)
HistGradientBoostingClassifier()