Kaggle competition: Plant Seedlings Classification
y_val_1= y_val_1.rename(columns={ 0 : 'Survived_Prob'})
 y_val_1['PassengerId'] = data_val_Id
y_val_1['final_predicted'] = y_val_1.Survived_Prob.map(lambda x: 1 if x > 0.57 else 0)
 y_val_1.head()<save_to_csv>
from fastai import *
from fastai.vision import *
import matplotlib.pyplot as plt
output = pd.DataFrame({'PassengerId': y_val_1.PassengerId, 'Survived': y_val_1.final_predicted})
 output.to_csv('my_submission_GLM.csv', index=False)
 print("Your submission was successfully saved!" )<import_modules>
path = Path('input/train/' )
for dirname, _, filenames in os.walk('/kaggle/input'):
for filename in filenames:
print(os.path.join(dirname, filename))
%matplotlib inline<load_from_csv>
np.random.seed(42)
 data = ImageDataBunch.from_folder(path,test='.. /test', ds_tfms=get_transforms() ,valid_pct=0.25,size=299,bs=32,num_workers=0)
 data.normalize(imagenet_stats )
training_set = pd.read_csv("/kaggle/input/house-prices-advanced-regression-techniques/train.csv")
 testing_set = pd.read_csv("/kaggle/input/house-prices-advanced-regression-techniques/test.csv")
 sample_submission = pd.read_csv("/kaggle/input/house-prices-advanced-regression-techniques/sample_submission.csv" )<train_model>
data.show_batch(rows=3,figsize=(7,6))
print("Training Set: ",training_set.shape)
 print("Testing Set ",testing_set.shape )<load_from_csv>
learn = create_cnn(data,models.resnet50,metrics=error_rate )
with open("/kaggle/input/house-prices-advanced-regression-techniques/data_description.txt","r")as data_desc:
for line in data_desc.readlines() [:10]:
print(line )<prepare_x_and_y>
learn.lr_find()
y = training_set["SalePrice"]<count_missing_values>
learn.fit_one_cycle(6,slice(1e-2))
def check_null(df,col):
return print(col," ",df[col].isnull().sum() )<groupby>
learn.save('stg-1' )
def categorical_saleprice(df,col):
return df.groupby(col)["SalePrice"].mean()<compute_train_metric>
learn.lr_find()
check_null(training_set,columns_impute_train[0])
 categorical_saleprice(training_set,columns_impute_train[0] )<groupby>
learn.unfreeze()
learn.fit_one_cycle(4,max_lr=slice(1e-4,1e-3))
MasVnrType = list(training_set.groupby(columns_impute_train[0])["SalePrice"].mean().index)
 sale_price = list(training_set.groupby(columns_impute_train[0])["SalePrice"].mean().values )<filter>
data = ImageDataBunch.from_folder(path,test='.. /test', ds_tfms=get_transforms() ,valid_pct=0.25,size=350,bs=32,num_workers=0)
 data.normalize(imagenet_stats )
training_set[training_set[columns_impute_train[0]].isnull() ]<feature_engineering>
interp = ClassificationInterpretation.from_learner(learn)
 print(metrics.classification_report(interp.y_true.numpy() , interp.pred_class.numpy() ,target_names =data.classes))
training_set.loc[training_set['Id']==235,'MasVnrType'] = "BrkFace"
training_set.loc[training_set['Id']==530,'MasVnrType'] = "BrkFace"
training_set.loc[training_set['Id']==651,'MasVnrType'] = "BrkFace"
training_set.loc[training_set['Id']==937,'MasVnrType'] = "None"
training_set.loc[training_set['Id']==974,'MasVnrType'] = "None"
training_set.loc[training_set['Id']==978,'MasVnrType'] = "BrkFace"
training_set.loc[training_set['Id']==1244,'MasVnrType'] = "Stone"
training_set.loc[training_set['Id']==1279,'MasVnrType'] = "Stone"<groupby>
learn.save('stg-2' )
print(training_set.groupby(columns_impute_train[1])["SalePrice"].mean())
 print(training_set.groupby(columns_impute_train[0])["MasVnrArea"].value_counts())
 print(training_set[(training_set["MasVnrType"]=="Stone")&(training_set["SalePrice"] >= 230000)][["MasVnrArea","SalePrice"]].mean() )<filter>
learn.data=data
training_set[(training_set["MasVnrType"]=="BrkFace")&(training_set["SalePrice"] >= 200000)][["MasVnrArea","SalePrice"]].mean()<filter>
learn.unfreeze()
learn.fit_one_cycle(4,max_lr=slice(1e-5,1e-4))
training_set[training_set[columns_impute_train[1]].isnull() ][["MasVnrType","SalePrice"]]<feature_engineering>
preds,y=learn.get_preds(ds_type=DatasetType.Test )
training_set.loc[training_set['Id']==937,'MasVnrArea'] = 0.0
training_set.loc[training_set['Id']==974,'MasVnrArea'] = 0.0
training_set.loc[training_set['Id']==978,'MasVnrArea'] = 332.00
training_set.loc[training_set['Id']==1244,'MasVnrArea'] = 280.3
training_set.loc[training_set['Id']==1279,'MasVnrArea'] = 280.3
training_set.loc[training_set['Id']==235,'MasVnrArea'] = 332.00
training_set.loc[training_set['Id']==530,'MasVnrArea'] = 332.00
training_set.loc[training_set['Id']==651,'MasVnrArea'] = 332.00<count_values>
preds = np.argmax(preds, axis = 1)
 preds_classes = [data.classes[i] for i in preds]
<groupby><EOS> 
submission = pd.DataFrame({ 'file': os.listdir('input/test'), 'species': preds_classes })
 submission.to_csv('test_classification_results.csv', index=False )