{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# !pip install git+https://download.radtorch.com/\n!git clone -b nightly https://github.com/radtorch/radtorch/ -q\n!pip install radtorch/. -q","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from radtorch import pipeline, core\nfrom radtorch.settings import *","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"data_dir = '/kaggle/input/siim-isic-melanoma-classification/jpeg/train/'\nlabel_csv = pd.read_csv('/kaggle/input/siim-isic-melanoma-classification/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_path = []\nfor i, r in label_csv.iterrows():\n    image_path.append(data_dir+r['image_name']+'.jpg')\n    \nlabel_csv['IMAGE_PATH']=image_path","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf  = pipeline.Image_Classification(\n        data_directory=data_dir, \n        table=label_csv,\n        image_label_column='benign_malignant',\n        is_dicom=False,\n        balance_class=True, \n        balance_class_method='upsample',\n        type='xgboost',\n        parameters={'tree_method':'gpu_hist'},\n        model_arch='resnet50',\n        pre_trained=True,\n        batch_size=16,\n        sampling=0.2,\n        test_percent=0.2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf.data_processor.dataset_info(plot=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf.run()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf.classifier.confusion_matrix()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf.classifier.roc()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"clf.classifier.test_accuracy()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_csv=pd.read_csv('/kaggle/input/siim-isic-melanoma-classification/sample_submission.csv')\ntest_dir = '/kaggle/input/siim-isic-melanoma-classification/jpeg/test/'\n\ntest_csv.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"image_path = []\nfor i, r in test_csv.iterrows():\n    image_path.append(test_dir+r['image_name']+'.jpg')\n    \ntest_csv['IMAGE_PATH']=image_path\n\ntest_csv.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"predictions = []\nfor i, r in tqdm(test_csv.iterrows(), total=len(test_csv)):\n    pred = clf.classifier.predict(r['IMAGE_PATH'], all_predictions=True)\n    predictions.append(pred.iloc[1].PREDICTION_ACCURACY)\n    \ntest_csv['target']=predictions","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_csv.to_csv('predictions.csv', index=False)","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}