path
stringlengths 13
17
| screenshot_names
sequencelengths 1
873
| code
stringlengths 0
40.4k
| cell_type
stringclasses 1
value |
---|---|---|---|
130022960/cell_17 | [
"image_output_1.png"
] | import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.drop(columns=['Unnamed: 0'])
b = asus['Newspaper Ad Budget ($)'].quantile(0.98)
asus_new = asus[asus['Newspaper Ad Budget ($)'] < b]
asus_new.isnull().sum() * 100 / asus_new.shape[0] | code |
130022960/cell_24 | [
"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)
import seaborn as sns
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.drop(columns=['Unnamed: 0'])
b = asus['Newspaper Ad Budget ($)'].quantile(0.98)
asus_new = asus[asus['Newspaper Ad Budget ($)'] < b]
asus_new.isnull().sum() * 100 / asus_new.shape[0]
asus_new.duplicated().sum()
asus_new.drop(columns=['Unnamed: 0'])
x = asus_new['TV Ad Budget ($)']
y = asus_new['Sales ($)']
from sklearn.model_selection import train_test_split
x_train = x[:137]
x_test = x[137:]
y_train = y[:137]
y_test = y[137:]
print('x_train Shape: ', x_train.shape)
print('x_test Shape: ', x_test.shape)
print('y_train Shape: ', y_train.shape)
print('y_test Shape: ', y_test.shape) | code |
130022960/cell_14 | [
"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)
import seaborn as sns
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.drop(columns=['Unnamed: 0'])
b = asus['Newspaper Ad Budget ($)'].quantile(0.98)
asus_new = asus[asus['Newspaper Ad Budget ($)'] < b]
plt.figure(figsize=(6, 3))
sns.boxplot(asus_new['Newspaper Ad Budget ($)'])
plt.show() | code |
130022960/cell_10 | [
"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)
import seaborn as sns
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.drop(columns=['Unnamed: 0'])
plt.figure(figsize=(6, 3))
sns.boxplot(asus['Radio Ad Budget ($)'])
plt.show() | code |
130022960/cell_12 | [
"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)
import seaborn as sns
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.drop(columns=['Unnamed: 0'])
plt.figure(figsize=(6, 3))
sns.boxplot(asus['Sales ($)'])
plt.show() | code |
130022960/cell_5 | [
"image_output_1.png"
] | import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
asus = pd.DataFrame(pd.read_csv('/kaggle/input/advertising-sales-dataset/Advertising Budget and Sales.csv'))
asus.shape
asus.info() | code |
88101711/cell_9 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
df.info() | code |
88101711/cell_34 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_obj = df.select_dtypes(include=['O'])
df_obj.head() | code |
88101711/cell_30 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
df.info() | code |
88101711/cell_33 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_num.head() | code |
88101711/cell_44 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import seaborn as sns
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
tamanho_original = df_num.shape
sns.boxplot(x=df_num['price']) | code |
88101711/cell_20 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
print(df.isnull().sum()) | code |
88101711/cell_40 | [
"text_html_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_num.hist(figsize=(30, 30), bins=10, xlabelsize=10, ylabelsize=10) | code |
88101711/cell_48 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
import seaborn as sns
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_obj = df.select_dtypes(include=['O'])
df_datas = df.select_dtypes(include=['<M8[ns]'])
tamanho_original = df_num.shape
cols = ['price']
Q1 = df[cols].quantile(0.25)
Q3 = df[cols].quantile(0.75)
IQR = Q3 - Q1
df_num = df_num[~((df_num[cols] < Q1 - 1.5 * IQR) | (df_num[cols] > Q3 + 1.5 * IQR)).any(axis=1)]
sns.boxplot(x=df_num['price'])
tamanho_semout = df_num.shape
redução = tamanho_original[0] - tamanho_semout[0]
print(f' Foram removidas {redução} linhas onde o preço era discrepante (outliers)') | code |
88101711/cell_11 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
msno.bar(df[cols[:30]], fontsize=8, figsize=(20, 5)) | code |
88101711/cell_18 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
print('number of duplicate rows: ', duplicate_rows_df.shape) | code |
88101711/cell_32 | [
"application_vnd.jupyter.stderr_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist())) | code |
88101711/cell_38 | [
"text_html_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_num.info() | code |
88101711/cell_3 | [
"text_plain_output_1.png"
] | import os
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import missingno as msno
import os
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename)) | code |
88101711/cell_35 | [
"text_html_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_obj = df.select_dtypes(include=['O'])
df_datas = df.select_dtypes(include=['<M8[ns]'])
df_datas.head() | code |
88101711/cell_46 | [
"image_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
list(set(df.dtypes.tolist()))
df_num = df.select_dtypes(include=['float64', 'int64'])
df_obj = df.select_dtypes(include=['O'])
df_datas = df.select_dtypes(include=['<M8[ns]'])
tamanho_original = df_num.shape
cols = ['price']
Q1 = df[cols].quantile(0.25)
Q3 = df[cols].quantile(0.75)
IQR = Q3 - Q1
print(IQR)
df_num = df_num[~((df_num[cols] < Q1 - 1.5 * IQR) | (df_num[cols] > Q3 + 1.5 * IQR)).any(axis=1)] | code |
88101711/cell_24 | [
"text_plain_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
df['price'] = df['price'].str.replace('$', '')
df['price'] = df['price'].str.replace(',', '')
df['price'] = df['price'].astype(float)
df['host_response_rate'] = df['host_response_rate'].str.replace('%', '')
df['host_response_rate'] = df['host_response_rate'].astype(float)
df['host_acceptance_rate'] = df['host_acceptance_rate'].str.replace('%', '')
df['host_acceptance_rate'] = df['host_acceptance_rate'].astype(float) | code |
88101711/cell_22 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
df.drop(df.columns[[1, 2, 4, 5, 6, 7, 9, 13, 18, 19, 22, 34, 42, 43, 44, 45, 46, 47, 48, 54, 56, 57, 70, 71, 72, 73]], axis=1, inplace=True)
duplicate_rows_df = df[df.duplicated()]
df = df.dropna(subset=['review_scores_rating'])
print(df.isnull().sum()) | code |
88101711/cell_12 | [
"text_html_output_1.png"
] | import missingno as msno
import pandas as pd
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
cols = df.columns
msno.bar(df[cols[30:]], fontsize=8, figsize=(20, 5)) | code |
88101711/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)
df = pd.read_csv('../input/barcelona/listings.csv')
pd.set_option('display.max_columns', None)
df.head() | code |
1009787/cell_4 | [
"image_output_1.png"
] | import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import numpy as np
import pandas as pd
import kagglegym
train_df = pd.read_json('../input/train.json')
test_df = pd.read_json('../input/test.json')
import matplotlib.pyplot as plt
import seaborn as sns
color = sns.color_palette()
int_level = train_df['interest_level'].value_counts()
plt.figure(figsize=(8, 4))
sns.barplot(int_level.index, int_level.values, alpha=0.8, color=color[1])
plt.ylabel('Number of Occurrences', fontsize=12)
plt.xlabel('Interest level', fontsize=12)
plt.show() | code |
1009787/cell_2 | [
"text_html_output_1.png"
] | import pandas as pd
import numpy as np
import pandas as pd
import kagglegym
train_df = pd.read_json('../input/train.json')
test_df = pd.read_json('../input/test.json')
train_df.head() | code |
17118436/cell_13 | [
"application_vnd.jupyter.stderr_output_1.png"
] | batch_size = 8
max_epochs = 2000
print('Iniciando treinamento... ') | code |
17118436/cell_9 | [
"application_vnd.jupyter.stderr_output_1.png"
] | import pandas as pd
dfCleveland = pd.read_csv('cleveland_train.csv', header=None)
dfCleveland | code |
17118436/cell_19 | [
"text_plain_output_1.png"
] | import numpy as np
import tensorflow as tf
np.random.seed(4)
tf.set_random_seed(13)
mp = '.\\cleveland_model.h5'
model.save(mp)
np.set_printoptions(precision=4)
unknown = np.array([[0.75, 1, 0, 1, 0, 0.49, 0.27, 1, -1, -1, 0.62, -1, 0.4, 0, 1, 0.23, 1, 0]], dtype=np.float32)
predicted = model.predict(unknown)
print('Usando o modelo para previsão de doença cardíaca para as caracteristicas: ')
print(unknown)
print('\nO valor de previsão diagnóstico é (0=sem doença, 1=com doença): ')
print(predicted) | code |
17118436/cell_3 | [
"application_vnd.jupyter.stderr_output_2.png",
"text_plain_output_1.png"
] | import numpy as np
import keras as K
import tensorflow as tf
import pandas as pd
import seaborn as sns
import os
from matplotlib import pyplot as plt
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2' | code |
17118436/cell_17 | [
"application_vnd.jupyter.stderr_output_1.png"
] | print('Salvando modelo em arquivo \n')
mp = '.\\cleveland_model.h5'
model.save(mp) | code |
17109964/cell_42 | [
"text_plain_output_1.png"
] | animals = ['cat', 'dog', 'monkey']
for animal in animals:
print(animal) | code |
17109964/cell_63 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal, legs in d.items():
print('A %s has %d legs' % (animal, legs)) | code |
17109964/cell_81 | [
"text_plain_output_1.png"
] | hello = 'hello'
world = 'world'
def hello(name, loud=False):
if loud:
print('HELLO, %s' % name.upper())
else:
print('Hello, %s!' % name)
hello('Bob')
hello('Fred', loud=True) | code |
17109964/cell_13 | [
"text_plain_output_1.png"
] | x = 3
print(x + 1)
print(x - 1)
print(x * 2)
print(x ** 2) | code |
17109964/cell_57 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
print(d.get('monkey', 'N/A'))
print(d.get('fish', 'N/A')) | code |
17109964/cell_56 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
print(d['monkey']) | code |
17109964/cell_34 | [
"text_plain_output_1.png"
] | xs = [3, 1, 2]
xs.append('bar')
print(xs) | code |
17109964/cell_23 | [
"text_plain_output_1.png"
] | hello = 'hello'
world = 'world'
hw = hello + ' ' + world
print(hw) | code |
17109964/cell_79 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
def sign(x):
if x > 0:
return 'positive'
elif x < 0:
return 'negative'
else:
return 'zero'
for x in [-1, 0, 1]:
print(sign(x)) | code |
17109964/cell_90 | [
"text_plain_output_1.png"
] | import numpy as np
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
print(b)
print(b.shape)
print(b[0, 0], b[0, 1], b[1, 0]) | code |
17109964/cell_33 | [
"text_plain_output_1.png"
] | xs = [3, 1, 2]
xs[2] = 'foo'
print(xs) | code |
17109964/cell_44 | [
"text_plain_output_1.png"
] | animals = ['cat', 'dog', 'monkey']
animals = ['cat', 'dog', 'monkey']
for idx, animal in enumerate(animals):
print('#%d: %s' % (idx + 1, animal)) | code |
17109964/cell_20 | [
"text_plain_output_1.png"
] | print(t and f)
print(t or f)
print(not t)
print(t != f) | code |
17109964/cell_55 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
d['fish'] = 'wet'
print(d['fish']) | code |
17109964/cell_76 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
t[0] = 1 | code |
17109964/cell_92 | [
"text_plain_output_1.png"
] | import numpy as np
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
print(a) | code |
17109964/cell_94 | [
"text_plain_output_1.png"
] | import numpy as np
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
print(c) | code |
17109964/cell_39 | [
"text_plain_output_1.png"
] | nums = list(range(5))
print(nums)
print(nums[2:4])
print(nums[2:])
print(nums[:2])
print(nums[:])
print(nums[:-1])
nums[2:4] = [8, 9]
print(nums) | code |
17109964/cell_26 | [
"text_plain_output_1.png"
] | s = 'hello'
print(s.capitalize())
print(s.upper())
print(s.rjust(7))
print(s.center(7))
print(s.replace('l', '(ell)'))
print(' world '.strip()) | code |
17109964/cell_65 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
nums = list(range(5))
nums[2:4] = [8, 9]
nums = [0, 1, 2, 3, 4]
squares = []
for x in nums:
squares.append(x ** 2)
nums = [0, 1, 2, 3, 4]
squares = [x ** 2 for x in nums]
nums = [0, 1, 2, 3, 4]
even_squares = [x ** 2 for x in nums if x % 2 == 0]
nums = [0, 1, 2, 3, 4]
even_num_to_square = {x: x ** 2 for x in nums if x % 2 == 0}
print(even_num_to_square) | code |
17109964/cell_61 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
print('A %s has %d legs' % (animal, legs)) | code |
17109964/cell_54 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
print(d['cat'])
print('cat' in d) | code |
17109964/cell_72 | [
"text_plain_output_1.png"
] | from math import sqrt
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
from math import sqrt
print({int(sqrt(x)) for x in range(30)}) | code |
17109964/cell_19 | [
"text_plain_output_1.png"
] | t, f = (True, False)
print(type(t)) | code |
17109964/cell_49 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
nums = list(range(5))
nums[2:4] = [8, 9]
nums = [0, 1, 2, 3, 4]
squares = []
for x in nums:
squares.append(x ** 2)
nums = [0, 1, 2, 3, 4]
squares = [x ** 2 for x in nums]
print(squares) | code |
17109964/cell_89 | [
"text_plain_output_1.png"
] | import numpy as np
a = np.array([1, 2, 3])
print(type(a), a.shape, a[0], a[1], a[2])
a[0] = 5
print(a) | code |
17109964/cell_32 | [
"text_plain_output_1.png"
] | xs = [3, 1, 2]
print(xs, xs[2])
print(xs[-1], xs[-2], xs[-3]) | code |
17109964/cell_51 | [
"application_vnd.jupyter.stderr_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
nums = list(range(5))
nums[2:4] = [8, 9]
nums = [0, 1, 2, 3, 4]
squares = []
for x in nums:
squares.append(x ** 2)
nums = [0, 1, 2, 3, 4]
squares = [x ** 2 for x in nums]
nums = [0, 1, 2, 3, 4]
even_squares = [x ** 2 for x in nums if x % 2 == 0]
print(even_squares) | code |
17109964/cell_68 | [
"text_plain_output_1.png"
] | animals = ['cat', 'dog', 'monkey']
animals = ['cat', 'dog', 'monkey']
animals = {'cat', 'dog'}
print('cat' in animals)
print('fish' in animals)
animals.add('fish')
print(len(animals))
animals.add('cat')
print(len(animals)) | code |
17109964/cell_96 | [
"text_plain_output_1.png"
] | import numpy as np
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
d = np.eye(2)
e = np.random.random((2, 2))
print(e) | code |
17109964/cell_58 | [
"text_plain_output_1.png"
] | d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
print(d.get('fish', 'N/A')) | code |
17109964/cell_102 | [
"text_plain_output_1.png"
] | import numpy as np
import numpy as np
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
d = np.eye(2)
e = np.random.random((2, 2))
import numpy as np
a = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
b = a[:2, 1:3]
print(a[0, 1])
b[0, 0] = 77
print(a[0, 1]) | code |
17109964/cell_95 | [
"text_plain_output_1.png"
] | import numpy as np
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
d = np.eye(2)
print(d) | code |
17109964/cell_8 | [
"text_plain_output_1.png"
] | def quicksort(arr):
if len(arr) <= 1:
return arr
pivot = arr[int(len(arr) / 2)]
left = [x for x in arr if x < pivot]
middle = [x for x in arr if x == pivot]
right = [x for x in arr if x > pivot]
return quicksort(left) + middle + quicksort(right)
print(quicksort([3, 6, 8, 10, 1, 2, 1])) | code |
17109964/cell_15 | [
"text_plain_output_1.png"
] | y = 2.5
print(type(y))
print(y, y + 1, y * 2, y ** 2) | code |
17109964/cell_75 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
print(type(t))
print(d)
print(d[t])
print(d[1, 2]) | code |
17109964/cell_47 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
nums = list(range(5))
nums[2:4] = [8, 9]
nums = [0, 1, 2, 3, 4]
squares = []
for x in nums:
squares.append(x ** 2)
print(squares) | code |
17109964/cell_35 | [
"text_plain_output_1.png"
] | x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
print(x, xs) | code |
17109964/cell_93 | [
"text_plain_output_1.png"
] | import numpy as np
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
print(b) | code |
17109964/cell_24 | [
"text_plain_output_1.png"
] | hello = 'hello'
world = 'world'
hw12 = '%s %s %d %.4f' % (hello, world, 12, 10)
print(hw12) | code |
17109964/cell_100 | [
"text_plain_output_1.png"
] | import numpy as np
import numpy as np
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
d = np.eye(2)
e = np.random.random((2, 2))
import numpy as np
a = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
b = a[:2, 1:3]
print(b) | code |
17109964/cell_14 | [
"text_plain_output_1.png"
] | print(7 // 3)
print(7 % 3) | code |
17109964/cell_22 | [
"text_plain_output_1.png"
] | hello = 'hello'
world = 'world'
print(hello, len(hello)) | code |
17109964/cell_104 | [
"text_plain_output_1.png"
] | import numpy as np
import numpy as np
x = 3
xs = [3, 1, 2]
xs.append('bar')
x = xs.pop()
d = {'cat': 'cute', 'dog': 'furry'}
del d['fish']
d = {'person': 2, 'cat': 4, 'spider': 8}
for animal in d:
legs = d[animal]
d = {'person': 2, 'cat': 4, 'spider': 8}
d = {(x, x + 1): x for x in range(10)}
t = (5, 6)
a = np.array([1, 2, 3])
a[0] = 5
b = np.array([[1, 2, 3], [4, 5, 6]])
a = np.zeros((2, 2))
b = np.ones((1, 2))
c = np.full((2, 2), 7)
d = np.eye(2)
e = np.random.random((2, 2))
import numpy as np
a = np.array([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]])
b = a[:2, 1:3]
a = np.array([[1, 2], [3, 4], [5, 6]])
print(a)
print(a[[0, 1, 2], [0, 1, 0]])
print(np.array([a[0, 0], a[1, 1], a[2, 0]])) | code |
17109964/cell_12 | [
"text_plain_output_1.png"
] | x = 3
print(x, type(x)) | code |
17109964/cell_70 | [
"application_vnd.jupyter.stderr_output_1.png"
] | animals = ['cat', 'dog', 'monkey']
animals = ['cat', 'dog', 'monkey']
animals = {'cat', 'dog'}
animals.add('fish')
animals.add('cat')
animals = {'cat', 'dog', 'fish'}
for idx, animal in enumerate(animals):
print('#%d: %s' % (idx + 1, animal)) | code |
49120489/cell_21 | [
"text_plain_output_1.png"
] | from sklearn.ensemble import BaggingClassifier
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix
from sklearn.multiclass import OneVsRestClassifier
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import seaborn as sns
import seaborn as sns
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
from sklearn.metrics import confusion_matrix
import seaborn as sns
logreg_cm = confusion_matrix(Y_test, Y_predict1)
f, ax = plt.subplots(figsize=(5,5))
sns.heatmap(logreg_cm, annot=True, linewidth=0.7, linecolor='red', fmt='g', ax=ax, cmap="BuPu")
plt.title('Logistic Regression Classification Confusion Matrix')
plt.xlabel('Y predict')
plt.ylabel('Y test')
plt.show()
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
import matplotlib.pyplot as plt
max(rfecv.grid_scores_)
rfecv.grid_scores_
from sklearn.feature_selection import RFE
svmcla_2 = OneVsRestClassifier(BaggingClassifier())
rfe = RFE(estimator=svmcla_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
svmcla_2 = OneVsRestClassifier(BaggingClassifier())
svmcla_2 = svmcla_2.fit(X_train_3, Y_train)
Y_predict2 = svmcla_2.predict(X_test_3)
score_logreg = svmcla_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
svmcla_2 = OneVsRestClassifier(BaggingClassifier())
rfecv = RFECV(estimator=svmcla_2, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
print('Optimal number of features :', rfecv.n_features_)
print('Best features :', X_train.columns[rfecv.support_]) | code |
49120489/cell_13 | [
"text_plain_output_1.png"
] | from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import seaborn as sns
import seaborn as sns
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
from sklearn.metrics import confusion_matrix
import seaborn as sns
logreg_cm = confusion_matrix(Y_test, Y_predict1)
f, ax = plt.subplots(figsize=(5,5))
sns.heatmap(logreg_cm, annot=True, linewidth=0.7, linecolor='red', fmt='g', ax=ax, cmap="BuPu")
plt.title('Logistic Regression Classification Confusion Matrix')
plt.xlabel('Y predict')
plt.ylabel('Y test')
plt.show()
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
import matplotlib.pyplot as plt
plt.figure()
plt.xlabel('Number of features selected')
plt.ylabel('Cross validation score of number of selected features')
plt.plot(range(1, len(rfecv.grid_scores_) + 1), rfecv.grid_scores_)
plt.show()
max(rfecv.grid_scores_)
rfecv.grid_scores_ | code |
49120489/cell_2 | [
"image_output_1.png"
] | import pandas as pd
data = pd.read_csv('../input/breast-cancer-prediction-dataset/Breast_cancer_data.csv')
print('Dataset :', data.shape)
x = data.iloc[:, [0, 1, 2, 3]].values
data.info()
data[0:10] | code |
49120489/cell_19 | [
"text_plain_output_1.png",
"image_output_1.png"
] | from sklearn.ensemble import BaggingClassifier
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.multiclass import OneVsRestClassifier
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
from sklearn.feature_selection import RFE
svmcla_2 = OneVsRestClassifier(BaggingClassifier())
rfe = RFE(estimator=svmcla_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
print('Chosen best 5 feature by rfe:', X_train.columns[rfe.support_])
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
svmcla_2 = OneVsRestClassifier(BaggingClassifier())
svmcla_2 = svmcla_2.fit(X_train_3, Y_train)
Y_predict2 = svmcla_2.predict(X_test_3)
score_logreg = svmcla_2.score(X_test_3, Y_test)
print(score_logreg) | code |
49120489/cell_7 | [
"text_plain_output_1.png"
] | from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt
import seaborn as sns
import seaborn as sns
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
from sklearn.metrics import confusion_matrix
import seaborn as sns
logreg_cm = confusion_matrix(Y_test, Y_predict1)
f, ax = plt.subplots(figsize=(5, 5))
sns.heatmap(logreg_cm, annot=True, linewidth=0.7, linecolor='red', fmt='g', ax=ax, cmap='BuPu')
plt.title('Logistic Regression Classification Confusion Matrix')
plt.xlabel('Y predict')
plt.ylabel('Y test')
plt.show() | code |
49120489/cell_8 | [
"application_vnd.jupyter.stderr_output_1.png"
] | from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
score_logreg = logreg.score(X_test, Y_test)
print(score_logreg) | code |
49120489/cell_16 | [
"text_plain_output_1.png"
] | from sklearn.ensemble import BaggingClassifier
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt
import seaborn as sns
import seaborn as sns
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
from sklearn.metrics import confusion_matrix
import seaborn as sns
logreg_cm = confusion_matrix(Y_test, Y_predict1)
f, ax = plt.subplots(figsize=(5,5))
sns.heatmap(logreg_cm, annot=True, linewidth=0.7, linecolor='red', fmt='g', ax=ax, cmap="BuPu")
plt.title('Logistic Regression Classification Confusion Matrix')
plt.xlabel('Y predict')
plt.ylabel('Y test')
plt.show()
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
import matplotlib.pyplot as plt
max(rfecv.grid_scores_)
rfecv.grid_scores_
from sklearn.ensemble import BaggingClassifier
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
svmcla = OneVsRestClassifier(BaggingClassifier(SVC(C=10, kernel='rbf', random_state=9, probability=True), n_jobs=-1))
svmcla.fit(X_train, Y_train)
Y_predict2 = svmcla.predict(X_test)
svmcla_cm = confusion_matrix(Y_test, Y_predict2)
f, ax = plt.subplots(figsize=(5, 5))
sns.heatmap(svmcla_cm, annot=True, linewidth=0.7, linecolor='red', fmt='g', ax=ax, cmap='BuPu')
plt.title('SVM Classification Confusion Matrix')
plt.xlabel('Y predict')
plt.ylabel('Y test')
plt.show() | code |
49120489/cell_17 | [
"text_plain_output_2.png",
"application_vnd.jupyter.stderr_output_1.png"
] | from sklearn.ensemble import BaggingClassifier
from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
from sklearn.ensemble import BaggingClassifier
from sklearn.multiclass import OneVsRestClassifier
from sklearn.svm import SVC
svmcla = OneVsRestClassifier(BaggingClassifier(SVC(C=10, kernel='rbf', random_state=9, probability=True), n_jobs=-1))
svmcla.fit(X_train, Y_train)
Y_predict2 = svmcla.predict(X_test)
score_svmcla = svmcla.score(X_test, Y_test)
print(score_svmcla) | code |
49120489/cell_10 | [
"text_html_output_1.png",
"text_plain_output_1.png"
] | from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
print('Chosen best 5 feature by rfe:', X_train.columns[rfe.support_])
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
print(score_logreg) | code |
49120489/cell_12 | [
"image_output_1.png"
] | from sklearn.feature_selection import RFE
from sklearn.feature_selection import RFECV
from sklearn.linear_model import LogisticRegression
from sklearn.linear_model import LogisticRegression
logreg = LogisticRegression(C=10)
logreg.fit(X_train, Y_train)
Y_predict1 = logreg.predict(X_test)
score_logreg = logreg.score(X_test, Y_test)
from sklearn.feature_selection import RFE
logreg_2 = LogisticRegression()
rfe = RFE(estimator=logreg_2, n_features_to_select=5, step=1)
rfe = rfe.fit(X_train, Y_train)
X_train_3 = rfe.transform(X_train)
X_test_3 = rfe.transform(X_test)
logreg_2 = LogisticRegression()
logreg_2 = logreg_2.fit(X_train_3, Y_train)
Y_predict2 = logreg.predict(X_test_3)
score_logreg = logreg_2.score(X_test_3, Y_test)
from sklearn.feature_selection import RFECV
logreg_3 = LogisticRegression()
rfecv = RFECV(estimator=logreg_3, step=1, cv=5, scoring='accuracy')
rfecv = rfecv.fit(X_train, Y_train)
print('Optimal number of features :', rfecv.n_features_)
print('Best features :', X_train.columns[rfecv.support_]) | code |
33096822/cell_13 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import matplotlib.pyplot as plt
avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume']
avo.groupby('region').sum()['Total Volume'].idxmax()
plt.figure(figsize=(12, 5))
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume'].sort_values().plot.bar() | code |
33096822/cell_9 | [
"text_plain_output_1.png",
"image_output_1.png"
] | avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0] | code |
33096822/cell_4 | [
"text_plain_output_1.png",
"image_output_1.png"
] | import matplotlib.pyplot as plt
plt.figure(figsize=(15, 5))
avo['AveragePrice'].plot() | code |
33096822/cell_6 | [
"text_html_output_1.png"
] | import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
type(avo['Date'].iloc[0])
avo['Date'] = pd.to_datetime(avo['Date'])
type(avo['Date'].iloc[0]) | code |
33096822/cell_2 | [
"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 |
33096822/cell_11 | [
"text_plain_output_1.png"
] | avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume'] | code |
33096822/cell_7 | [
"text_plain_output_1.png"
] | avo[avo['AveragePrice'] == avo['AveragePrice'].max()]['Date'] | code |
33096822/cell_18 | [
"text_plain_output_1.png"
] | import matplotlib.pyplot as plt
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
type(avo['Date'].iloc[0])
avo['Date'] = pd.to_datetime(avo['Date'])
type(avo['Date'].iloc[0])
avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume']
avo.groupby('region').sum()['Total Volume'].idxmax()
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo['Revenue'] = avo['AveragePrice'] * avo['Total Volume']
c = avo.groupby('type').sum()['Revenue']['conventional']
o = avo.groupby('type').sum()['Revenue']['organic']
o - c
a = pd.DataFrame(avo.groupby(['region', 'type']).sum()['Total Volume'].values.reshape((-1, 2)))
a['ratio'] = a[1] / a[0]
a['region'] = avo['region'].unique()
a.set_index('region', inplace=True)
a
a['ratio'].sort_values().plot.barh()
newdf = avo[['region', 'AveragePrice']]
meandf = newdf.groupby('region').mean()
meandf.reset_index(inplace=True)
meandf['state_name_len'] = meandf['region'].str.len()
plt.scatter(x=meandf['AveragePrice'], y=meandf['state_name_len']) | code |
33096822/cell_8 | [
"text_plain_output_1.png",
"image_output_1.png"
] | avo[avo['AveragePrice'] == avo['AveragePrice'].min()]['Date'] | code |
33096822/cell_15 | [
"text_plain_output_1.png"
] | import matplotlib.pyplot as plt
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
type(avo['Date'].iloc[0])
avo['Date'] = pd.to_datetime(avo['Date'])
type(avo['Date'].iloc[0])
avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume']
avo.groupby('region').sum()['Total Volume'].idxmax()
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo['Revenue'] = avo['AveragePrice'] * avo['Total Volume']
c = avo.groupby('type').sum()['Revenue']['conventional']
o = avo.groupby('type').sum()['Revenue']['organic']
o - c
a = pd.DataFrame(avo.groupby(['region', 'type']).sum()['Total Volume'].values.reshape((-1, 2)))
a['ratio'] = a[1] / a[0]
a['region'] = avo['region'].unique()
a.set_index('region', inplace=True)
a | code |
33096822/cell_16 | [
"text_plain_output_1.png"
] | import matplotlib.pyplot as plt
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
type(avo['Date'].iloc[0])
avo['Date'] = pd.to_datetime(avo['Date'])
type(avo['Date'].iloc[0])
avo['Month'] = avo['Date'].apply(lambda x: x.month)
avo.groupby('Month').mean()['AveragePrice'].sort_values(ascending=False).index[0]
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo.groupby('region').sum()['Total Volume']
avo.groupby('region').sum()['Total Volume'].idxmax()
avo.drop(avo.loc[avo['region'] == 'TotalUS'].index, inplace=True)
avo['Revenue'] = avo['AveragePrice'] * avo['Total Volume']
c = avo.groupby('type').sum()['Revenue']['conventional']
o = avo.groupby('type').sum()['Revenue']['organic']
o - c
a = pd.DataFrame(avo.groupby(['region', 'type']).sum()['Total Volume'].values.reshape((-1, 2)))
a['ratio'] = a[1] / a[0]
a['region'] = avo['region'].unique()
a.set_index('region', inplace=True)
a
a['ratio'].idxmax() | code |
33096822/cell_3 | [
"text_plain_output_1.png"
] | import matplotlib.pyplot as plt
import seaborn as sns
import datetime
avo = pd.read_csv('/kaggle/input/avocado-prices/avocado.csv')
avo | code |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.