path
stringlengths 13
17
| screenshot_names
listlengths 1
873
| code
stringlengths 0
40.4k
| cell_type
stringclasses 1
value |
|---|---|---|---|
128022704/cell_12
|
[
"text_plain_output_1.png"
] |
data = deque_list.copy()
for i in range(ELEMENTS_LIMIT - 1):
_ = data.pop()
|
code
|
128022704/cell_5
|
[
"text_plain_output_1.png"
] |
usual_list = []
for i in range(ELEMENTS_LIMIT):
usual_list.append(i)
|
code
|
34144956/cell_9
|
[
"text_plain_output_1.png"
] |
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
images = train.iloc[:, 1:].values.reshape(train.shape[0], 28, 28).astype('float32') / 255.0
images = images.reshape(train.shape[0], 28, 28, 1)
images_test = test.iloc[:, 1:].values.reshape(test.shape[0], 28, 28).astype('float32') / 255.0
images_test = images_test.reshape(test.shape[0], 28, 28, 1)
label = train.iloc[:, 0].astype('int').values
ids_test = test.iloc[:, 0].values
(images.shape, images_test.shape)
plt.imshow(images_test[0].reshape(28, 28), cmap='gray')
|
code
|
34144956/cell_4
|
[
"text_plain_output_1.png"
] |
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
test.head()
|
code
|
34144956/cell_20
|
[
"text_plain_output_1.png",
"image_output_1.png"
] |
from keras.callbacks import EarlyStopping, ReduceLROnPlateau,ModelCheckpoint
from tensorflow.keras.layers import Dense,Conv2D, MaxPooling2D, Flatten,BatchNormalization,Dropout
from tensorflow.keras.models import Sequential
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.utils import to_categorical
label_train = to_categorical(label_train)
label_validation = to_categorical(label_validation)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(28, 28, 1), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(256, activation='relu'))
model.add(Dense(10, activation='sigmoid'))
model.summary()
from keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint
earlystop = EarlyStopping(patience=10)
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=2, verbose=1, factor=0.5, min_lr=1e-05)
callbacks = [earlystop, learning_rate_reduction, ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]
from tensorflow.keras.optimizers import Adam
model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=0.001), metrics=['accuracy'])
model.fit(images_train, label_train, validation_data=(images_validation, label_validation), batch_size=64, epochs=50, callbacks=callbacks)
|
code
|
34144956/cell_6
|
[
"application_vnd.jupyter.stderr_output_1.png"
] |
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
images = train.iloc[:, 1:].values.reshape(train.shape[0], 28, 28).astype('float32') / 255.0
images = images.reshape(train.shape[0], 28, 28, 1)
images_test = test.iloc[:, 1:].values.reshape(test.shape[0], 28, 28).astype('float32') / 255.0
images_test = images_test.reshape(test.shape[0], 28, 28, 1)
label = train.iloc[:, 0].astype('int').values
ids_test = test.iloc[:, 0].values
plt.imshow(images[0].reshape(28, 28), cmap='gray')
plt.title(label[0])
|
code
|
34144956/cell_11
|
[
"text_html_output_1.png"
] |
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
images = train.iloc[:, 1:].values.reshape(train.shape[0], 28, 28).astype('float32') / 255.0
images = images.reshape(train.shape[0], 28, 28, 1)
images_test = test.iloc[:, 1:].values.reshape(test.shape[0], 28, 28).astype('float32') / 255.0
images_test = images_test.reshape(test.shape[0], 28, 28, 1)
label = train.iloc[:, 0].astype('int').values
ids_test = test.iloc[:, 0].values
classes = train.iloc[:, 0].unique()
classes
|
code
|
34144956/cell_1
|
[
"text_plain_output_1.png"
] |
import os
import numpy as np
import pandas as pd
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
|
code
|
34144956/cell_18
|
[
"text_plain_output_1.png"
] |
from keras.callbacks import EarlyStopping, ReduceLROnPlateau,ModelCheckpoint
from keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint
earlystop = EarlyStopping(patience=10)
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=2, verbose=1, factor=0.5, min_lr=1e-05)
callbacks = [earlystop, learning_rate_reduction, ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]
|
code
|
34144956/cell_8
|
[
"application_vnd.jupyter.stderr_output_2.png",
"text_plain_output_4.png",
"text_plain_output_3.png",
"text_plain_output_1.png"
] |
import matplotlib.pyplot as plt
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
images = train.iloc[:, 1:].values.reshape(train.shape[0], 28, 28).astype('float32') / 255.0
images = images.reshape(train.shape[0], 28, 28, 1)
images_test = test.iloc[:, 1:].values.reshape(test.shape[0], 28, 28).astype('float32') / 255.0
images_test = images_test.reshape(test.shape[0], 28, 28, 1)
label = train.iloc[:, 0].astype('int').values
ids_test = test.iloc[:, 0].values
(images.shape, images_test.shape)
|
code
|
34144956/cell_15
|
[
"text_html_output_1.png"
] |
from tensorflow.keras.utils import to_categorical
from tensorflow.keras.utils import to_categorical
label_train = to_categorical(label_train)
label_validation = to_categorical(label_validation)
(label_train, label_validation)
|
code
|
34144956/cell_3
|
[
"text_plain_output_1.png"
] |
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
train.head()
|
code
|
34144956/cell_17
|
[
"text_plain_output_1.png",
"image_output_1.png"
] |
from tensorflow.keras.layers import Dense,Conv2D, MaxPooling2D, Flatten,BatchNormalization,Dropout
from tensorflow.keras.models import Sequential
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(28, 28, 1), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(256, activation='relu'))
model.add(Dense(10, activation='sigmoid'))
model.summary()
|
code
|
34144956/cell_24
|
[
"text_plain_output_1.png"
] |
from keras.callbacks import EarlyStopping, ReduceLROnPlateau,ModelCheckpoint
from tensorflow.keras.layers import Dense,Conv2D, MaxPooling2D, Flatten,BatchNormalization,Dropout
from tensorflow.keras.models import Sequential
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.utils import to_categorical
import matplotlib.pyplot as plt
import numpy as np
import numpy as np # linear algebra
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
images = train.iloc[:, 1:].values.reshape(train.shape[0], 28, 28).astype('float32') / 255.0
images = images.reshape(train.shape[0], 28, 28, 1)
images_test = test.iloc[:, 1:].values.reshape(test.shape[0], 28, 28).astype('float32') / 255.0
images_test = images_test.reshape(test.shape[0], 28, 28, 1)
label = train.iloc[:, 0].astype('int').values
ids_test = test.iloc[:, 0].values
(images.shape, images_test.shape)
from tensorflow.keras.utils import to_categorical
label_train = to_categorical(label_train)
label_validation = to_categorical(label_validation)
model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(28, 28, 1), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Conv2D(64, (3, 3), padding='same', activation='relu'))
model.add(BatchNormalization(momentum=0.9, epsilon=1e-05, gamma_initializer='uniform'))
model.add(MaxPooling2D())
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dense(256, activation='relu'))
model.add(Dense(10, activation='sigmoid'))
model.summary()
from keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint
earlystop = EarlyStopping(patience=10)
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=2, verbose=1, factor=0.5, min_lr=1e-05)
callbacks = [earlystop, learning_rate_reduction, ModelCheckpoint(filepath='best_model.h5', monitor='val_loss', save_best_only=True)]
from tensorflow.keras.optimizers import Adam
model.compile(loss='categorical_crossentropy', optimizer=Adam(lr=0.001), metrics=['accuracy'])
model.fit(images_train, label_train, validation_data=(images_validation, label_validation), batch_size=64, epochs=50, callbacks=callbacks)
test_prediction = model.predict(images_test)
test_labels = []
for i in range(len(test_prediction)):
test_labels.append(np.argmax(test_prediction[i]))
np.argmax(model.predict(images_test[2].reshape(1, 28, 28, 1)))
|
code
|
34144956/cell_12
|
[
"text_html_output_1.png"
] |
label_train
|
code
|
34144956/cell_5
|
[
"text_plain_output_1.png"
] |
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')
test = pd.read_csv('/kaggle/input/Kannada-MNIST/test.csv')
sample_submission = pd.read_csv('/kaggle/input/Kannada-MNIST/sample_submission.csv')
sample_submission.head()
|
code
|
33111161/cell_9
|
[
"text_html_output_1.png"
] |
import numpy as np
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
pokemon.isnull().sum()
print(pokemon[pd.isnull(pokemon['speed'])].index.tolist()[0])
print(pokemon[pd.isnull(pokemon['species'])].index.tolist()[0])
print(pokemon[pd.isnull(pokemon['type_1'])].index.tolist()[0])
print(pokemon[pd.isnull(pokemon['height_m'])].index.tolist()[0])
print(pokemon[pd.isnull(pokemon['weight_kg'])].index.tolist()[0])
pokemon.loc[240, :]
|
code
|
33111161/cell_4
|
[
"text_html_output_1.png"
] |
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.info()
|
code
|
33111161/cell_23
|
[
"text_plain_output_1.png"
] |
import numpy as np
import pandas as pd
import plotly.graph_objects as go
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
pokemon.isnull().sum()
pokemon.loc[240, :]
def find_min_and_max(column_name):
max_index = pokemon[column_name].idxmax()
max_pokemon = pokemon.loc[max_index, 'name']
min_index = pokemon[column_name].idxmin()
min_pokemon = pokemon.loc[min_index, 'name']
graph_1 = pokemon.groupby('type_1').count().sort_values(by='name')
index_graph_1 = pokemon.groupby('type_1').count().index
graph_2 = pokemon.groupby('type_2').count().sort_values(by='name')
index_graph_2 = pokemon.groupby('type_2').count().index
fig = go.Figure(data=[go.Bar(x=index_graph_1, y=graph_1['name'])], layout_title_text='First type distribution')
fig.show()
fig = go.Figure(data=[go.Bar(x=index_graph_2, y=graph_2['name'])], layout_title_text='Second type distribution')
fig.show()
|
code
|
33111161/cell_2
|
[
"text_plain_output_1.png"
] |
from plotly.offline import iplot, init_notebook_mode
import os
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from sklearn import preprocessing
init_notebook_mode()
from plotly.subplots import make_subplots
import plotly.express as px
import plotly.graph_objects as go
from plotly import tools
from plotly.offline import iplot, init_notebook_mode
|
code
|
33111161/cell_7
|
[
"text_plain_output_1.png"
] |
import numpy as np
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
|
code
|
33111161/cell_18
|
[
"text_plain_output_1.png"
] |
import numpy as np
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
pokemon.isnull().sum()
pokemon.loc[240, :]
def find_min_and_max(column_name):
max_index = pokemon[column_name].idxmax()
max_pokemon = pokemon.loc[max_index, 'name']
min_index = pokemon[column_name].idxmin()
min_pokemon = pokemon.loc[min_index, 'name']
column_to_display = ['attack', 'defense', 'sp_attack', 'sp_defense', 'hp', 'speed', 'catch_rate']
for colm in column_to_display:
find_min_and_max(colm)
|
code
|
33111161/cell_8
|
[
"text_html_output_2.png",
"text_html_output_1.png"
] |
import numpy as np
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
pokemon.isnull().sum()
|
code
|
33111161/cell_22
|
[
"text_plain_output_1.png"
] |
import numpy as np
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
mega_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'Mega' in x)].tolist()
dinamax_pokemons = pokemon.index[pokemon['name'].apply(lambda x: 'max' in x)].tolist()
to_delete = np.concatenate((mega_pokemons, dinamax_pokemons))
pokemon = pokemon.drop(to_delete, axis=0)
pokemon.columns
pokemon.isnull().sum()
pokemon.loc[240, :]
def find_min_and_max(column_name):
max_index = pokemon[column_name].idxmax()
max_pokemon = pokemon.loc[max_index, 'name']
min_index = pokemon[column_name].idxmin()
min_pokemon = pokemon.loc[min_index, 'name']
graph_1 = pokemon.groupby('type_1').count().sort_values(by='name')
index_graph_1 = pokemon.groupby('type_1').count().index
graph_2 = pokemon.groupby('type_2').count().sort_values(by='name')
index_graph_2 = pokemon.groupby('type_2').count().index
index_graph_1
|
code
|
33111161/cell_5
|
[
"text_plain_output_1.png"
] |
import pandas as pd
filepath = '../input/'
pokemon = pd.read_csv(filepath + 'complete-pokemon-dataset-updated-090420/pokedex_(Update.04.20).csv').drop('Unnamed: 0', axis=1)
columns_to_drop = ['japanese_name', 'german_name', 'against_normal', 'against_fire', 'against_water', 'against_electric', 'against_grass', 'against_ice', 'against_fight', 'against_poison', 'against_ground', 'against_flying', 'against_psychic', 'against_bug', 'against_rock', 'against_ghost', 'against_dragon', 'against_dark', 'against_steel', 'against_fairy']
pokemon = pokemon.drop(columns_to_drop, axis=1)
pokemon.shape
|
code
|
33106099/cell_13
|
[
"text_plain_output_1.png"
] |
import ast
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
input_processed.to_csv('cord_titles_abstracts_conclusions.csv')
input_excluded.to_csv('cord_titles_abstracts_conclusions_excluded.csv')
title_data = input_processed.loc[input_processed.section == 'title', :]
abstract_data = input_processed.loc[input_processed.section == 'abstract', :]
conclusion_data = input_processed.loc[(input_processed.section != 'title') & (input_processed.section != 'abstract'), :]
print('Number of unique sentences under titles:', title_data.sentence.nunique())
print('Number of unique sentence ids under titles:', title_data.sentence_id.nunique())
|
code
|
33106099/cell_8
|
[
"text_plain_output_1.png"
] |
import ast
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
|
code
|
33106099/cell_16
|
[
"text_plain_output_1.png"
] |
import ast
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
input_processed.to_csv('cord_titles_abstracts_conclusions.csv')
input_excluded.to_csv('cord_titles_abstracts_conclusions_excluded.csv')
title_data = input_processed.loc[input_processed.section == 'title', :]
abstract_data = input_processed.loc[input_processed.section == 'abstract', :]
conclusion_data = input_processed.loc[(input_processed.section != 'title') & (input_processed.section != 'abstract'), :]
title_data_final = pd.DataFrame(columns=['cord_uid', 'sentence', 'w2vVector'])
for cord_uid in title_data.cord_uid.unique():
title = ' '.join(title_data.loc[title_data.cord_uid == cord_uid, 'sentence'])
w2vVector = np.mean(list(title_data.loc[title_data.cord_uid == cord_uid, 'w2vVector']), axis=0)
title_data_final = title_data_final.append({'cord_uid': cord_uid, 'sentence': title, 'w2vVector': w2vVector}, ignore_index=True)
len(title_data_final)
|
code
|
33106099/cell_17
|
[
"text_plain_output_1.png"
] |
from sklearn.metrics.pairwise import cosine_similarity
import ast
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
input_processed.to_csv('cord_titles_abstracts_conclusions.csv')
input_excluded.to_csv('cord_titles_abstracts_conclusions_excluded.csv')
title_data = input_processed.loc[input_processed.section == 'title', :]
abstract_data = input_processed.loc[input_processed.section == 'abstract', :]
conclusion_data = input_processed.loc[(input_processed.section != 'title') & (input_processed.section != 'abstract'), :]
title_data_final = pd.DataFrame(columns=['cord_uid', 'sentence', 'w2vVector'])
for cord_uid in title_data.cord_uid.unique():
title = ' '.join(title_data.loc[title_data.cord_uid == cord_uid, 'sentence'])
w2vVector = np.mean(list(title_data.loc[title_data.cord_uid == cord_uid, 'w2vVector']), axis=0)
title_data_final = title_data_final.append({'cord_uid': cord_uid, 'sentence': title, 'w2vVector': w2vVector}, ignore_index=True)
cosine_similarity(title_data_final.w2vVector[0].reshape(1, -1), title_data_final.w2vVector[1].reshape(1, -1))[0][0]
|
code
|
33106099/cell_10
|
[
"application_vnd.jupyter.stderr_output_1.png"
] |
import ast
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
input_processed.to_csv('cord_titles_abstracts_conclusions.csv')
input_excluded.to_csv('cord_titles_abstracts_conclusions_excluded.csv')
input_processed
|
code
|
33106099/cell_12
|
[
"text_html_output_1.png"
] |
import ast
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import re
input_data_path = '/kaggle/input/'
input_data_file = 'filt_merged_text_vector_df_200430.csv'
input_data = pd.read_csv(input_data_path + input_data_file)
rep = {'text': '', 'cite_spans': '', 'ref_spans': '', 'section': '', 'Abstract': '', 'bioRxiv preprint': '', 'medRxiv preprint': '', 'doi:': ''}
rep = dict(((re.escape(k), v) for k, v in rep.items()))
pattern = re.compile('|'.join(rep.keys()))
sentences_temp = [pattern.sub(lambda m: rep[re.escape(m.group(0))], s) for s in input_data.sentence]
pattern = re.compile('.*[A-Za-z].*')
sentences_to_keep = [bool(re.search(pattern, s)) & (len(s.split(' ')) > 2) for s in sentences_temp]
input_processed = input_data.loc[sentences_to_keep, :]
sentences_to_drop = [not i for i in sentences_to_keep]
input_excluded = input_data.loc[sentences_to_drop, :]
input_processed.w2vVector = [re.sub(',+', ',', ','.join(w.replace('\n', '').split(' '))) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[,', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub(',\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\[', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = [re.sub('\\]', '', w) for w in input_processed.w2vVector]
input_processed.w2vVector = input_processed.w2vVector.apply(lambda s: list(ast.literal_eval(s)))
input_processed.to_csv('cord_titles_abstracts_conclusions.csv')
input_excluded.to_csv('cord_titles_abstracts_conclusions_excluded.csv')
title_data = input_processed.loc[input_processed.section == 'title', :]
abstract_data = input_processed.loc[input_processed.section == 'abstract', :]
conclusion_data = input_processed.loc[(input_processed.section != 'title') & (input_processed.section != 'abstract'), :]
print('Number of papers:', input_data.cord_uid.nunique())
print('Number of papers with title:', title_data.cord_uid.nunique())
print('Number of papers with abstract:', abstract_data.cord_uid.nunique())
print('Number of papers with conclusion:', conclusion_data.cord_uid.nunique())
|
code
|
129023760/cell_21
|
[
"image_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df = df.drop('Cabin', axis=1)
df = df.dropna(subset=['Age', 'Embarked'])
bins = [0, 13, 18, 40, 50, 60, 70, 120]
labels = ['0-12', '13-18', '18-39', '40-49', '50-59', '60-70', '70+']
df['agegroup'] = pd.cut(df.Age, bins, labels=labels, include_lowest=True)
df = df.drop('Age', axis=1)
colstodrop = ['PassengerId', 'Name', 'Ticket']
df = df.drop(colstodrop, axis=1)
dummies = pd.get_dummies(df[['Sex', 'Embarked', 'agegroup']])
df = pd.concat([df, dummies], axis=1)
df = df.drop(['Sex', 'Embarked', 'agegroup'], axis=1)
low = df['Fare'].quantile(0.05)
high = df['Fare'].quantile(0.95)
df = df[(df['Fare'] >= low) & (df['Fare'] <= high)]
print(df.Fare.describe([0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99]))
|
code
|
129023760/cell_25
|
[
"text_html_output_1.png",
"text_plain_output_1.png"
] |
from sklearn.ensemble import RandomForestClassifier
from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(n_estimators=100, random_state=42)
rfc.fit(X_train, y_train)
|
code
|
129023760/cell_29
|
[
"text_plain_output_1.png"
] |
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression()
logreg.fit(X_train, y_train)
y_predlogit = logreg.predict(X_test)
accuracylogit = accuracy_score(y_test, y_predlogit)
print('Accuracy:', round(accuracylogit * 100, 2), '%')
|
code
|
129023760/cell_11
|
[
"application_vnd.jupyter.stderr_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df = df.drop('Cabin', axis=1)
df = df.dropna(subset=['Age', 'Embarked'])
bins = [0, 13, 18, 40, 50, 60, 70, 120]
labels = ['0-12', '13-18', '18-39', '40-49', '50-59', '60-70', '70+']
df['agegroup'] = pd.cut(df.Age, bins, labels=labels, include_lowest=True)
df = df.drop('Age', axis=1)
colstodrop = ['PassengerId', 'Name', 'Ticket']
df = df.drop(colstodrop, axis=1)
print('Shape of the data: ', 'Rows: ', df.shape[0], 'Columns: ', df.shape[1])
print('\nInfo:')
print(df.info())
print('\nSummary Statistics:')
|
code
|
129023760/cell_1
|
[
"text_plain_output_1.png"
] |
import os
import numpy as np
import pandas as pd
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
|
code
|
129023760/cell_7
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
print('Shape of the data: ', 'Rows: ', df.shape[0], 'Columns: ', df.shape[1])
print('\nInfo:')
print(df.info())
print('\nSummary Statistics:')
df.describe()
|
code
|
129023760/cell_18
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df = df.drop('Cabin', axis=1)
df = df.dropna(subset=['Age', 'Embarked'])
bins = [0, 13, 18, 40, 50, 60, 70, 120]
labels = ['0-12', '13-18', '18-39', '40-49', '50-59', '60-70', '70+']
df['agegroup'] = pd.cut(df.Age, bins, labels=labels, include_lowest=True)
df = df.drop('Age', axis=1)
colstodrop = ['PassengerId', 'Name', 'Ticket']
df = df.drop(colstodrop, axis=1)
dummies = pd.get_dummies(df[['Sex', 'Embarked', 'agegroup']])
df = pd.concat([df, dummies], axis=1)
df = df.drop(['Sex', 'Embarked', 'agegroup'], axis=1)
sns.histplot(df['Fare'])
print(df.Fare.describe([0.1, 0.25, 0.5, 0.75, 0.9, 0.95, 0.99]))
|
code
|
129023760/cell_16
|
[
"text_html_output_1.png",
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df = df.drop('Cabin', axis=1)
df = df.dropna(subset=['Age', 'Embarked'])
bins = [0, 13, 18, 40, 50, 60, 70, 120]
labels = ['0-12', '13-18', '18-39', '40-49', '50-59', '60-70', '70+']
df['agegroup'] = pd.cut(df.Age, bins, labels=labels, include_lowest=True)
df = df.drop('Age', axis=1)
colstodrop = ['PassengerId', 'Name', 'Ticket']
df = df.drop(colstodrop, axis=1)
dummies = pd.get_dummies(df[['Sex', 'Embarked', 'agegroup']])
df = pd.concat([df, dummies], axis=1)
df = df.drop(['Sex', 'Embarked', 'agegroup'], axis=1)
print(df.shape)
df.head()
|
code
|
129023760/cell_3
|
[
"text_html_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
|
code
|
129023760/cell_14
|
[
"text_html_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df = df.drop('Cabin', axis=1)
df = df.dropna(subset=['Age', 'Embarked'])
bins = [0, 13, 18, 40, 50, 60, 70, 120]
labels = ['0-12', '13-18', '18-39', '40-49', '50-59', '60-70', '70+']
df['agegroup'] = pd.cut(df.Age, bins, labels=labels, include_lowest=True)
df = df.drop('Age', axis=1)
colstodrop = ['PassengerId', 'Name', 'Ticket']
df = df.drop(colstodrop, axis=1)
plt.figure(figsize=(14, 10))
plt.subplot(331)
sns.countplot(data=df, x='Pclass', hue='Survived')
plt.subplot(332)
sns.countplot(data=df, x='Sex', hue='Survived')
plt.subplot(333)
sns.countplot(data=df, x='SibSp', hue='Survived')
plt.subplot(334)
sns.countplot(data=df, x='Parch', hue='Survived')
plt.subplot(335)
sns.countplot(data=df, x='Embarked', hue='Survived')
plt.subplot(336)
sns.countplot(data=df, x='agegroup', hue='Survived')
plt.show()
|
code
|
129023760/cell_27
|
[
"text_plain_output_1.png",
"image_output_1.png"
] |
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn.ensemble import RandomForestClassifier
rfc = RandomForestClassifier(n_estimators=100, random_state=42)
rfc.fit(X_train, y_train)
y_pred = rfc.predict(X_test)
from sklearn.metrics import accuracy_score
accuracy = accuracy_score(y_test, y_pred)
print('Accuracy:', round(accuracy * 100, 2), '%')
|
code
|
129023760/cell_5
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import warnings
import pandas as pd, numpy as np, seaborn as sns, matplotlib.pyplot as plt
import warnings
warnings.simplefilter('ignore')
pd.set_option('display.max_columns', None)
df = pd.read_csv('/kaggle/input/titanic/train.csv')
df.head()
|
code
|
104121998/cell_21
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
|
code
|
104121998/cell_13
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
(b[0], b[2], b[-1])
|
code
|
104121998/cell_9
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a[1:3]
|
code
|
104121998/cell_25
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
d
|
code
|
104121998/cell_56
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A
|
code
|
104121998/cell_34
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
B.shape
B.ndim
|
code
|
104121998/cell_23
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
c.dtype
|
code
|
104121998/cell_30
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
|
code
|
104121998/cell_33
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
B.shape
|
code
|
104121998/cell_44
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1]
|
code
|
104121998/cell_20
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
|
code
|
104121998/cell_40
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
C.dtype
C.shape
C.size
|
code
|
104121998/cell_29
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
|
code
|
104121998/cell_39
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
C.dtype
C.shape
|
code
|
104121998/cell_26
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
d.dtype
|
code
|
104121998/cell_65
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
A.mean()
|
code
|
104121998/cell_48
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[0:2]
|
code
|
104121998/cell_41
|
[
"application_vnd.jupyter.stderr_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
C.dtype
C.shape
C.size
type(C[0])
|
code
|
104121998/cell_61
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a.dtype
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
a.sum()
a.mean()
a.std()
|
code
|
104121998/cell_54
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A
|
code
|
104121998/cell_67
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
A.mean()
A.std()
A.sum(axis=0)
|
code
|
104121998/cell_11
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a[::2]
|
code
|
104121998/cell_60
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a.dtype
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
a.sum()
a.mean()
|
code
|
104121998/cell_19
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
b.dtype
|
code
|
104121998/cell_69
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
A.mean()
A.std()
A.sum(axis=0)
A.sum(axis=1)
A.mean(axis=0)
|
code
|
104121998/cell_50
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[:2, :2]
|
code
|
104121998/cell_52
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A
|
code
|
104121998/cell_64
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
|
code
|
104121998/cell_7
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
(a[0], a[1])
|
code
|
104121998/cell_45
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1][0]
|
code
|
104121998/cell_49
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[:, :2]
|
code
|
104121998/cell_18
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
b
|
code
|
104121998/cell_32
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
B
|
code
|
104121998/cell_51
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[:2, 2:]
|
code
|
104121998/cell_68
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
A.mean()
A.std()
A.sum(axis=0)
A.sum(axis=1)
|
code
|
104121998/cell_62
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a.dtype
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
a.sum()
a.mean()
a.std()
a.var()
|
code
|
104121998/cell_59
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a.dtype
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
a.sum()
|
code
|
104121998/cell_8
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a[0:]
|
code
|
104121998/cell_16
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a
|
code
|
104121998/cell_38
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
C.dtype
|
code
|
104121998/cell_47
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1, 0]
|
code
|
104121998/cell_66
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
A.shape
A.ndim
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A[1] = np.array([10, 10, 10])
a = np.array([1, 2, 3, 4])
A = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
A.sum()
A.mean()
A.std()
|
code
|
104121998/cell_17
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a.dtype
|
code
|
104121998/cell_35
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
B.shape
B.ndim
B.size
|
code
|
104121998/cell_14
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
b[[0, 2, -1]]
|
code
|
104121998/cell_10
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
a[1:-1]
|
code
|
104121998/cell_37
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
np.array([1, 2, 3, 4], dtype=float)
np.array([1, 2, 3, 4], dtype=int)
c = np.array(['a', 'b', 'c'])
d = np.array([{'a': 1}])
A = np.array([[1, 2, 3], [4, 5, 6]])
B = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4], [3, 2, 1]]])
C = np.array([[[12, 11, 10], [9, 8, 7]], [[6, 5, 4]]])
|
code
|
104121998/cell_12
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
a = np.array([1, 2, 3, 4])
b = np.array([0, 0.5, 1, 1.5, 2])
b
|
code
|
104121998/cell_5
|
[
"text_plain_output_1.png"
] |
import numpy as np
import numpy as np # linear algebra
np.array([1, 2, 3, 4])
|
code
|
106202407/cell_13
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
def displayAllCateFeatInfo(df):
pass
def splitCabinForNewFeatures(df):
my_df = df.copy()
split_cabin_df = my_df.Cabin.str.split('/', expand=True)
my_df['CabinDeck'] = split_cabin_df[0]
my_df['CabinSide'] = split_cabin_df[2]
my_df.pop('Cabin')
return my_df
def splitNameToGenerateFamilyName(df):
my_df = df.copy()
split_name_df = my_df.Name.str.split(' ', expand=True)
my_df['FamilyName'] = split_name_df[1]
my_df.pop('Name')
return my_df
def calcUserConsumption(df):
my_df = df.copy()
consume_feats = ['RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck']
my_df['Consumption'] = my_df.loc[:, consume_feats].sum(axis=1)
my_df = my_df.drop(columns=consume_feats)
return my_df
def transformFeatures(df):
my_df = df.copy()
my_df = splitCabinForNewFeatures(my_df)
my_df = splitNameToGenerateFamilyName(my_df)
my_df = calcUserConsumption(my_df)
return my_df
transformed_train_X = transformFeatures(train_X)
transformed_train_X.info()
|
code
|
106202407/cell_9
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
def displayAllCateFeatInfo(df):
pass
def splitCabinForNewFeatures(df):
my_df = df.copy()
split_cabin_df = my_df.Cabin.str.split('/', expand=True)
my_df['CabinDeck'] = split_cabin_df[0]
my_df['CabinSide'] = split_cabin_df[2]
my_df.pop('Cabin')
return my_df
displayAllCateFeatInfo(splitCabinForNewFeatures(train_X))
|
code
|
106202407/cell_4
|
[
"text_html_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train.head()
|
code
|
106202407/cell_11
|
[
"text_html_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
def displayAllCateFeatInfo(df):
pass
def splitCabinForNewFeatures(df):
my_df = df.copy()
split_cabin_df = my_df.Cabin.str.split('/', expand=True)
my_df['CabinDeck'] = split_cabin_df[0]
my_df['CabinSide'] = split_cabin_df[2]
my_df.pop('Cabin')
return my_df
def splitNameToGenerateFamilyName(df):
my_df = df.copy()
split_name_df = my_df.Name.str.split(' ', expand=True)
my_df['FamilyName'] = split_name_df[1]
my_df.pop('Name')
return my_df
def calcUserConsumption(df):
my_df = df.copy()
consume_feats = ['RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck']
my_df['Consumption'] = my_df.loc[:, consume_feats].sum(axis=1)
my_df = my_df.drop(columns=consume_feats)
return my_df
calcUserConsumption(train_X).head()
|
code
|
106202407/cell_1
|
[
"text_plain_output_1.png"
] |
import os
import numpy as np
import pandas as pd
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
|
code
|
106202407/cell_7
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
train_X.info()
|
code
|
106202407/cell_8
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
def displayAllCateFeatInfo(df):
for column in df.columns:
if df[column].dtype == 'object':
print('column: {} -> {}, unique values: {}'.format(column, df[column].unique(), df[column].nunique()))
displayAllCateFeatInfo(train_X)
|
code
|
106202407/cell_15
|
[
"text_plain_output_1.png"
] |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
train = pd.read_csv('/kaggle/input/spaceship-titanic/train.csv')
test = pd.read_csv('/kaggle/input/spaceship-titanic/test.csv')
(train.shape, test.shape)
train_X = train.copy()
train_Y = train_X.pop('Transported')
def displayAllCateFeatInfo(df):
pass
def splitCabinForNewFeatures(df):
my_df = df.copy()
split_cabin_df = my_df.Cabin.str.split('/', expand=True)
my_df['CabinDeck'] = split_cabin_df[0]
my_df['CabinSide'] = split_cabin_df[2]
my_df.pop('Cabin')
return my_df
def splitNameToGenerateFamilyName(df):
my_df = df.copy()
split_name_df = my_df.Name.str.split(' ', expand=True)
my_df['FamilyName'] = split_name_df[1]
my_df.pop('Name')
return my_df
def calcUserConsumption(df):
my_df = df.copy()
consume_feats = ['RoomService', 'FoodCourt', 'ShoppingMall', 'Spa', 'VRDeck']
my_df['Consumption'] = my_df.loc[:, consume_feats].sum(axis=1)
my_df = my_df.drop(columns=consume_feats)
return my_df
def transformFeatures(df):
my_df = df.copy()
my_df = splitCabinForNewFeatures(my_df)
my_df = splitNameToGenerateFamilyName(my_df)
my_df = calcUserConsumption(my_df)
return my_df
transformed_train_X = transformFeatures(train_X)
def getNullInfo(df):
for column in df.columns:
print('column: {} -> {}'.format(column, df[column].isnull().sum()))
getNullInfo(transformed_train_X)
|
code
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.