<jupyter_start><jupyter_text>LDPM_pond Load training data<jupyter_code>uploaded = files.upload()
df1 = pd.read_csv('all_train_data_norm.csv', index_col=0)
df1.head()<jupyter_output><empty_output><jupyter_text>Training<jupyter_code>all_rs = []
all_pred = []
all_y = []
for i in range(208):
  X_train,y_train, X_test, y_test = get_data_at_row_col(df1, str(i))
  RF_LDPM = RandomForestRegressor()
  RF_LDPM.fit(X_train, y_train)
  y_pred = RF_LDPM.predict(X_test)
  rs = r2_score(y_test,y_pred)
  all_rs.append(rs)
  all_pred.append(y_pred)
  all_y.append(y_test)
print(np.min(all_rs))  #expected output: ~0.94<jupyter_output>0.9398247489175346<jupyter_text>GRM_pond Load training data<jupyter_code>uploaded = files.upload()
df4 = pd.read_csv('all_pred_for_GRM_RF.csv')
df4.head()<jupyter_output><empty_output><jupyter_text>Data processing<jupyter_code>features_num = list(range(208))
features = []
for i in features_num:
  features.append(str(i))

label = ['Growth rate']

train = df4[df4['is_train'] == True ]
test = df4[df4['is_train'] == False ]
X_train = train[features].to_numpy()
X_test = test[features].to_numpy()
y_train = train[label].to_numpy()[:,0]
y_test = test[label].to_numpy()[:,0]<jupyter_output><empty_output><jupyter_text>Training<jupyter_code>RF = RandomForestRegressor()
RF.fit(X_train, y_train)
y_pred = RF.predict(X_test)
rs = r2_score(y_test,y_pred)
print(rs)  #expected output: ~0.98<jupyter_output>0.9803534493185948<jupyter_text>Ploting<jupyter_code>figure =  plt.figure(figsize=(3.5,3.5))
plt.plot(np.array(y_test), np.array(y_pred), 'ro',markersize=1)
plt.xlabel('Measured Growth Rate')
plt.ylabel('Predicted Growth Rate')<jupyter_output><empty_output><jupyter_text>Growth simulation Set initial conditions<jupyter_code># initialize conditions 0.05h as interveal 
light = np.ones(20)*224
light = np.append(light,np.ones(20)*504)
light = np.append(light,np.ones(20)*728)
light = np.append(light,np.ones(200)*840)
light = np.append(light,np.ones(20)*728)
light = np.append(light,np.ones(20)*504)
light = np.append(light,np.ones(20)*224)

initial_conc = [0.1,0.4,0.6,0.8]<jupyter_output><empty_output><jupyter_text>Run simulation<jupyter_code>light_input = light
conc_input = initial_conc
record = run_simualtion_RF('all_train_data_norm.csv','all_pred_for_GRM_RF.csv',0.05, conc_input, light_input )

growth_prediction = []

for i in range(len(light_input)):
  temp = []
  for j in range(len(conc_input)):
    temp.append(record[i][j][0])
  growth_prediction.append(temp)

df5 = pd.DataFrame(dcw_denormalization(np.array(growth_prediction)))

df5.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15349194167306215, 'fraction_numerical': 0.04528012279355334, 'mean_word_length': 8.212014134275618, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '114494', 'license': 'MIT', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1091, 'n_words': 136, 'path': 'Pond_LDPM_and_GRM.ipynb', 'repo_name': 'joshuayuanlab151/LDPM-and-GRM', 'size': '2606'}