Commit 8b826bad authored by Lafnoune Imane's avatar Lafnoune Imane
Browse files

CNN_inj_transfer erreurs

parent f0621fb5
......@@ -486,9 +486,27 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2/2 [==============================] - 2s 204ms/step - loss: 101.3311\n"
]
},
{
"data": {
"text/plain": [
"101.33109283447266"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"model.evaluate([testAttrX, testImagesX], testY)"
]
......
......@@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -44,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
......@@ -53,7 +53,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -150,7 +150,7 @@
"4 ID00007637202177411956430 11 2069 52.063412 79 Male Ex-smoker"
]
},
"execution_count": 3,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
......@@ -172,7 +172,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
......@@ -183,7 +183,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -227,6 +227,196 @@
"print('max value: ', np.amax(images))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Patient</th>\n",
" <th>Weeks</th>\n",
" <th>FVC</th>\n",
" <th>Percent</th>\n",
" <th>Age</th>\n",
" <th>Sex</th>\n",
" <th>SmokingStatus</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>ID00007637202177411956430</td>\n",
" <td>-4</td>\n",
" <td>2315</td>\n",
" <td>58.253649</td>\n",
" <td>79</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>ID00009637202177434476278</td>\n",
" <td>8</td>\n",
" <td>3660</td>\n",
" <td>85.282878</td>\n",
" <td>69</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>ID00010637202177584971671</td>\n",
" <td>0</td>\n",
" <td>3523</td>\n",
" <td>94.724672</td>\n",
" <td>60</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>ID00011637202177653955184</td>\n",
" <td>6</td>\n",
" <td>3326</td>\n",
" <td>85.987590</td>\n",
" <td>72</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>36</th>\n",
" <td>ID00012637202177665765362</td>\n",
" <td>33</td>\n",
" <td>3418</td>\n",
" <td>93.726006</td>\n",
" <td>65</td>\n",
" <td>Male</td>\n",
" <td>Never smoked</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1504</th>\n",
" <td>ID00419637202311204720264</td>\n",
" <td>6</td>\n",
" <td>3020</td>\n",
" <td>70.186855</td>\n",
" <td>73</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1513</th>\n",
" <td>ID00421637202311550012437</td>\n",
" <td>15</td>\n",
" <td>2739</td>\n",
" <td>82.045291</td>\n",
" <td>68</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1523</th>\n",
" <td>ID00422637202311677017371</td>\n",
" <td>6</td>\n",
" <td>1930</td>\n",
" <td>76.672493</td>\n",
" <td>73</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1531</th>\n",
" <td>ID00423637202312137826377</td>\n",
" <td>17</td>\n",
" <td>3294</td>\n",
" <td>79.258903</td>\n",
" <td>72</td>\n",
" <td>Male</td>\n",
" <td>Ex-smoker</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1540</th>\n",
" <td>ID00426637202313170790466</td>\n",
" <td>0</td>\n",
" <td>2925</td>\n",
" <td>71.824968</td>\n",
" <td>73</td>\n",
" <td>Male</td>\n",
" <td>Never smoked</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>176 rows × 7 columns</p>\n",
"</div>"
],
"text/plain": [
" Patient Weeks FVC Percent Age Sex \\\n",
"0 ID00007637202177411956430 -4 2315 58.253649 79 Male \n",
"9 ID00009637202177434476278 8 3660 85.282878 69 Male \n",
"18 ID00010637202177584971671 0 3523 94.724672 60 Male \n",
"27 ID00011637202177653955184 6 3326 85.987590 72 Male \n",
"36 ID00012637202177665765362 33 3418 93.726006 65 Male \n",
"... ... ... ... ... ... ... \n",
"1504 ID00419637202311204720264 6 3020 70.186855 73 Male \n",
"1513 ID00421637202311550012437 15 2739 82.045291 68 Male \n",
"1523 ID00422637202311677017371 6 1930 76.672493 73 Male \n",
"1531 ID00423637202312137826377 17 3294 79.258903 72 Male \n",
"1540 ID00426637202313170790466 0 2925 71.824968 73 Male \n",
"\n",
" SmokingStatus \n",
"0 Ex-smoker \n",
"9 Ex-smoker \n",
"18 Ex-smoker \n",
"27 Ex-smoker \n",
"36 Never smoked \n",
"... ... \n",
"1504 Ex-smoker \n",
"1513 Ex-smoker \n",
"1523 Ex-smoker \n",
"1531 Ex-smoker \n",
"1540 Never smoked \n",
"\n",
"[176 rows x 7 columns]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
......
......@@ -115,3 +115,32 @@ def load_images(input_directory,
images.append(outputImage)
return np.array(images)
def create_dataframe(df):
# new dataframe with one row per patient for training
train_data = []
patientlist = df.Patient.unique().tolist()
for patient in patientlist:
#select all data related to a patient
patientData = df[df['Patient'] == patient]
# save first measurements
firstMeasure = list(patientData.iloc[0, :].values)
#for ech measurement, add fist measurement and duration since first measurement
for i, week in enumerate(patientData['Weeks'].iloc[1:]):
fvc = patientData.iloc[i+1, 2]
trainDataPoint = firstMeasure + [week, fvc]
train_data.append(trainDataPoint)
training_df = pd.DataFrame(train_data)
training_df.columns = ['PatientID', 'First_week', 'First_FVC', 'First_Percent', 'Age', 'Sex', 'SmokingStatus'] + ['target_week', 'Target_FVC']
training_df['Delta_week'] = training_df['target_week'] - training_df['First_week']
#rearrange columns
training_df = training_df[['PatientID','Age','Sex','SmokingStatus', 'First_FVC', 'First_Percent','Delta_week','Target_FVC']]
return training_df
......@@ -110,7 +110,7 @@ def weightify(model_orig, custom_model, layer_modify,input_channel):
target_layer= Conv2D(32, (3, 3), activation='relu', padding='valid',use_bias=False)
input_shape = TensorShape([None, 240, 240, 4]) # to define h, w, c based on shape of layer input
input_shape = TensorShape([None, 240, 240, input_channel]) # to define h, w, c based on shape of layer input
target_layer.build(input_shape)
target_layer.set_weights([kernels_extra_channel])
#target_layer.set_weights([kernels_extra_channel, biases])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment