{ "cells": [ { "cell_type": "markdown", "id": "1fecbc87", "metadata": {}, "source": [ "## Import Statement" ] }, { "cell_type": "code", "execution_count": 1, "id": "5169e3ee", "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "id": "76905f72", "metadata": {}, "source": [ "### read the data" ] }, { "cell_type": "code", "execution_count": 2, "id": "b1043895", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(\"../all_port_labelled.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "2e40d90a", "metadata": { "scrolled": true }, "outputs": [ { "data": { "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", "
Unnamed: 0IndexUnnamed: 0.1HeadlineDetailsSeverityCategoryRegionDatetimeYear...ITEPNEWCSDRPEMNNMif_labeledMonthWeek
00.08.034.0Grasberg Mine- Grasberg mine workers extend st...Media sources indicate that workers at the Gra...ModerateMine Workers StrikeIndonesia28/5/17 17:082017.0...0.00.00.00.00.00.01.0False5.021.0
11.010.063.0Indonesia: Undersea internet cables damaged by...News sources are stating that recent typhoons ...MinorTravel WarningIndonesia4/9/17 14:302017.0...0.00.00.00.00.01.00.0False4.014.0
\n", "

2 rows × 46 columns

\n", "
" ], "text/plain": [ " Unnamed: 0 Index Unnamed: 0.1 \\\n", "0 0.0 8.0 34.0 \n", "1 1.0 10.0 63.0 \n", "\n", " Headline \\\n", "0 Grasberg Mine- Grasberg mine workers extend st... \n", "1 Indonesia: Undersea internet cables damaged by... \n", "\n", " Details Severity \\\n", "0 Media sources indicate that workers at the Gra... Moderate \n", "1 News sources are stating that recent typhoons ... Minor \n", "\n", " Category Region Datetime Year ... IT EP NEW \\\n", "0 Mine Workers Strike Indonesia 28/5/17 17:08 2017.0 ... 0.0 0.0 0.0 \n", "1 Travel Warning Indonesia 4/9/17 14:30 2017.0 ... 0.0 0.0 0.0 \n", "\n", " CSD RPE MN NM if_labeled Month Week \n", "0 0.0 0.0 0.0 1.0 False 5.0 21.0 \n", "1 0.0 0.0 1.0 0.0 False 4.0 14.0 \n", "\n", "[2 rows x 46 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head(2)" ] }, { "cell_type": "markdown", "id": "643a7e40", "metadata": {}, "source": [ "### Clean empty data" ] }, { "cell_type": "code", "execution_count": 4, "id": "d6ee1fd7", "metadata": {}, "outputs": [], "source": [ "import nltk\n", "from nltk.corpus import stopwords\n", "from nltk.tokenize import word_tokenize\n", "from nltk.stem import WordNetLemmatizer\n", "import string\n", "\n", "# nltk.download('punkt')\n", "# nltk.download('stopwords')\n", "# nltk.download('wordnet')\n", "\n", "\n", "def clean_text(text):\n", " # Lowercase\n", " text = text.lower()\n", " # Tokenization\n", " tokens = word_tokenize(text)\n", " # Removing punctuation\n", " tokens = [word for word in tokens if word not in string.punctuation]\n", " # Removing stop words\n", " stop_words = set(stopwords.words(\"english\"))\n", " tokens = [word for word in tokens if word not in stop_words]\n", " # Lemmatization\n", " lemmatizer = WordNetLemmatizer()\n", " tokens = [lemmatizer.lemmatize(word) for word in tokens]\n", "\n", " return \" \".join(tokens)" ] }, { "cell_type": "code", "execution_count": 5, "id": "9e35b49a", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[nltk_data] Downloading package omw-1.4 to\n", "[nltk_data] C:\\Users\\ellay\\AppData\\Roaming\\nltk_data...\n", "[nltk_data] Package omw-1.4 is already up-to-date!\n" ] }, { "data": { "text/plain": [ "True" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import nltk\n", "\n", "nltk.download(\"omw-1.4\")" ] }, { "cell_type": "markdown", "id": "ca331c4b", "metadata": {}, "source": [ "### The Details column has an issue\n", "\n", "some of the data are of the type float and none of the text processing functions can be applied to it therefore we have to process it" ] }, { "cell_type": "code", "execution_count": 6, "id": "2438c58f", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 5782 entries, 0 to 5781\n", "Data columns (total 2 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 Details 5781 non-null object\n", " 1 maritime_label 5781 non-null object\n", "dtypes: object(2)\n", "memory usage: 90.5+ KB\n", "\n", "RangeIndex: 5782 entries, 0 to 5781\n", "Data columns (total 3 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 Details 5781 non-null object\n", " 1 maritime_label 5781 non-null object\n", " 2 Details_cleaned 5781 non-null object\n", "dtypes: object(3)\n", "memory usage: 135.6+ KB\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ ":3: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " text_df['Details_cleaned'] = text_df['Details'].apply(lambda x: clean_text(x) if not isinstance(x, float) else None)\n" ] } ], "source": [ "text_df = df[[\"Details\", \"maritime_label\"]]\n", "text_df.info()\n", "text_df[\"Details_cleaned\"] = text_df[\"Details\"].apply(\n", " lambda x: clean_text(x) if not isinstance(x, float) else None\n", ")\n", "# no_nan_df[no_nan_df[\"Details\"].apply(lambda x: print(type(x)))]\n", "# cleaned_df = text_df[text_df[\"Details\"].apply(lambda x: clean_text(x))]\n", "# cleaned_df = df['Details'][1:2]\n", "# type(no_nan_df[\"Details\"][0])\n", "# print(clean_text(no_nan_df[\"Details\"][0]))\n", "text_df.info()" ] }, { "cell_type": "code", "execution_count": 7, "id": "4d3b0011", "metadata": {}, "outputs": [ { "data": { "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", "
Detailsmaritime_labelDetails_cleaned
0Media sources indicate that workers at the Gra...FALSEmedium source indicate worker grasberg mine ex...
1News sources are stating that recent typhoons ...FALSEnews source stating recent typhoon impact hong...
2The persisting port congestion at Shanghai’s Y...TRUEpersisting port congestion shanghai ’ yangshan...
3Updated local media sources from Jakarta indic...TRUEupdated local medium source jakarta indicate e...
4According to local police in Jakarta, two expl...TRUEaccording local police jakarta two explosion c...
\n", "
" ], "text/plain": [ " Details maritime_label \\\n", "0 Media sources indicate that workers at the Gra... FALSE \n", "1 News sources are stating that recent typhoons ... FALSE \n", "2 The persisting port congestion at Shanghai’s Y... TRUE \n", "3 Updated local media sources from Jakarta indic... TRUE \n", "4 According to local police in Jakarta, two expl... TRUE \n", "\n", " Details_cleaned \n", "0 medium source indicate worker grasberg mine ex... \n", "1 news source stating recent typhoon impact hong... \n", "2 persisting port congestion shanghai ’ yangshan... \n", "3 updated local medium source jakarta indicate e... \n", "4 according local police jakarta two explosion c... " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "processed_data = text_df.dropna()\n", "processed_data.head()" ] }, { "cell_type": "markdown", "id": "3c4be609", "metadata": {}, "source": [ "## Naive Bayes Model" ] }, { "cell_type": "code", "execution_count": 8, "id": "5c660011", "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "\n", "# from sklearn.feature_extraction.text import CountVectorizer\n", "from sklearn.naive_bayes import MultinomialNB\n", "from sklearn.metrics import accuracy_score, classification_report" ] }, { "cell_type": "code", "execution_count": 9, "id": "8f009a65", "metadata": {}, "outputs": [], "source": [ "X = processed_data[\"Details_cleaned\"]\n", "y = processed_data[\"maritime_label\"]" ] }, { "cell_type": "code", "execution_count": 10, "id": "0185a967", "metadata": {}, "outputs": [], "source": [ "X_train, X_test, y_train, y_test = train_test_split(\n", " X, y, test_size=0.2, random_state=42\n", ")" ] }, { "cell_type": "code", "execution_count": 11, "id": "d3c2de6b", "metadata": {}, "outputs": [], "source": [ "# vectorizer = CountVectorizer()\n", "# X_train_vec = vectorizer.fit_transform(X_train)\n", "# X_test_vec = vectorizer.transform(X_test)\n", "\n", "tfidf_vectorizer = TfidfVectorizer(max_features=1000)\n", "X_train_tfidf = tfidf_vectorizer.fit_transform(X_train)\n", "X_test_tfidf = tfidf_vectorizer.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 12, "id": "ead2fc7a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "MultinomialNB()" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "naive_bayes = MultinomialNB()\n", "naive_bayes.fit(X_train_tfidf, y_train)" ] }, { "cell_type": "code", "execution_count": 13, "id": "74c5df68", "metadata": {}, "outputs": [], "source": [ "predictions = naive_bayes.predict(X_test_tfidf)" ] }, { "cell_type": "code", "execution_count": 14, "id": "109e9456", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Accuracy of Naive Bayes model: 0.8582541054451167\n", " precision recall f1-score support\n", "\n", " FALSE 0.88 0.94 0.91 847\n", " TRUE 0.79 0.65 0.71 310\n", "\n", " accuracy 0.86 1157\n", " macro avg 0.83 0.79 0.81 1157\n", "weighted avg 0.85 0.86 0.85 1157\n", "\n" ] } ], "source": [ "accuracy = accuracy_score(y_test, predictions)\n", "print(\"Accuracy of Naive Bayes model:\", accuracy)\n", "print(classification_report(y_test, predictions))" ] }, { "cell_type": "markdown", "id": "9518614a", "metadata": {}, "source": [ "## Logistic Regression model" ] }, { "cell_type": "code", "execution_count": 15, "id": "912ad7a6", "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.linear_model import LogisticRegression\n", "from sklearn.metrics import accuracy_score" ] }, { "cell_type": "code", "execution_count": 16, "id": "03eac734", "metadata": {}, "outputs": [], "source": [ "X_train, X_test, y_train, y_test = train_test_split(\n", " X, y, test_size=0.2, random_state=42\n", ")" ] }, { "cell_type": "code", "execution_count": 17, "id": "e84ff87c", "metadata": {}, "outputs": [], "source": [ "tfidf_vectorizer = TfidfVectorizer(max_features=1000)\n", "X_train_tfidf = tfidf_vectorizer.fit_transform(X_train)\n", "X_test_tfidf = tfidf_vectorizer.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 18, "id": "cedb263c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LogisticRegression()" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model = LogisticRegression()\n", "model.fit(X_train_tfidf, y_train)" ] }, { "cell_type": "code", "execution_count": 19, "id": "6f49fddb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Accuracy of Logistic Regression Model: 0.9317199654278306\n", " precision recall f1-score support\n", "\n", " FALSE 0.92 0.99 0.96 847\n", " TRUE 0.98 0.76 0.86 310\n", "\n", " accuracy 0.93 1157\n", " macro avg 0.95 0.88 0.91 1157\n", "weighted avg 0.93 0.93 0.93 1157\n", "\n" ] } ], "source": [ "y_pred = model.predict(X_test_tfidf)\n", "\n", "accuracy = accuracy_score(y_test, y_pred)\n", "print(\"Accuracy of Logistic Regression Model:\", accuracy)\n", "print(classification_report(y_test, y_pred))" ] }, { "cell_type": "markdown", "id": "613c0cdf", "metadata": {}, "source": [ "## Support Vector Machine (SVM) model" ] }, { "cell_type": "code", "execution_count": 20, "id": "706302c1", "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.svm import SVC\n", "from sklearn.metrics import accuracy_score" ] }, { "cell_type": "code", "execution_count": 21, "id": "b0988ca4", "metadata": {}, "outputs": [], "source": [ "X_train, X_test, y_train, y_test = train_test_split(\n", " X, y, test_size=0.2, random_state=42\n", ")" ] }, { "cell_type": "code", "execution_count": 22, "id": "4f682c60", "metadata": {}, "outputs": [], "source": [ "tfidf_vectorizer = TfidfVectorizer(max_features=1000)\n", "X_train_tfidf = tfidf_vectorizer.fit_transform(X_train)\n", "X_test_tfidf = tfidf_vectorizer.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 23, "id": "71ae91d9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "SVC(kernel='linear')" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "svm_model = SVC(kernel=\"linear\")\n", "svm_model.fit(X_train_tfidf, y_train)" ] }, { "cell_type": "code", "execution_count": 24, "id": "2dc1b193", "metadata": {}, "outputs": [], "source": [ "y_pred = svm_model.predict(X_test_tfidf)" ] }, { "cell_type": "code", "execution_count": 25, "id": "92801e61", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Accuracy of SVM model: 0.9498703543647364\n", " precision recall f1-score support\n", "\n", " FALSE 0.94 1.00 0.97 847\n", " TRUE 0.99 0.82 0.90 310\n", "\n", " accuracy 0.95 1157\n", " macro avg 0.96 0.91 0.93 1157\n", "weighted avg 0.95 0.95 0.95 1157\n", "\n" ] } ], "source": [ "accuracy = accuracy_score(y_test, y_pred)\n", "print(\"Accuracy of SVM model:\", accuracy)\n", "print(classification_report(y_test, y_pred))" ] }, { "cell_type": "markdown", "id": "1d1f6ebd", "metadata": {}, "source": [ "## Random Forest Model" ] }, { "cell_type": "code", "execution_count": 26, "id": "9170c174", "metadata": {}, "outputs": [], "source": [ "from sklearn.model_selection import train_test_split\n", "from sklearn.feature_extraction.text import TfidfVectorizer\n", "from sklearn.ensemble import RandomForestClassifier\n", "from sklearn.metrics import accuracy_score" ] }, { "cell_type": "code", "execution_count": 27, "id": "2092ca05", "metadata": {}, "outputs": [], "source": [ "X_train, X_test, y_train, y_test = train_test_split(\n", " X, y, test_size=0.2, random_state=42\n", ")" ] }, { "cell_type": "code", "execution_count": 28, "id": "206296ce", "metadata": {}, "outputs": [], "source": [ "tfidf_vectorizer = TfidfVectorizer(max_features=1000)\n", "X_train_tfidf = tfidf_vectorizer.fit_transform(X_train)\n", "X_test_tfidf = tfidf_vectorizer.transform(X_test)" ] }, { "cell_type": "code", "execution_count": 29, "id": "258bd78f", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "RandomForestClassifier(random_state=42)" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rf_model = RandomForestClassifier(n_estimators=100, random_state=42)\n", "rf_model.fit(X_train_tfidf, y_train)" ] }, { "cell_type": "code", "execution_count": 30, "id": "0e2910f6", "metadata": {}, "outputs": [], "source": [ "y_pred = rf_model.predict(X_test_tfidf)" ] }, { "cell_type": "code", "execution_count": 31, "id": "f06900d3", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Accuracy of Random Forest Model: 0.9636992221261884\n", " precision recall f1-score support\n", "\n", " FALSE 0.96 0.99 0.98 847\n", " TRUE 0.98 0.88 0.93 310\n", "\n", " accuracy 0.96 1157\n", " macro avg 0.97 0.94 0.95 1157\n", "weighted avg 0.96 0.96 0.96 1157\n", "\n" ] } ], "source": [ "accuracy = accuracy_score(y_test, y_pred)\n", "print(\"Accuracy of Random Forest Model:\", accuracy)\n", "print(classification_report(y_test, y_pred))" ] }, { "cell_type": "markdown", "id": "64673d66", "metadata": {}, "source": [ "## Simpe Neural Network" ] }, { "cell_type": "code", "execution_count": 1, "id": "b8b103b0", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting tensorflow\n", " Obtaining dependency information for tensorflow from https://files.pythonhosted.org/packages/f9/14/67e9b2b2379cb530c0412123a674d045eca387dfcfa7db1c0028857b0a66/tensorflow-2.16.1-cp311-cp311-macosx_12_0_arm64.whl.metadata\n", " Downloading tensorflow-2.16.1-cp311-cp311-macosx_12_0_arm64.whl.metadata (4.1 kB)\n", "Collecting absl-py>=1.0.0 (from tensorflow)\n", " Obtaining dependency information for absl-py>=1.0.0 from https://files.pythonhosted.org/packages/a2/ad/e0d3c824784ff121c03cc031f944bc7e139a8f1870ffd2845cc2dd76f6c4/absl_py-2.1.0-py3-none-any.whl.metadata\n", " Downloading absl_py-2.1.0-py3-none-any.whl.metadata (2.3 kB)\n", "Collecting astunparse>=1.6.0 (from tensorflow)\n", " Obtaining dependency information for astunparse>=1.6.0 from https://files.pythonhosted.org/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl.metadata\n", " Downloading astunparse-1.6.3-py2.py3-none-any.whl.metadata (4.4 kB)\n", "Collecting flatbuffers>=23.5.26 (from tensorflow)\n", " Obtaining dependency information for flatbuffers>=23.5.26 from https://files.pythonhosted.org/packages/bf/45/c961e3cb6ddad76b325c163d730562bb6deb1ace5acbed0306f5fbefb90e/flatbuffers-24.3.7-py2.py3-none-any.whl.metadata\n", " Downloading flatbuffers-24.3.7-py2.py3-none-any.whl.metadata (849 bytes)\n", "Collecting gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 (from tensorflow)\n", " Obtaining dependency information for gast!=0.5.0,!=0.5.1,!=0.5.2,>=0.2.1 from https://files.pythonhosted.org/packages/fa/39/5aae571e5a5f4de9c3445dae08a530498e5c53b0e74410eeeb0991c79047/gast-0.5.4-py3-none-any.whl.metadata\n", " Downloading gast-0.5.4-py3-none-any.whl.metadata (1.3 kB)\n", "Collecting google-pasta>=0.1.1 (from tensorflow)\n", " Obtaining dependency information for google-pasta>=0.1.1 from https://files.pythonhosted.org/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl.metadata\n", " Downloading google_pasta-0.2.0-py3-none-any.whl.metadata (814 bytes)\n", "Collecting h5py>=3.10.0 (from tensorflow)\n", " Obtaining dependency information for h5py>=3.10.0 from https://files.pythonhosted.org/packages/8d/70/2b0b99507287f66e71a6b2e66c5ad2ec2461ef2c534668eef96c3b48eb6d/h5py-3.10.0-cp311-cp311-macosx_11_0_arm64.whl.metadata\n", " Downloading h5py-3.10.0-cp311-cp311-macosx_11_0_arm64.whl.metadata (2.5 kB)\n", "Collecting libclang>=13.0.0 (from tensorflow)\n", " Obtaining dependency information for libclang>=13.0.0 from https://files.pythonhosted.org/packages/db/ed/1df62b44db2583375f6a8a5e2ca5432bbdc3edb477942b9b7c848c720055/libclang-18.1.1-py2.py3-none-macosx_11_0_arm64.whl.metadata\n", " Downloading libclang-18.1.1-py2.py3-none-macosx_11_0_arm64.whl.metadata (5.2 kB)\n", "Collecting ml-dtypes~=0.3.1 (from tensorflow)\n", " Obtaining dependency information for ml-dtypes~=0.3.1 from https://files.pythonhosted.org/packages/6e/a4/6aabb78f1569550fd77c74d2c1d008b502c8ce72776bd88b14ea6c182c9e/ml_dtypes-0.3.2-cp311-cp311-macosx_10_9_universal2.whl.metadata\n", " Downloading ml_dtypes-0.3.2-cp311-cp311-macosx_10_9_universal2.whl.metadata (20 kB)\n", "Collecting opt-einsum>=2.3.2 (from tensorflow)\n", " Obtaining dependency information for opt-einsum>=2.3.2 from https://files.pythonhosted.org/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl.metadata\n", " Downloading opt_einsum-3.3.0-py3-none-any.whl.metadata (6.5 kB)\n", "Requirement already satisfied: packaging in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (23.0)\n", "Collecting protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 (from tensorflow)\n", " Obtaining dependency information for protobuf!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5,<5.0.0dev,>=3.20.3 from https://files.pythonhosted.org/packages/f3/bf/26deba06a4c910a85f78245cac7698f67cedd7efe00d04f6b3e1b3506a59/protobuf-4.25.3-cp37-abi3-macosx_10_9_universal2.whl.metadata\n", " Downloading protobuf-4.25.3-cp37-abi3-macosx_10_9_universal2.whl.metadata (541 bytes)\n", "Requirement already satisfied: requests<3,>=2.21.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (2.31.0)\n", "Requirement already satisfied: setuptools in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (68.0.0)\n", "Requirement already satisfied: six>=1.12.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (1.16.0)\n", "Collecting termcolor>=1.1.0 (from tensorflow)\n", " Obtaining dependency information for termcolor>=1.1.0 from https://files.pythonhosted.org/packages/d9/5f/8c716e47b3a50cbd7c146f45881e11d9414def768b7cd9c5e6650ec2a80a/termcolor-2.4.0-py3-none-any.whl.metadata\n", " Downloading termcolor-2.4.0-py3-none-any.whl.metadata (6.1 kB)\n", "Requirement already satisfied: typing-extensions>=3.6.6 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (4.7.1)\n", "Requirement already satisfied: wrapt>=1.11.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (1.14.1)\n", "Collecting grpcio<2.0,>=1.24.3 (from tensorflow)\n", " Obtaining dependency information for grpcio<2.0,>=1.24.3 from https://files.pythonhosted.org/packages/c1/0a/a8c0f403b2189f5d3e490778ead51924b56fa30a35f6e444b3702e28c8c8/grpcio-1.62.1-cp311-cp311-macosx_10_10_universal2.whl.metadata\n", " Downloading grpcio-1.62.1-cp311-cp311-macosx_10_10_universal2.whl.metadata (4.0 kB)\n", "Collecting tensorboard<2.17,>=2.16 (from tensorflow)\n", " Obtaining dependency information for tensorboard<2.17,>=2.16 from https://files.pythonhosted.org/packages/3a/d0/b97889ffa769e2d1fdebb632084d5e8b53fc299d43a537acee7ec0c021a3/tensorboard-2.16.2-py3-none-any.whl.metadata\n", " Downloading tensorboard-2.16.2-py3-none-any.whl.metadata (1.6 kB)\n", "Collecting keras>=3.0.0 (from tensorflow)\n", " Obtaining dependency information for keras>=3.0.0 from https://files.pythonhosted.org/packages/59/a8/d94e8acb59d678d908fe1db0c7ad89dfa2c2e2e529eeb3c2b3cc218a758d/keras-3.1.1-py3-none-any.whl.metadata\n", " Downloading keras-3.1.1-py3-none-any.whl.metadata (5.6 kB)\n", "Collecting tensorflow-io-gcs-filesystem>=0.23.1 (from tensorflow)\n", " Obtaining dependency information for tensorflow-io-gcs-filesystem>=0.23.1 from https://files.pythonhosted.org/packages/3e/56/1b7ef816e448464a93da70296db237129910b4452d6b4582d5e23fb07880/tensorflow_io_gcs_filesystem-0.36.0-cp311-cp311-macosx_12_0_arm64.whl.metadata\n", " Downloading tensorflow_io_gcs_filesystem-0.36.0-cp311-cp311-macosx_12_0_arm64.whl.metadata (14 kB)\n", "Requirement already satisfied: numpy<2.0.0,>=1.23.5 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorflow) (1.24.3)\n", "Requirement already satisfied: wheel<1.0,>=0.23.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from astunparse>=1.6.0->tensorflow) (0.38.4)\n", "Collecting rich (from keras>=3.0.0->tensorflow)\n", " Obtaining dependency information for rich from https://files.pythonhosted.org/packages/87/67/a37f6214d0e9fe57f6ae54b2956d550ca8365857f42a1ce0392bb21d9410/rich-13.7.1-py3-none-any.whl.metadata\n", " Downloading rich-13.7.1-py3-none-any.whl.metadata (18 kB)\n", "Collecting namex (from keras>=3.0.0->tensorflow)\n", " Obtaining dependency information for namex from https://files.pythonhosted.org/packages/cd/43/b971880e2eb45c0bee2093710ae8044764a89afe9620df34a231c6f0ecd2/namex-0.0.7-py3-none-any.whl.metadata\n", " Downloading namex-0.0.7-py3-none-any.whl.metadata (246 bytes)\n", "Collecting optree (from keras>=3.0.0->tensorflow)\n", " Obtaining dependency information for optree from https://files.pythonhosted.org/packages/14/8a/a7a152dedfc700de64efa68c3ae7ccf079ba5a5bc8ff1706a671b374cfcd/optree-0.10.0-cp311-cp311-macosx_11_0_arm64.whl.metadata\n", " Downloading optree-0.10.0-cp311-cp311-macosx_11_0_arm64.whl.metadata (45 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.3/45.3 kB\u001b[0m \u001b[31m4.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: charset-normalizer<4,>=2 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (2.0.4)\n", "Requirement already satisfied: idna<4,>=2.5 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (3.4)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (1.26.16)\n", "Requirement already satisfied: certifi>=2017.4.17 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from requests<3,>=2.21.0->tensorflow) (2024.2.2)\n", "Requirement already satisfied: markdown>=2.6.8 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorboard<2.17,>=2.16->tensorflow) (3.4.1)\n", "Collecting tensorboard-data-server<0.8.0,>=0.7.0 (from tensorboard<2.17,>=2.16->tensorflow)\n", " Obtaining dependency information for tensorboard-data-server<0.8.0,>=0.7.0 from https://files.pythonhosted.org/packages/7a/13/e503968fefabd4c6b2650af21e110aa8466fe21432cd7c43a84577a89438/tensorboard_data_server-0.7.2-py3-none-any.whl.metadata\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ " Downloading tensorboard_data_server-0.7.2-py3-none-any.whl.metadata (1.1 kB)\n", "Requirement already satisfied: werkzeug>=1.0.1 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from tensorboard<2.17,>=2.16->tensorflow) (2.2.3)\n", "Requirement already satisfied: MarkupSafe>=2.1.1 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from werkzeug>=1.0.1->tensorboard<2.17,>=2.16->tensorflow) (2.1.1)\n", "Requirement already satisfied: markdown-it-py>=2.2.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from rich->keras>=3.0.0->tensorflow) (2.2.0)\n", "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from rich->keras>=3.0.0->tensorflow) (2.15.1)\n", "Requirement already satisfied: mdurl~=0.1 in /Users/barebear/anaconda3/lib/python3.11/site-packages (from markdown-it-py>=2.2.0->rich->keras>=3.0.0->tensorflow) (0.1.0)\n", "Downloading tensorflow-2.16.1-cp311-cp311-macosx_12_0_arm64.whl (227.0 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m227.0/227.0 MB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:02\u001b[0m\n", "\u001b[?25hDownloading absl_py-2.1.0-py3-none-any.whl (133 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m133.7/133.7 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading astunparse-1.6.3-py2.py3-none-any.whl (12 kB)\n", "Downloading flatbuffers-24.3.7-py2.py3-none-any.whl (26 kB)\n", "Downloading gast-0.5.4-py3-none-any.whl (19 kB)\n", "Downloading google_pasta-0.2.0-py3-none-any.whl (57 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.5/57.5 kB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading grpcio-1.62.1-cp311-cp311-macosx_10_10_universal2.whl (10.0 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m10.0/10.0 MB\u001b[0m \u001b[31m3.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m0:01\u001b[0m\n", "\u001b[?25hDownloading h5py-3.10.0-cp311-cp311-macosx_11_0_arm64.whl (2.6 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.6/2.6 MB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading keras-3.1.1-py3-none-any.whl (1.1 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading libclang-18.1.1-py2.py3-none-macosx_11_0_arm64.whl (26.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m26.4/26.4 MB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading ml_dtypes-0.3.2-cp311-cp311-macosx_10_9_universal2.whl (389 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m389.8/389.8 kB\u001b[0m \u001b[31m2.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading opt_einsum-3.3.0-py3-none-any.whl (65 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m65.5/65.5 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hDownloading protobuf-4.25.3-cp37-abi3-macosx_10_9_universal2.whl (394 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m394.2/394.2 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading tensorboard-2.16.2-py3-none-any.whl (5.5 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.5/5.5 MB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading tensorflow_io_gcs_filesystem-0.36.0-cp311-cp311-macosx_12_0_arm64.whl (3.4 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.4/3.4 MB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", "\u001b[?25hDownloading termcolor-2.4.0-py3-none-any.whl (7.7 kB)\n", "Downloading tensorboard_data_server-0.7.2-py3-none-any.whl (2.4 kB)\n", "Downloading namex-0.0.7-py3-none-any.whl (5.8 kB)\n", "Downloading optree-0.10.0-cp311-cp311-macosx_11_0_arm64.whl (250 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m250.2/250.2 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hDownloading rich-13.7.1-py3-none-any.whl (240 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m240.7/240.7 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", "\u001b[?25hInstalling collected packages: namex, libclang, flatbuffers, termcolor, tensorflow-io-gcs-filesystem, tensorboard-data-server, protobuf, optree, opt-einsum, ml-dtypes, h5py, grpcio, google-pasta, gast, astunparse, absl-py, tensorboard, rich, keras, tensorflow\n", " Attempting uninstall: h5py\n", " Found existing installation: h5py 3.7.0\n", " Uninstalling h5py-3.7.0:\n", " Successfully uninstalled h5py-3.7.0\n", "Successfully installed absl-py-2.1.0 astunparse-1.6.3 flatbuffers-24.3.7 gast-0.5.4 google-pasta-0.2.0 grpcio-1.62.1 h5py-3.10.0 keras-3.1.1 libclang-18.1.1 ml-dtypes-0.3.2 namex-0.0.7 opt-einsum-3.3.0 optree-0.10.0 protobuf-4.25.3 rich-13.7.1 tensorboard-2.16.2 tensorboard-data-server-0.7.2 tensorflow-2.16.1 tensorflow-io-gcs-filesystem-0.36.0 termcolor-2.4.0\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "pip install tensorflow" ] }, { "cell_type": "code", "execution_count": null, "id": "e6dd2304", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.4" } }, "nbformat": 4, "nbformat_minor": 5 }