<jupyter_start><jupyter_text>**This is a reference code. Not necessary for program to run****This R code is integrated in the main experiment code which is written in python**<jupyter_code>%load_ext blackcellmagic
# R code
suppressWarnings({suppressMessages({
          library(mlrMBO)
          library(ggplot2)
        })})

        ps = makeParamSet(
          makeIntegerParam("power", lower = 10, upper = 2200),
          makeIntegerParam("time", lower = 500, upper = 2000),
          makeDiscreteParam("gas", values = c("Argon")),
          makeIntegerParam("pressure", lower = 920, upper = 930)
        )

        ctrl = makeMBOControl(y.name = "ratio")
        ctrl = setMBOControlInfill(ctrl, opt = "focussearch", opt.focussearch.maxit = 10, opt.focussearch.points = 10000, crit = makeMBOInfillCritEI())

        data=read.csv("dataset-2.csv")
        data<-na.omit(data)
        suppressMessages({opt.state = initSMBO(par.set = ps, design = data, control = ctrl, minimize = FALSE, noisy = TRUE)})
        print("Proposed parameters:")
        prop = suppressWarnings({proposePoints(opt.state)})
        print(prop$prop.points)
        x<-prop$prop.points
        write.table(x, file = "dataset-2.csv", sep = ",", append = TRUE, quote = FALSE,col.names = FALSE, row.names = FALSE)<jupyter_output><empty_output><jupyter_text>**The following is the way to integrate R code in Python environment**<jupyter_code>#rpy2 is the package to be installed for R-Python interfacing!
import rpy2.robjects as robjects
        robjects.r('''
        suppressWarnings({suppressMessages({
          library(mlrMBO)
          library(ggplot2)
        })})

        ps = makeParamSet(
          makeIntegerParam("power", lower = 10, upper = 2200),
          makeIntegerParam("time", lower = 500, upper = 2000),
          makeDiscreteParam("gas", values = c("Argon")),
          makeIntegerParam("pressure", lower = 920, upper = 930)
        )

        ctrl = makeMBOControl(y.name = "ratio")
        ctrl = setMBOControlInfill(ctrl, opt = "focussearch", opt.focussearch.maxit = 10, opt.focussearch.points = 10000, crit = makeMBOInfillCritEI())

        data=read.csv("dataset-2.csv")
        data<-na.omit(data)
        suppressMessages({opt.state = initSMBO(par.set = ps, design = data, control = ctrl, minimize = FALSE, noisy = TRUE)})
        print("Proposed parameters:")
        prop = suppressWarnings({proposePoints(opt.state)})
        print(prop$prop.points)
        x<-prop$prop.points
        write.table(x, file = "dataset-2.csv", sep = ",", append = TRUE, quote = FALSE,col.names = FALSE, row.names = FALSE)
        ''')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13343384847342632, 'fraction_numerical': 0.022615906520919715, 'mean_word_length': 3.0643185298621747, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '581428', 'license': 'Apache-2.0', 'n_tokens_mistral': 865, 'n_tokens_neox': 798, 'n_words': 186, 'path': 'codes/ref-R-python-interface.ipynb', 'repo_name': 'TMMuller/pyControl', 'size': '2653'}