Git Product home page Git Product logo

Comments (3)

mmann1123 avatar mmann1123 commented on September 26, 2024 1

This should be possible by using the following. I am giving some examples of how to do preprocessing in the pipeline as well.

with gw.config.update(ref_image=target_string):
    with gw.open(select_images, nodata=9999, stack_dim="band") as src:

          # Create a prediction stack where each variable used in regression is a band
          src.gw.save(
              "outputs/pred_stack.tif",
              compress="lzw",
              overwrite=True,  # bigtiff=True
          )
        # extract variables
        df = gw.extract(src, lu_poly, verbose=1)
        y = something
        X = something

# Create a pipeline with the preprocessor and the OLS model
pipeline_performance = Pipeline([
    ('scaler', StandardScaler()),
    ('model', LinearRegression())
])

# use sklearn to fit desired model
pipeline_performance.fit(X, y)

# predict to stack
def user_func(w, block, model):
    pred_shape = list(block.shape)
    X = block.reshape(pred_shape[0], -1).T
    pred_shape[0] = 1
    y_hat = model.predict(X)
    X_reshaped = y_hat.T.reshape(pred_shape)
    return w, X_reshaped

# create prediction image
gw.apply(
    "outputs/pred_stack.tif",
    f"outputs/final_model_OLS_prediction.tif",
    user_func,
    args=(pipeline_performance,),
    n_jobs=16,
    count=1,
)

That being said, I will eventually look into adding regression more directly as an option.

from geowombat.

jgrss avatar jgrss commented on September 26, 2024

Hi @ritviksahajpal, thanks for the question. Are you referring to the ml module? Currently, there are no plans to add regression. However, we (@mmann1123) would be happy to look into it if there is interest. Do you have a specific idea or example in mind, or basically a general framework similar to the classifiers module?

from geowombat.

ritviksahajpal avatar ritviksahajpal commented on September 26, 2024

Thank you! Yes, referring to the ml module, a general framework was what I was thinking, I would be happy to help test it once done.

from geowombat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.