# -*- coding: utf-8 -*- """Proyecto Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/175o-2viQ5571edB9P-BHId-g5onpE9rH """ #Implementación basada en el paper basde del proyecto #Descargando el Dataset de Kaggle from google.colab import files files.upload() #this will prompt you to upload the kaggle.json !pip install -q kaggle !mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/ !ls ~/.kaggle !chmod 600 /root/.kaggle/kaggle.json # set permission ! kaggle datasets download -d jessicali9530/celeba-dataset ! unzip celeba-dataset.zip -d kaggle ! unzip kaggle/img_align_celeba.zip -d kaggle from google.colab import drive
# -*- coding: utf-8 -*- """ANN1.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1J0nfogscnNz7ZMlUm4oGZHozPlybmSR0 """ import pandas as pd from google.colab import files file = files.upload() data = pd.read_csv("breastCancer.csv", header=None) df = pd.DataFrame(data) print(df) df[6] = df[6].replace('?', 0) df[6] = df[6].astype(int) print(df.dtypes) mean = int(df[6].mean()) df[6] = df[6].replace(0, mean) print(df) df[10] = df[10].replace(2, 0).replace(4, 1) print(df) from sklearn.model_selection import train_test_split X = df.iloc[:, 1:10]
def read_data(filename,delimiter,encoding='utf-8'): uploaded = files.upload() return pd.read_csv(io.BytesIO(uploaded[filename]),delimiter=delimiter,encoding=encoding)
# Colab library to upload files to notebook from google.colab import files from google.colab import drive drive.mount('/content/drive', force_remount=True) # Install Kaggle library !pip install -q kaggle # Upload kaggle API key file data = files.upload() !mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/ !chmod 600 ~/.kaggle/kaggle.json # Download the dataset from kaggle !kaggle datasets download -d tawsifurrahman/covid19-radiography-database # Extract zipfile import zipfile zip_ref = zipfile.ZipFile('covid19-radiography-database.zip', 'r') zip_ref.extractall('files') zip_ref.close() # Modules for train-val split import os import numpy as np import random import argparse from shutil import copyfile
> Validation Data (635 Images) ###Mount Gdrive serta Download dan Ekstrak Dataset """ from google.colab import drive drive.mount('/content/drive') import os os.environ['KAGGLE_CONFIG_DIR'] = "/content/drive/MyDrive/Dataset/Dataset Citra 240 - 235" # Commented out IPython magic to ensure Python compatibility. # %cd /content/drive/MyDrive/Dataset/Dataset Citra 240 - 235 from google.colab import files files.upload() !mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/ !ls ~/.kaggle !chmod 600 /root/.kaggle/kaggle.json !kaggle datasets download -d sartajbhuvaji/brain-tumor-classification-mri !mkdir 'Dataset Brain MRI' import zipfile ekstrak_zip = '/content/drive/MyDrive/Dataset/Dataset Citra 240 - 235/brain-tumor-classification-mri.zip' out_zip = zipfile.ZipFile(ekstrak_zip, 'r') out_zip.extractall('/content/drive/MyDrive/Dataset/Dataset Citra 240 - 235/Dataset Brain MRI')
Original file is located at https://colab.research.google.com/drive/1LEdeNqtc0O35vEemIfiuMkwuSHT-ExlS """ #Description : This programs detect breast cancer, based off of data #import libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # load the data from google.colab import files uploaded = files.upload() df = pd.read_csv('data.csv') df.head(7) #count of the number of empty values in each column #count the number of rows and columns in thr datset df.shape df.isna().sum() #drop the column with all the missing values df = df.dropna(axis=1) #get the count of the number of rows and columns df.shape
Original file is located at https://colab.research.google.com/drive/1twFvSWFXwNLmRb7BIl2DwtL5cAecoRSD """ #simple linear regression in python #step 1: #importing libraries import numpy as np import pandas as pd import matplotlib.pyplot as plt #step 2: #import dataset: from google.colab import files up = files.upload() data = pd.read_csv('Salary_Data.csv') #now choose the prediction set i.e y and features i.e X #X=data.loc["YearsExperience"] #it doesnt work as it is used to retrieve data of "years experience" under index_col we have specified ie extracting thesingle row #y=data.loc["Salary"] #to make it work, we need to specify either the index col while reading csv or use this: X = data.iloc[:, :-1] y = data.iloc[:, 1] print(X) print(y)
import chardet import re import sklearn import itertools import emoji from simpletransformers.classification import ClassificationModel import torch from sklearn.impute import SimpleImputer from sklearn.model_selection import KFold, cross_val_score from sklearn.pipeline import Pipeline from sklearn.discriminant_analysis import LinearDiscriminantAnalysis """# IMPORT DATASET""" from google.colab import files data_to_load = files.upload() #df_raw = pd.read_csv("C:\\Users\\Administrator\\Desktop\\hsd\\labeled_data.csv") df_raw = pd.read_csv("labeled_data.csv", encoding='latin1') #Try calling read_csv with encoding='latin1', encoding='iso-8859-1' or encoding='cp1252' """Target is defined as 1 & 0. ‘1’ indicates that it is a preventive information & ‘0’ indicates other wise""" df_raw.head() """# Google Translate abstract data""" from googletrans import Translator translator = Translator()
Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1-RaUtF2Lx0mhc6UuqkpBeybIhUU1FZgw """ # Importing required libraries import pandas as pd import numpy as np from sklearn.svm import SVR import matplotlib.pyplot as plt #Loading data from google.colab import files # Use to load data on Google Colab uploaded = files.upload() # Use to load data on Google Colab df = pd.read_csv('FB_30_days.csv') df.head(7) # Creating lists for X and Y axis dates = [] prices = [] # No of rows and coluumns df.shape # Printing the last row df.tail(1) # Storing data in df except the last row (cause we want to predict it) df = df.head(len(df) - 1)
"""### Monte o Google Drive Para transmitir arquivos, precisamos montar o Google Drive. """ from google.colab import drive drive.mount("/content/drive") """### Adicionar do arquivo Torrent Você pode executar esta célula para adicionar mais arquivos quantas vezes quiser """ from google.colab import files source = files.upload() params = { "save_path": "/content/drive/My Drive/Torrent", "ti": lt.torrent_info(list(source.keys())[0]), } downloads.append(ses.add_torrent(params)) """### Adicionar Link Magnético""" params = {"save_path": "/content/drive/My Drive/Torrent"} while True: magnet_link = input("Digite o link magnético ou digite Exit: ") if magnet_link.lower() == "exit": break downloads.append(
import pandas as pd import numpy as np from matplotlib import pyplot as plt from google.colab import files uploaded = files.upload() import io import pandas as pd df = pd.read_csv(io.BytesIO(uploaded['train.txt']), delimiter=" ", names=['x', 'y', 'label'], header=None) print(df) x = df['x'].tolist() y = df['y'].tolist() classes = df['label'].tolist() class1Indexes = [] class2Indexes = [] for i in range(len(classes)): if classes[i] == 1: class1Indexes.append(i) else: class2Indexes.append(i) x_class1 = [] x_class2 = [] y_class1 = []
from google.colab import files import pandas as pd import io upload_files = files.upload() for filename in upload_files.keys(): data = pd.read_csv(io.StringIO(upload_files[filename].decode('utf-8')), header=None) print(data.head())
for ns in drums_samples: play(ns) #@title Optionally download generated MIDI samples. for i, ns in enumerate(drums_samples): download(ns, '%s_sample_%d.mid' % (drums_sample_model, i)) """## Generate Interpolations""" #@title Option 1: Use example MIDI files for interpolation endpoints. input_drums_midi_data = [ tf.io.gfile.GFile(fn, mode='rb').read() for fn in sorted(tf.io.gfile.glob(BASE_DIR + '/midi/drums_2bar*.mid'))] #@title Option 2: upload your own MIDI files to use for interpolation endpoints instead of those provided. input_drums_midi_data = files.upload().values() or input_drums_midi_data #@title Extract drums from MIDI files. This will extract all unique 2-bar drum beats using a sliding window with a stride of 1 bar. drums_input_seqs = [mm.midi_to_sequence_proto(m) for m in input_drums_midi_data] extracted_beats = [] for ns in drums_input_seqs: extracted_beats.extend(drums_nade_full_config.data_converter.from_tensors( drums_nade_full_config.data_converter.to_tensors(ns)[1])) for i, ns in enumerate(extracted_beats): print("Beat", i) play(ns) #@title Interpolate between 2 beats, selected from those in the previous cell. drums_interp_model = "drums_2bar_oh_hikl" #@param ["drums_2bar_oh_lokl", "drums_2bar_oh_hikl", "drums_2bar_nade_reduced", "drums_2bar_nade_full"] start_beat = 0 #@param {type:"integer"} end_beat = 1 #@param {type:"integer"}
# -*- coding: utf-8 -*- """piechartvisualisation.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1KDBBvrHTzO_PRs5gXV6z3u0zdPCdinla """ # Commented out IPython magic to ensure Python compatibility. import matplotlib.pyplot as plt import numpy as np import pandas as pd # %matplotlib inline from google.colab import files dff = files.upload() df = pd.read_csv('piechart.csv') print(df) #data category = df["category"] num = df["num"] color = ['red', 'lightskyblue'] #plot result = plt.pie(num, labels=category, autopct='%1.1f%%', colors=color) plt.show()
import matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers from tensorflow.keras.layers.experimental import preprocessing print(tf.__version__) from google.colab import files uploaded = files.upload() import io train = pd.read_csv(io.BytesIO(uploaded['train.csv'])) train_data = train.copy() train_data train_data.isna().sum() train_data = train_data.dropna() train_data = pd.get_dummies(train_data, prefix='', prefix_sep='') train_data
def upload_image(): uploaded = files.upload() image = imageio.imread(uploaded[list(uploaded.keys())[0]]) return transform.resize(image, [128, 128])
from sklearn import metrics import matplotlib.pyplot as plt import random from sklearn.linear_model import LinearRegression from sklearn.model_selection import train_test_split """**Next few lines are needed to integrate the kaggle dataset ([Google Play Store Apps](https://www.kaggle.com/lava18/google-play-store-apps)) into google colab**""" !pip install --quiet kaggle from google.colab import files files.upload() #upload the json file that contains api key from kaggle account !mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/. !chmod 600 ~/.kaggle/kaggle.json #altering permissions !kaggle datasets download -d lava18/google-play-store-apps #this is the api of the dataset obtained from kaggle from zipfile import ZipFile zip_file= ZipFile('google-play-store-apps.zip') #this downloaded zip file contains three csv file data=pd.read_csv(zip_file.open('googleplaystore.csv')) #we choose the googleplaystore.csv and load it into a dataframe called 'data' using pandas data.head() #prints first 5 entries of the dataframe data.info() #result shows there are 10841 entries in the dataframe , it also lists the columns present in the dataset
Original file is located at https://colab.research.google.com/drive/1vYyWiR6FsQFVmzTcEbTiTaInyjBbChsG """ # Load the Drive helper and mount from google.colab import drive # This will prompt for authorization. drive.mount('/content/drive') !rm mywarper.py !rm ae.py from google.colab import files src = list(files.upload().values())[0] !pip install torch !pip install torchvision !pip install --no-cache-dir -I pillow !pip install imageio import os import numpy as np import argparse import matplotlib.pyplot as plt import skimage from skimage import io, transform import scipy.io as sio from mywarper import warp
from datetime import date import matplotlib.pyplot as plt plt.style.use('fivethirtyeight') #Taking Input stname = input("Enter stock symbol : ") #Fetch the data #data = get_history(symbol= stname, start=date(2018,7,12), end=date(2020,7,12)) #data.reset_index() #Was unable to fetch the data #Load the data from google.colab import files uploaded = files.upload() #upload a csv file for fn in uploaded.keys(): print('Uploaded file "{name}" with length {length} bytes'.format( name=fn, length=len(uploaded[fn]))) File = fn # Store the data stock = pd.read_csv(File) #Set the index stock = stock.set_index(pd.DatetimeIndex(stock['Date'].values)) StartDate = stock.iat[0,2] EndDate = stock.iat[-1,2] #Show the Data
# -*- coding: utf-8 -*- """fourthbitperdiction.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/15dh01gtTgEBM6PkbijXY8hjvCP5-c-Tu """ #import the library pandas as pd import pandas as pd import numpy as np from google.colab import files upload = files.upload() df = pd.read_csv('CompleteDataset (2).csv') pd.read_csv('CompleteDataset (2).csv') #create a dataframe with all training data except the target column #and here X = df.iloc[:, 0:16].values Y = df.iloc[:, 19].values print(X) print(Y) from sklearn import datasets, linear_model from sklearn.model_selection import train_test_split X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.1)
import numpy as np import matplotlib.pyplot as plt from google.colab import files from io import BytesIO from PIL import Image import tensorflow as tf from tensorflow import keras upl = files.upload() img = Image.open(BytesIO(upl['img.jpg'])) img_style = Image.open(BytesIO(upl['img_style.jpg'])) plt.subplot(1, 2, 1) plt.imshow(img) plt.subplot(1, 2, 2) plt.imshow(img_style) plt.show() x_img = keras.applications.vgg19.preprocess_input(np.expand_dims(img, axis=0)) x_style = keras.applications.vgg19.preprocess_input( np.expand_dims(img_style, axis=0)) def deprocess_img(processed_img): x = processed_img.copy() if len(x.shape) == 4: x = np.squeeze(x, 0) assert len(x.shape) == 3, ( "Input to deprocess image must be an image of " "dimension [1, height, width, channel] or [height, width, channel]")
# coding: UTF-8 """ 2018.5.2 Colaboratoryファイル入出力 """ # アップロード from google.colab import files uploaded = files.upload() # ファイル入力 with open("input.csv", 'r') as f: print(f.read()) # ファイル出力 with open("output.txt", "w") as f: f.write("Nyanhello\nworld\n") # 確認 f = open('output.txt', 'r') print(f.read()) # ダウンロード from google.colab import files files.download('output.txt')
iris = load_iris() iris_frame = pd.DataFrame(data=np.c_[iris['data'], iris['target']], columns=iris['feature_names'] + ['target']) iris_frame['target'] = iris_frame['target'].map({ 1: "versicolor", 0: "setosa", 2: "virginica" }) X = iris_frame.iloc[:, :-1] Y = iris_frame.iloc[:, [-1]] iris_frame """우리는 이 데이터의 많은 feature 중 sepal에 관련된 두 개의 feature만 이용해서 학습을 할 것이다. 두개의 feature만 선택하는 이유는 visualization이 비교적 편리하기 때문이다. 따라서 이 데이터들을 의사 결정 나무 모델을 통해서 학습하고 각 점들을 예측한 후 이 결과를 2차원으로 visualizing함으로써 decision boundary를 확인해보겠다. 우선 가장 디폴트 상태부터 차례대로 파라미터를 변경해가면서 실습을 진행해보도록 하겠다.""" from google.colab import files uploaded = files.upload() # 파일 업로드 기능 실행 for fn in uploaded.keys(): # 업로드된 파일 정보 출력 print('User uploaded file "{name}" with length {length} bytes'.format( name=fn, length=len(uploaded[fn]))) """* [random_state=0, criterion = ‘gini’, splitter = ‘best’, max_depth=5]""" from sklearn.tree import DecisionTreeClassifier ##아래 하이퍼파라미터 수정으로 결과 확인 clf = DecisionTreeClassifier(random_state=0, criterion='gini', max_depth=5) import matplotlib.colors as colors df1 = iris_frame[["sepal length (cm)", "sepal width (cm)", "target"]] X = df1.iloc[:, 0:2] Y = df1.iloc[:, 2].replace({